Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef SHAPE_TRACKER_H_
00049 #define SHAPE_TRACKER_H_
00050
00051 #include <omip_common/OMIPTypeDefs.h>
00052
00053
00054 #include <opencv2/core/core.hpp>
00055 #include <camera_info_manager/camera_info_manager.h>
00056
00057 #include <omip_common/OMIPUtils.h>
00058
00059 #include <omip_msgs/ShapeTrackerState.h>
00060
00061 #include <opencv2/highgui/highgui.hpp>
00062
00063 #include <pcl/filters/extract_indices.h>
00064 #include <pcl/registration/icp.h>
00065
00066 #ifdef USE_LIBPOINTMATCHER_ICP
00067 #include "shape_tracker/point_cloud_conversions.h"
00068 typedef PointMatcher<float> PM;
00069 typedef PM::DataPoints DP;
00070 #endif
00071
00072 namespace omip
00073 {
00074
00075 void calculate_ICP_COV(pcl::PointCloud<pcl::PointXYZ>& data_pi, pcl::PointCloud<pcl::PointXYZ>& model_qi, Eigen::Matrix4f& transform, Eigen::MatrixXd& ICP_COV);
00076
00077 class ShapeTracker;
00078 typedef boost::shared_ptr<ShapeTracker> ShapeTrackerPtr;
00079
00080 class ShapeTracker
00081 {
00082 public:
00083 ShapeTracker(omip::RB_id_t rb_id);
00084
00085 ShapeTrackerPtr clone() const
00086 {
00087 return (ShapeTrackerPtr(doClone()));
00088 }
00089
00090 ShapeTracker(const ShapeTracker &sr);
00091
00092 virtual ~ShapeTracker();
00093
00094 virtual void step(const sensor_msgs::PointCloud2ConstPtr& pc_msg,
00095 const omip_msgs::RigidBodyPoseAndVelMsg& tracked_rbm,
00096 omip_msgs::ShapeTrackerState& st_state);
00097
00098 virtual void setShapeModel(const sensor_msgs::PointCloud2& model);
00099
00100 virtual void setCameraInfo(const sensor_msgs::CameraInfo& camera_info);
00101
00102 protected:
00103
00104 virtual void _RemoveInconsistentPointsFromRBModel(pcl::PointCloud<pcl::PointXYZ >::Ptr model_current_pose,
00105 pcl::PointCloud<pcl::PointXYZ >::Ptr current_pc,
00106 pcl::PointCloud<pcl::PointXYZ >::Ptr& rb_segment_depth,
00107 pcl::PointCloud<pcl::PointXYZ >::Ptr ¤t_pc_extended_segment);
00108
00109
00110 virtual void _FindInconsistentPoints(const pcl::PointCloud<pcl::PointXYZ >::Ptr& pc_source,
00111 const cv::Mat & dm_true,
00112 pcl::PointIndicesPtr& indices_to_remove,
00113 pcl::PointIndicesPtr& indices_matching_in_true,
00114 pcl::PointIndicesPtr& indices_matching_in_dm,
00115 const double min_depth_error=0.03);
00116
00118 virtual ShapeTracker* doClone() const
00119 {
00120 return (new ShapeTracker(*this));
00121 }
00122
00123 omip::RB_id_t _rb_id;
00124 pcl::PointCloud<pcl::PointXYZ >::Ptr _rb_model;
00125
00126 sensor_msgs::CameraInfo _ci;
00127
00128 pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> _icp;
00129
00130 ros::NodeHandle _nh;
00131 ros::Publisher _segment_pub;
00132
00133 bool _new_model;
00134
00135 cv::Mat _current_dm;
00136 cv::Mat _segment_of_current;
00137 cv::Mat _segment_of_current_dilated;
00138 cv::Mat _dilation_element;
00139
00140 pcl::ExtractIndices<pcl::PointXYZ> _extractor;
00141
00142 #ifdef USE_LIBPOINTMATCHER_ICP
00143 boost::shared_ptr<DP> _cloud_lpm;
00144 PM::ICP* _icp_lpm;
00145 boost::shared_ptr<DP> _rb_model_lpm;
00146 #endif
00147 };
00148 }
00149
00150 #endif
00151