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
00038 #ifndef CLIFF_DETECTOR
00039 #define CLIFF_DETECTOR
00040
00041 #include <ros/console.h>
00042 #include <sensor_msgs/Image.h>
00043 #include <sensor_msgs/image_encodings.h>
00044 #include <image_geometry/pinhole_camera_model.h>
00045 #include <depth_nav_msgs/Point32List.h>
00046 #include <geometry_msgs/Point32.h>
00047
00048 #include <sstream>
00049 #include <limits.h>
00050 #include <math.h>
00051 #include <cmath>
00052 #include <string>
00053 #include <boost/lexical_cast.hpp>
00054 #include <iostream>
00055 #include <fstream>
00056 #include <utility>
00057 #include <cstdlib>
00058
00059 #include <vector>
00060
00061 namespace cliff_detector
00062 {
00066 class CliffDetector
00067 {
00068
00069 public:
00070 CliffDetector();
00071 ~CliffDetector() { }
00082 void detectCliff( const sensor_msgs::ImageConstPtr& depth_msg,
00083 const sensor_msgs::CameraInfoConstPtr& info_msg);
00090 void setRangeLimits(const float rmin, const float rmax);
00096 void setSensorMountHeight (const float height);
00102 float getSensorMountHeight () { return sensor_mount_height_; }
00107 void setSensorTiltAngle (const float angle);
00113 float getSensorTiltAngle () { return sensor_tilt_angle_; }
00118 void setPublishDepthEnable (const bool enable) { publish_depth_enable_ = enable; }
00123 bool getPublishDepthEnable () const { return publish_depth_enable_; }
00140 void setCamModelUpdate (const bool u) { cam_model_update_ = u; }
00145 void setUsedDepthHeight(const unsigned int height);
00151 void setBlockSize(const int size);
00157 void setBlockPointsThresh(const int thresh);
00162 void setDepthImgStepRow(const int step);
00167 void setDepthImgStepCol(const int step);
00172 void setGroundMargin (const float margin);
00177 void setParametersConfigurated (const bool u) { depth_sensor_params_update = u; }
00178
00179
00180 private:
00189 double lengthOfVector(const cv::Point3d& vec) const;
00201 double angleBetweenRays(const cv::Point3d& ray1, const cv::Point3d& ray2) const;
00209 void findCliffInDepthImage(const sensor_msgs::ImageConstPtr& depth_msg);
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 vertical_fov);
00240 void calcTiltCompensationFactorsForImgRows(double vertical_fov);
00241
00242
00243 private:
00244
00245
00246
00247 std::string outputFrameId_;
00248 float range_min_;
00249 float range_max_;
00250 float sensor_mount_height_;
00251 float sensor_tilt_angle_;
00252 bool publish_depth_enable_;
00253 bool cam_model_update_;
00254 unsigned int used_depth_height_;
00255 unsigned int block_size_;
00256 unsigned int block_points_thresh_;
00257 unsigned int depth_image_step_row_;
00258 unsigned int depth_image_step_col_;
00259 float ground_margin_;
00260
00261
00262 bool depth_sensor_params_update;
00264 image_geometry::PinholeCameraModel camera_model_;
00266 std::vector<unsigned int> dist_to_ground_;
00268 std::vector<double> tilt_compensation_factor_;
00269
00270 std::vector<double> delta_row_;
00271
00272
00273 public:
00274
00275 sensor_msgs::Image new_depth_msg_;
00276 sensor_msgs::ImageConstPtr depth_msg_to_pub_;
00277
00279 depth_nav_msgs::Point32List stairs_points_msg_;
00280
00281 };
00282 };
00283
00284 #endif