This class solves the optimization problem with the Ipopt software package and returns the estiamted superquadric, better fitting a given point cloud. More...
#include <superquadric.h>
Inherits TNLP.
Public Member Functions | |
void | init () |
Init function. | |
void | setPoints (const std::deque< yarp::sig::Vector > &point_cloud, const int &optimizer_points) |
Set point to be used for superquadric estimation. More... | |
void | configure (yarp::os::ResourceFinder *rf, bool bounds_aut, const std::string &object_class) |
Configure function. More... | |
yarp::sig::Vector | get_result () const |
Extract the solution. More... | |
bool | readMatrix (const std::string &tag, yarp::sig::Matrix &matrix, const int &dimension, yarp::os::ResourceFinder *rf) |
Function for reading matrices from config files. More... | |
Data Fields | |
yarp::sig::Vector | solution |
Final solution. | |
std::deque< yarp::sig::Vector > | points_downsampled |
3D points actually used for superquadric estimation | |
Protected Member Functions | |
bool | get_nlp_info (Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style) |
Get info for the nonlinear problem to be solved with ipopt. More... | |
void | computeBounds () |
Compute bounds variable from the point cloud for speeding up optimization. | |
bool | get_bounds_info (Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u) |
Get variable bounds for the nonlinear problem to be solved with ipopt. More... | |
bool | get_starting_point (Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda) |
Get the starting point for the nonlinear problem to be solved with ipopt. More... | |
bool | eval_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value) |
Cost function of the nonlinear problem to be solved with ipopt. More... | |
void | F (const Ipopt::Number *x, std::deque< yarp::sig::Vector > &points, bool &new_x) |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt. More... | |
double | f (const Ipopt::Number *x, const yarp::sig::Matrix &R, const yarp::sig::Vector &point_cloud) |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt. More... | |
double | F_v (const yarp::sig::Vector &x, const std::deque< yarp::sig::Vector > &points) |
Auxiliary function for computing the gradient of cost function of the nonlinear problem. More... | |
double | f_v (const yarp::sig::Vector &x, const yarp::sig::Matrix &R, const yarp::sig::Vector &point_cloud) |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt. More... | |
bool | eval_grad_f (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f) |
Gradient of the cost function of the nonlinear problem. More... | |
bool | eval_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g) |
Constraints of the nonlinear problem. More... | |
bool | eval_jac_g (Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values) |
Jacobian of the constraints of the nonlinear problem. More... | |
void | computeX0 (yarp::sig::Vector &x0, std::deque< yarp::sig::Vector > &point_cloud) |
Compute a good starting point for the nonlinear problem. More... | |
void | computeInitialOrientation (yarp::sig::Vector &x0, std::deque< yarp::sig::Vector > &point_cloud) |
Compute initial superquadric orientation from the point cloud. More... | |
yarp::sig::Matrix | computeBoundingBox (std::deque< yarp::sig::Vector > &points, const yarp::sig::Vector &x0) |
Compute bounding box from the point cloud. More... | |
void | finalize_solution (Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq) |
Finalize the solution. More... | |
Protected Attributes | |
bool | bounds_automatic |
Boolean variable for enabling automatic bounds computation. | |
yarp::sig::Vector | x_v |
Auxiliar vector for gradient computation. | |
yarp::sig::Vector | x0 |
Starting point for the optimization problem. | |
yarp::sig::Matrix | bounds |
Bounds variable of the optimization problem. | |
double | aux_objvalue |
std::string | obj_class |
Object class: cylinder, sphere and box. | |
yarp::os::ResourceFinder * | rf |
This class solves the optimization problem with the Ipopt software package and returns the estiamted superquadric, better fitting a given point cloud.
Definition at line 36 of file superquadric.h.
|
protected |
Compute bounding box from the point cloud.
points | is the point cloud |
x0 | is the initial value for the superquadric to be estimated |
Definition at line 344 of file superquadric.cpp.
|
protected |
Compute initial superquadric orientation from the point cloud.
x0 | is the initial value for the superquadric to be estimated |
point_cloud | is the object point cloud |
Definition at line 297 of file superquadric.cpp.
|
protected |
Compute a good starting point for the nonlinear problem.
x0 | is the initial value for the superquadric to be estimated |
point_cloud | is the object point cloud |
Definition at line 266 of file superquadric.cpp.
void SuperQuadric_NLP::configure | ( | yarp::os::ResourceFinder * | rf, |
bool | bounds_aut, | ||
const std::string & | object_class | ||
) |
Configure function.
rf | is the resource finder |
bounds_aut | is to set or not the automatic computation of the variable bound |
object_class | is the object class according to its shape |
Definition at line 255 of file superquadric.cpp.
|
protected |
Cost function of the nonlinear problem to be solved with ipopt.
n | is the dimension of the variable |
x | is the variable |
new_x | takes into account is the variable has been updated or not |
obj_value | is the value of the cost function true |
Definition at line 138 of file superquadric.cpp.
|
protected |
Constraints of the nonlinear problem.
n | is the dimension of the variable |
x | is the variable |
m | is the number of constraints |
new_x | takes into account is the variable has been updated or not |
g | is the values of the constraints |
Definition at line 240 of file superquadric.cpp.
|
protected |
Gradient of the cost function of the nonlinear problem.
x | is the variable |
n | is the dimension of the variable |
new_x | takes into account is the variable has been updated or not |
grad_f | is the gradient of the cost function |
Definition at line 213 of file superquadric.cpp.
|
protected |
Jacobian of the constraints of the nonlinear problem.
n | is the dimension of the variable |
x | is the variable |
m | is the number of constraints |
new_x | takes into account is the variable has been updated or not |
iRow | contains the jacobian raws |
iCol | contains the jacobian columns |
values | contains the jacobian values |
Definition at line 247 of file superquadric.cpp.
|
protected |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt.
x | is the variable |
points_on | is object point cloud |
new_x | takes into account is the variable has been updated or not the cost function value |
Definition at line 147 of file superquadric.cpp.
|
protected |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt.
x | is the variable |
point | is one point of the point cloud |
Definition at line 170 of file superquadric.cpp.
|
protected |
Auxiliary function for computing the gradient of cost function of the nonlinear problem.
x | is the variable |
points_on | is one point of object point cloud |
Definition at line 181 of file superquadric.cpp.
|
protected |
Auxiliary function for computing cost function of the nonlinear problem to be solved with ipopt.
x | is the variable |
point | is one point of the point cloud |
Definition at line 202 of file superquadric.cpp.
|
protected |
Finalize the solution.
n | is the dimension of the variable |
x | is the variable |
m | is the number of constraints |
init_z | is an ipopt variable |
z_L | is an ipopt variable |
z_U | is an ipopt variable |
status | says if the problem has been solved or not |
obj_value | is the final cost function values |
Definition at line 450 of file superquadric.cpp.
|
protected |
Get variable bounds for the nonlinear problem to be solved with ipopt.
n | is the dimension of the variable |
m | is the number of constraints |
x_l | is the lower bound of the variable |
x_u | is the upper bound of the variable |
g_l | is the lower bound of the constraints |
g_u | is the upper bound of the constraints |
Definition at line 111 of file superquadric.cpp.
|
protected |
Get info for the nonlinear problem to be solved with ipopt.
n | is the dimension of the variable |
m | is the number of constraints |
nnz_jac_g | is the dimensions of the jacobian |
nnz_h_lag | is an ipopt variable |
index_styl | is an ipopt variable |
Definition at line 70 of file superquadric.cpp.
Vector SuperQuadric_NLP::get_result | ( | ) | const |
Extract the solution.
Definition at line 463 of file superquadric.cpp.
|
protected |
Get the starting point for the nonlinear problem to be solved with ipopt.
n | is the dimension of the variable |
init_x | is the starting point of the optimization problem |
x | is the variable |
init_z | is an ipopt variable |
z_L | is an ipopt variable |
z_U | is an ipopt variable |
m | is the number of constraints |
init_lambda | is an ipopt variable |
lambda | is an ipopt variable |
Definition at line 126 of file superquadric.cpp.
bool SuperQuadric_NLP::readMatrix | ( | const std::string & | tag, |
yarp::sig::Matrix & | matrix, | ||
const int & | dimension, | ||
yarp::os::ResourceFinder * | rf | ||
) |
Function for reading matrices from config files.
tag | is the name of the quantity to be read from text |
matrix | is the matrix to be filled |
dimensions | is the matrix dimensions |
rf | is the resource finder |
Definition at line 388 of file superquadric.cpp.
void SuperQuadric_NLP::setPoints | ( | const std::deque< yarp::sig::Vector > & | point_cloud, |
const int & | optimizer_points | ||
) |
Set point to be used for superquadric estimation.
point_cloud | is the object point cloud |
optimizer_points | is the maximum number of points to be used for the optimization problem |
Definition at line 44 of file superquadric.cpp.