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
00037 #ifndef DEPTH_SENSOR_POSE
00038 #define DEPTH_SENSOR_POSE
00039
00040 #include <ros/console.h>
00041 #include <ros/ros.h>
00042
00043 #include <sensor_msgs/Image.h>
00044 #include <sensor_msgs/LaserScan.h>
00045 #include <sensor_msgs/image_encodings.h>
00046 #include <image_geometry/pinhole_camera_model.h>
00047
00048 #include <sstream>
00049 #include <limits.h>
00050 #include <math.h>
00051 #include <vector>
00052 #include <cmath>
00053 #include <string>
00054 #include <boost/lexical_cast.hpp>
00055 #include <iostream>
00056 #include <fstream>
00057
00058 #include <pcl/point_types.h>
00059 #include <pcl/sample_consensus/ransac.h>
00060 #include <pcl/sample_consensus/sac_model_plane.h>
00061 #include <pcl/sample_consensus/method_types.h>
00062 #include <pcl/sample_consensus/model_types.h>
00063 #include <pcl/segmentation/sac_segmentation.h>
00064
00065 #include <Eigen/Core>
00066
00067 #define DEBUG 1
00068
00069
00070
00071
00072
00073 namespace depth_sensor_pose
00074 {
00075 class DepthSensorPose
00076 {
00077
00078 public:
00079 DepthSensorPose();
00080 ~DepthSensorPose();
00081
00094 void estimateParams(const sensor_msgs::ImageConstPtr& depth_msg,
00095 const sensor_msgs::CameraInfoConstPtr& info_msg);
00106 void setRangeLimits(const float rmin, const float rmax);
00107
00113 void setSensorMountHeightMin (const float height);
00119 void setSensorMountHeightMax (const float height);
00124 void setSensorTiltAngleMin (const float angle);
00129 void setSensorTiltAngleMax (const float angle);
00134 void setPublishDepthEnable (const bool enable) { publish_depth_enable_ = enable; }
00139 bool getPublishDepthEnable () const { return publish_depth_enable_; }
00144 void setCamModelUpdate (const bool u) { cam_model_update_ = u; }
00149 void setUsedDepthHeight(const unsigned int height);
00154 void setDepthImgStepRow(const int step);
00159 void setDepthImgStepCol(const int step);
00164 void setReconfParamsUpdated (bool updated) {reconf_serv_params_updated_ = updated; }
00165
00166
00167
00168
00169 void setRansacMaxIter (const unsigned int u) { ransacMaxIter_ = u; }
00170
00171 void setRansacDistanceThresh (const float u) { ransacDistanceThresh_ = u; }
00172
00173 void setGroundMaxPoints (const unsigned int u) { max_ground_points_ = u; }
00174
00175
00179 float getSensorTiltAngle () const { return tilt_angle_est_; }
00183 float getSensorMountHeight () const { return mount_height_est_; }
00184
00185
00186 private:
00196 double lengthOfVector( const cv::Point3d& ray) const;
00197
00209 double angleBetweenRays( const cv::Point3d& ray1, const cv::Point3d& ray2) const;
00218 void fieldOfView( double & min, double & max, double x1, double y1,
00219 double xc, double yc, double x2, double y2 );
00224 void calcDeltaAngleForImgRows( double vertical_fov);
00234 void calcGroundDistancesForImgRows( double mount_height, double tilt_angle,
00235 std::vector<unsigned int>& distances);
00239 void getGroundPoints(const sensor_msgs::ImageConstPtr& depth_msg,
00240 pcl::PointCloud<pcl::PointXYZ>::Ptr& points);
00244 void sensorPoseCalibration(const sensor_msgs::ImageConstPtr& depth_msg, double & tilt, double & height);
00245
00246
00247 public:
00248
00249 sensor_msgs::Image new_depth_msg_;
00250
00251 private:
00252
00253
00254
00255 float range_min_;
00256 float range_max_;
00257
00258 float mount_height_min_;
00259 float mount_height_max_;
00260 float tilt_angle_min_;
00261 float tilt_angle_max_;
00262
00263 bool publish_depth_enable_;
00264 bool cam_model_update_;
00265 unsigned int used_depth_height_;
00266 unsigned int depth_image_step_row_;
00267 unsigned int depth_image_step_col_;
00268
00269 unsigned int max_ground_points_;
00270
00271 unsigned int ransacMaxIter_;
00272 float ransacDistanceThresh_;
00273 float groundDistTolerance_;
00274
00275
00276
00277
00279 image_geometry::PinholeCameraModel camera_model_;
00280
00281 std::vector<double> delta_row_;
00282
00283 float mount_height_est_;
00284 float tilt_angle_est_;
00285
00286 bool reconf_serv_params_updated_;
00287
00288 std::vector<unsigned int>dist_to_ground_max_;
00289 std::vector<unsigned int>dist_to_ground_min_;
00290
00291 };
00292
00293 template <typename T>
00294 std::string NumberToString ( T Number )
00295 {
00296 std::ostringstream ss;
00297 ss << Number;
00298 return ss.str();
00299 }
00300
00301 }
00302
00303 #endif