18 #ifndef __COMPUTATION_H__ 19 #define __COMPUTATION_H__ 21 #include <yarp/dev/all.h> 23 #include <opencv2/opencv.hpp> 25 #include <iCub/ctrl/filters.h> 26 #include <iCub/ctrl/adaptWinPolyEstimator.h> 28 #include "superquadric.h" 39 static std::vector<int> filter(
const cv::Mat &data,
const double radius,
const int maxResults, std::deque<yarp::sig::Vector> &points);
114 yarp::sig::Vector elem_x;
122 yarp::os::ResourceFinder *rf;
124 yarp::os::Mutex mutex;
125 yarp::os::Mutex &mutex_shared;
148 yarp::sig::Vector &
x;
157 SuperqComputation(yarp::os::Mutex &mutex_shared,
int _rate,
bool _filter_points,
bool _filter_superq,
bool _fixed_window, std::deque<yarp::sig::Vector> &_points,
158 std::string _tag_file,
double _threshold_median,
const yarp::os::Property &filters_points_par, yarp::sig::Vector &_x, yarp::sig::Vector &_x_filtered,
159 const yarp::os::Property &filters_superq_par,
const yarp::os::Property &optimizer_par,
const std::string &_homeContextPath,
bool _save_points, yarp::os::ResourceFinder *rf);
180 void setIpoptPar(
const yarp::os::Property &newOptions,
bool first_time);
205 void setPar(
const std::string &par_name,
const std::string &value);
224 void savePoints(
const std::string &namefile,
const yarp::sig::Vector &colors);
265 yarp::sig::Vector
getSolution(
bool filtered_or_not);
271 void sendPoints(
const std::deque<yarp::sig::Vector> &p);
yarp::os::Property getPointsFilterPar()
Get options used for filtering the point cloud.
bool bounds_automatic
Boolean varibal for enabling automatic computation of variables bounds.
void getPoints3D()
Get the point cloud for computing the superquadric.
double max_cpu_time
Max cpu time allowed for solving the optimization problem.
bool configFilterSuperq()
Configure superquadric filter.
bool filter_points
Boolean variable for enabling point cloud filtering.
bool go_on
Boolean variable for going to the next step of the state machine.
iCub::ctrl::MedianFilter * mFilter
Median filter for discarding wrong superquadrics.
double radius
Radius for spatial density filter.
std::string tag_file
Tag name of files for saving 3D points.
bool filter_superq
Boolean variable for enabling superquadric filtering.
double min_norm_vel
Minimum norm of velocity for considering the object moving.
double t_superq
Time required for computing superquadric.
bool readPointCloud()
Read the object point cloud from txt for offline tests.
std::deque< cv::Point > blob_points
Object 2D blob.
double tol
Tolerance of the optimization problem.
yarp::os::Property filter_points_par
Parameters of point cloud filter.
std::string mu_strategy
Mu strategy of the Ipopt algorithm.
void setSuperqFilterPar(const yarp::os::Property &newOptions, bool first_time)
Set options for filtering the superquadric.
yarp::os::Property filter_superq_par
Parameters of superquadric filter.
bool config3Dpoints()
Configure point cloud filter.
virtual void threadRelease()
Release function of Thread class.
yarp::sig::Vector & x_filtered
Filtered object superquadric.
double getTime()
Return the computation time for estimating the superquadric.
This class filters the point cloud according to its density.
void filterSuperq()
Filter the superquadri with the median filter.
void filter()
Filter the received point cloud.
bool save_points
Boolean variable for enabling point cloud saving.
void setPar(const std::string &par_name, const std::string &value)
Set a parameter equal to a value.
std::deque< yarp::sig::Vector > & points
Object point cloud.
int max_median_order
max median order width
int max_iter
Maximum iteration allowed of Ipopt algorithm.
int std_median_order
median order width
void setPointsFilterPar(const yarp::os::Property &newOptions, bool first_time)
Set options for filtering the point cloud.
yarp::sig::Vector getSolution(bool filtered_or_not)
Return the computed superquadric.
virtual void run()
Run function of Thread class.
int nnThreshold
Density threshold for spatial density filter.
void savePoints(const std::string &namefile, const yarp::sig::Vector &colors)
Save point cloud used for reconstructing the superquadric.
std::string ob_class
Objec class: cylinder, sphere of box.
This class provides a thread for computing in real time the superquadric, filtering the point cloud a...
std::string homeContextPath
Path where code context is located.
int adaptWindComputation()
Compute window size according to the object velocity.
int min_median_order
Minimum median filder order allowed.
bool fixed_window
Boolean variable for enabling the use of a fixed window during the median filter. ...
iCub::ctrl::AWPolyEstimator * PolyEst
Time Polyestimator for estimating object velocity.
double threshold_median
Threshold for velocity estimation for median order.
int optimizer_points
Number of 3D points used for optimization.
std::string nlp_scaling_method
NLP scaling method of the Ipopt algorithm.
yarp::os::Property getSuperqFilterPar()
Get options used for filtering the superquadric.
std::vector< cv::Point > contour
OpenCV variable for blob extraction.
void setIpoptPar(const yarp::os::Property &newOptions, bool first_time)
Set options for the optimization problem solved by Ipopt.
yarp::os::ConstString pointCloudFileName
Pointcloud name file in case the module runs offline.
yarp::os::Property ipopt_par
Parameters of the Ipopt optimization problem.
bool computeSuperq()
Compute the superquadric modeling the object.
void resetMedianFilter()
Reset median filter.
void sendPoints(const std::deque< yarp::sig::Vector > &p)
Get the point cloud for computing the superquadric.
int new_median_order
New median filder order estimated.
yarp::os::Property getIpoptPar()
Get options used for solving the optimization problem with Ipopt.
int acceptable_iter
Acceptable iter of Ipopt algorithm.
yarp::os::BufferedPort< yarp::os::Bottle > pointPort
Port for receiving point cloud.
yarp::sig::Vector & x
Object superquadric.
virtual bool threadInit()
Init function of Thread class.
int median_order
Median filder order.