MultiRBTracker.h
Go to the documentation of this file.
00001 /*
00002  * MultiRBTracker.h
00003  *
00004  *      Author: roberto
00005  *
00006  * This is a modified implementation of the method for online estimation of kinematic structures described in our paper
00007  * "Online Interactive Perception of Articulated Objects with Multi-Level Recursive Estimation Based on Task-Specific Priors"
00008  * (Martín-Martín and Brock, 2014).
00009  * This implementation can be used to reproduce the results of the paper and to be applied to new research.
00010  * The implementation allows also to be extended to perceive different information/models or to use additional sources of information.
00011  * A detail explanation of the method and the system can be found in our paper.
00012  *
00013  * If you are using this implementation in your research, please consider citing our work:
00014  *
00015 @inproceedings{martinmartin_ip_iros_2014,
00016 Title = {Online Interactive Perception of Articulated Objects with Multi-Level Recursive Estimation Based on Task-Specific Priors},
00017 Author = {Roberto {Mart\'in-Mart\'in} and Oliver Brock},
00018 Booktitle = {Proceedings of the IEEE/RSJ International Conference on Intelligent Robots and Systems},
00019 Pages = {2494-2501},
00020 Year = {2014},
00021 Location = {Chicago, Illinois, USA},
00022 Note = {http://www.robotics.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martinmartin_ip_iros_2014.pdf},
00023 Url = {http://www.robotics.tu-berlin.de/fileadmin/fg170/Publikationen_pdf/martinmartin_ip_iros_2014.pdf},
00024 Projectname = {Interactive Perception}
00025 }
00026  * If you have questions or suggestions, contact us:
00027  * roberto.martinmartin@tu-berlin.de
00028  *
00029  * Enjoy!
00030  */
00031 
00032 #ifndef MULTI_RB_TRACKER_H_
00033 #define MULTI_RB_TRACKER_H_
00034 
00035 #include <rb_tracker/RBTrackerDynReconfConfig.h>
00036 
00037 #include "rb_tracker/RBFilter.h"
00038 
00039 #include "omip_common/FeaturesDataBase.h"
00040 #include "omip_msgs/RigidBodyTwistWithCovMsg.h"
00041 
00042 #include "omip_common/OMIPTypeDefs.h"
00043 
00044 #include "omip_common/RecursiveEstimatorFilterInterface.h"
00045 
00046 #include "omip_msgs/ShapeTrackerStates.h"
00047 
00048 #include <tf/transform_listener.h>
00049 
00050 #include "rb_tracker/StaticEnvironmentFilter.h"
00051 
00052 #include <boost/thread/thread.hpp>
00053 #include <boost/thread/mutex.hpp>
00054 
00055 #include <iostream>
00056 #include <fstream>
00057 
00058 #define INTEGRATOR_VISION_CHANNEL 0
00059 #define INTEGRATOR_PROPRIOCEPTION_CHANNEL 1
00060 
00061 namespace omip
00062 {
00063 
00072 class MultiRBTracker : public RecursiveEstimatorFilterInterface<rbt_state_t, rbt_measurement_t>
00073 {
00074 public:
00075 
00091     MultiRBTracker(int max_num_rb,
00092                    double loop_period_ns,
00093                    int ransac_iterations,
00094                    double estimation_error_threshold,
00095                    double static_motion_threshold,
00096                    double new_rbm_error_threshold,
00097                    double max_error_to_reassign_feats,
00098                    int supporting_features_threshold,
00099                    int min_num_feats_for_new_rb,
00100                    int min_num_frames_for_new_rb,
00101                    int initial_cam_motion_constraint,
00102                    static_environment_tracker_t static_environment_tracker_type);
00103 
00104     virtual void Init();
00105 
00109     virtual ~MultiRBTracker();
00110 
00116     virtual void setMeasurement(rbt_measurement_t acquired_measurement, const double& measurement_timestamp);
00117 
00123     virtual void predictState(double time_interval_ns);
00124 
00129     virtual void predictMeasurement();
00130 
00131 
00137     virtual rbt_measurement_t getPredictedMeasurement() const;
00138 
00148     virtual void correctState();
00149 
00155     virtual rbt_state_t getState() const;
00156 
00160     void ReflectState();
00161 
00167     virtual void setDynamicReconfigureValues(rb_tracker::RBTrackerDynReconfConfig &config);
00168 
00174     virtual void processMeasurementFromShapeTracker(const omip_msgs::ShapeTrackerStates &meas_from_st);
00175 
00176 
00181     std::vector<Eigen::Matrix4d> getPoses() const;
00182 
00187     std::vector<geometry_msgs::PoseWithCovariancePtr> getPosesWithCovariance() const;
00188 
00193     std::vector<geometry_msgs::TwistWithCovariancePtr> getPosesECWithCovariance() const;
00194 
00199     std::vector<geometry_msgs::TwistWithCovariancePtr> getVelocitiesWithCovariance() const;
00200 
00206     void addFeatureLocation(Feature::Id f_id, Feature::Location f_loc);
00207 
00213     RB_id_t getRBId(int n) const;
00214 
00220     int getNumberSupportingFeatures(int n) const;
00221 
00227     FeatureCloudPCL getLabelledSupportingFeatures();
00228 
00229     FeatureCloudPCL getFreeFeatures();
00230 
00231     FeatureCloudPCL getPredictedFeatures();
00232 
00233     FeatureCloudPCL getAtBirthFeatures();
00234 
00235 
00242     std::vector<Eigen::Vector3d> getCentroids() const;
00243 
00251     FeaturesDataBase::Ptr getFeaturesDatabase();
00252 
00258     virtual void addPredictedState(const rbt_state_t& predicted_state, const double& predicted_state_timestamp_ns);
00259 
00265     FeatureCloudPCL::Ptr CollectLocationPredictions();
00266 
00272     std::vector<Feature::Id> estimateBestPredictionsAndSupportingFeatures();
00273 
00280     std::vector<Feature::Id> EstimateFreeFeatures(const std::vector<Feature::Id>& supporting_features);
00281 
00288     std::vector<Feature::Id> ReassignFreeFeatures(const std::vector<Feature::Id>& free_feat_ids);
00289 
00306     void TryToCreateNewFilter(const std::vector<Feature::Id>& really_free_feat_ids);
00307 
00314     void CreateNewFilter(const std::vector<Eigen::Matrix4d> &initial_trajectory,
00315                          const Eigen::Twistd& initial_velocity,
00316                          const std::vector<Feature::Id> &initial_supporting_feats);
00317 
00318 
00319     virtual void setPriorCovariancePose(double v)
00320     {
00321         this->_prior_cov_pose = v;
00322     }
00323 
00324     virtual void setPriorCovarianceVelocity(double v)
00325     {
00326         this->_prior_cov_vel = v;
00327     }
00328 
00329     virtual void setMinCovarianceMeasurementX(double v)
00330     {
00331         this->_min_cov_meas_x = v;
00332     }
00333 
00334     virtual void setMinCovarianceMeasurementY(double v)
00335     {
00336         this->_min_cov_meas_y = v;
00337     }
00338 
00339     virtual void setMinCovarianceMeasurementZ(double v)
00340     {
00341         this->_min_cov_meas_z = v;
00342     }
00343 
00344     virtual void setMeasurementDepthFactor(double v)
00345     {
00346         this->_meas_depth_factor = v;
00347     }
00348 
00349     virtual void setCovarianceSystemAccelerationTx(double v)
00350     {
00351         this->_cov_sys_acc_tx = v;
00352     }
00353 
00354     virtual void setCovarianceSystemAccelerationTy(double v)
00355     {
00356         this->_cov_sys_acc_ty = v;
00357     }
00358 
00359     virtual void setCovarianceSystemAccelerationTz(double v)
00360     {
00361         this->_cov_sys_acc_tz = v;
00362     }
00363 
00364     virtual void setCovarianceSystemAccelerationRx(double v)
00365     {
00366         this->_cov_sys_acc_rx = v;
00367     }
00368 
00369     virtual void setCovarianceSystemAccelerationRy(double v)
00370     {
00371         this->_cov_sys_acc_ry = v;
00372     }
00373 
00374     virtual void setCovarianceSystemAccelerationRz(double v)
00375     {
00376         this->_cov_sys_acc_rz = v;
00377     }
00378 
00379     virtual void setNumberOfTrackedFeatures(int v)
00380     {
00381         this->_num_tracked_feats = v;
00382     }
00383 
00384     virtual void setMinNumPointsInSegment(int v)
00385     {
00386         this->_min_num_points_in_segment = v;
00387     }
00388 
00389     virtual void setMinProbabilisticValue(double v)
00390     {
00391         this->_min_probabilistic_value = v;
00392     }
00393 
00394     virtual void setMaxFitnessScore(double v)
00395     {
00396         this->_max_fitness_score = v;
00397     }
00398 
00399     virtual void setMinAmountTranslationForNewRB(double v)
00400     {
00401         this->_min_amount_translation_for_new_rb = v;
00402     }
00403 
00404     virtual void setMinAmountRotationForNewRB(double v)
00405     {
00406         this->_min_amount_rotation_for_new_rb = v;
00407     }
00408 
00409     virtual void setMinNumberOfSupportingFeaturesToCorrectPredictedState(int v)
00410     {
00411         this->_min_num_supporting_feats_to_correct = v;
00412     }
00413 
00414 protected:    
00415 
00416     int _max_num_rb;
00417     double _prior_cov_pose;
00418     double _prior_cov_vel;
00419     double _min_cov_meas_x;
00420     double _min_cov_meas_y;
00421     double _min_cov_meas_z;
00422     double _meas_depth_factor;
00423     double _cov_sys_acc_tx;
00424     double _cov_sys_acc_ty;
00425     double _cov_sys_acc_tz;
00426     double _cov_sys_acc_ry;
00427     double _cov_sys_acc_rx;
00428     double _cov_sys_acc_rz;
00429 
00430     int _min_num_points_in_segment;
00431     double _min_probabilistic_value;
00432     double _max_fitness_score;
00433 
00434     double _min_amount_translation_for_new_rb;
00435     double _min_amount_rotation_for_new_rb;
00436 
00437 
00438     std::vector<RBFilter::Ptr> _kalman_filters;
00439 
00440     FeaturesDataBase::Ptr _features_db;
00441 
00442     // Maximum number of iterations of RANSAC to find a good hypothesis for the free features
00443     int _ransac_iterations;
00444 
00445     // Maximum error allowed between predicted and measured feature position to consider it to STILL
00446     // support a RBM
00447     double _estimation_error_threshold;
00448 
00449     // Minimum motion to consider that a feature moves
00450     double _static_motion_threshold;
00451 
00452     // Maximum error allowed for the inliers of a new RBM hypothesis in RANSAC
00453     double _new_rbm_error_threshold;
00454 
00455     // Maximum error allowed between the predicted and the measured position of a feature to assign it to a RBM
00456     double _max_error_to_reassign_feats;
00457 
00458     // Minimum number of features that have to support a RBM to not be deleted
00459     int _supporting_features_threshold;
00460 
00461     // Minimum number of free features to trigger the generation of a new RBM
00462     int _min_num_feats_for_new_rb;
00463 
00464     // Minimum number of frames that a features has to be present to be used to create new RBM
00465     int _min_num_frames_for_new_rb;
00466 
00467     int _num_tracked_feats;
00468 
00469     int _min_num_supporting_feats_to_correct;
00470 
00471     StaticEnvironmentFilter::Ptr _static_environment_filter;
00472 
00473     rbt_state_t _last_predicted_state_kh;
00474 
00475     double _max_distance_ee;
00476     double _max_distance_irb;
00477 
00478     std::vector<Feature::Id> _free_feat_ids, _really_free_feat_ids;
00479 
00480     std::ofstream _really_free_feats_file;
00481 
00482     boost::mutex _measurement_timestamp_ns_mutex;
00483     boost::mutex::scoped_lock _measurement_timestamp_ns_lock;
00484 
00485 };
00486 }
00487 
00488 #endif /* MULTI_RB_TRACKER_H_ */


rb_tracker
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:26:42