cliff_detector.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ros/console.h>
4 #include <sensor_msgs/Image.h>
7 #include <depth_nav_msgs/Point32List.h>
8 #include <geometry_msgs/Point32.h>
9 
10 #include <sstream>
11 #include <limits.h>
12 #include <math.h>
13 #include <cmath>
14 #include <string>
15 #include <iostream>
16 #include <fstream>
17 #include <utility>
18 #include <cstdlib>
19 #include <vector>
20 
21 namespace cliff_detector {
26  public:
27  CliffDetector();
38  void detectCliff(const sensor_msgs::ImageConstPtr& depth_msg,
39  const sensor_msgs::CameraInfoConstPtr& info_msg);
46  void setRangeLimits(const float rmin, const float rmax);
52  void setSensorMountHeight (const float height);
63  void setSensorTiltAngle(const float angle);
74  void setPublishDepthEnable(const bool enable) { publish_depth_enable_ = enable; }
92  void setCamModelUpdate(const bool u) { cam_model_update_ = u; }
97  void setUsedDepthHeight(const unsigned int height);
103  void setBlockSize(const int size);
109  void setBlockPointsThresh(const int thresh);
114  void setDepthImgStepRow(const int step);
119  void setDepthImgStepCol(const int step);
124  void setGroundMargin (const float margin);
130 
131  protected:
140  double lengthOfVector(const cv::Point3d& vec) const;
152  double angleBetweenRays(const cv::Point3d& ray1, const cv::Point3d& ray2) const;
160  template<typename T>
161  void findCliffInDepthImage(const sensor_msgs::ImageConstPtr& depth_msg);
170  void fieldOfView(double & min, double & max, double x1, double y1,
171  double xc, double yc, double x2, double y2);
176  void calcDeltaAngleForImgRows(double vertical_fov);
186  void calcGroundDistancesForImgRows(double vertical_fov);
191 
192  private:
193  // ROS parameters configurated with config file or dynamic_reconfigure
194  std::string outputFrameId_;
195  float range_min_;
196  float range_max_;
201  unsigned int used_depth_height_;
202  unsigned int block_size_;
203  unsigned int block_points_thresh_;
204  unsigned int depth_image_step_row_;
205  unsigned int depth_image_step_col_;
207 
212  std::vector<unsigned int> dist_to_ground_;
214  std::vector<double> tilt_compensation_factor_;
215 
216  std::vector<double> delta_row_;
217 
218  public:
219  sensor_msgs::Image new_depth_msg_;
220  sensor_msgs::ImageConstPtr depth_msg_to_pub_;
221 
223  depth_nav_msgs::Point32List stairs_points_msg_;
224 };
225 
226 } // namespace cliff_detector
void setDepthImgStepCol(const int step)
setDepthImgStepCol
void detectCliff(const sensor_msgs::ImageConstPtr &depth_msg, const sensor_msgs::CameraInfoConstPtr &info_msg)
detectCliff detects descending stairs based on the information in a depth image
bool cam_model_update_
Determines if continuously cam model update required.
float range_min_
Stores the current minimum range to use.
depth_nav_msgs::Point32List stairs_points_msg_
float getSensorTiltAngle()
getSensorTiltAngle gets sensor tilt angle in degrees
sensor_msgs::Image new_depth_msg_
bool getPublishDepthEnable() const
getPublishDepthEnable
void setParametersConfigurated(const bool u)
setParametersConfigurated
void setDepthImgStepRow(const int step)
setDepthImgStepRow
float range_max_
Stores the current maximum range to use.
float ground_margin_
Margin for ground points feature detector (m)
void setUsedDepthHeight(const unsigned int height)
setUsedDepthHeight
image_geometry::PinholeCameraModel camera_model_
Class for managing sensor_msgs/CameraInfo messages.
unsigned int used_depth_height_
Used depth height from img bottom (px)
unsigned int block_points_thresh_
Threshold value of points in block to admit stairs.
void setCamModelUpdate(const bool u)
Sets the number of image rows to use in data processing.
void findCliffInDepthImage(const sensor_msgs::ImageConstPtr &depth_msg)
unsigned int block_size_
Square block (subimage) size (px).
void setSensorMountHeight(const float height)
setSensorMountHeight sets the height of sensor mount (in meters) from ground
void setBlockSize(const int size)
setBlockSize sets size of square block (subimage) used in cliff detector
std::vector< unsigned int > dist_to_ground_
Calculated distances to ground for every row of depth image in mm.
void setPublishDepthEnable(const bool enable)
setPublishDepthEnable
float sensor_mount_height_
Height of sensor mount from ground.
bool publish_depth_enable_
Determines if depth should be republished.
void calcGroundDistancesForImgRows(double vertical_fov)
Calculates distances to ground for every row of depth image.
unsigned int depth_image_step_col_
Columns step in depth processing (px).
sensor_msgs::ImageConstPtr depth_msg_to_pub_
Store points which contain stairs.
float getSensorMountHeight()
getSensorMountHeight gets sensor mount height
float sensor_tilt_angle_
Sensor tilt angle (degrees)
void fieldOfView(double &min, double &max, double x1, double y1, double xc, double yc, double x2, double y2)
unsigned int depth_image_step_row_
Rows step in depth processing (px).
void calcDeltaAngleForImgRows(double vertical_fov)
calcDeltaAngleForImgRows
int min(int a, int b)
std::string outputFrameId_
Output frame_id for laserscan.
void calcTiltCompensationFactorsForImgRows()
calcTiltCompensationFactorsForImgRows calculate factors used in tilt compensation ...
double angleBetweenRays(const cv::Point3d &ray1, const cv::Point3d &ray2) const
void setGroundMargin(const float margin)
setGroundMargin sets the floor margin (in meters)
void setBlockPointsThresh(const int thresh)
setBlockPointsThresh sets threshold value of pixels in block to set block as stairs ...
double lengthOfVector(const cv::Point3d &vec) const
lengthOfVector calculates length of 3D vector.
std::vector< double > tilt_compensation_factor_
Calculated sensor tilt compensation factors.
The CliffDetector class detect cliff based on depth image.
void setSensorTiltAngle(const float angle)
setSensorTiltAngle sets the sensor tilt angle (in degrees)
std::vector< double > delta_row_
void setRangeLimits(const float rmin, const float rmax)
setRangeLimits sets the minimum and maximum range of depth value from RGBD sensor.


cliff_detector
Author(s): Michal Drwiega (http://www.mdrwiega.com)
autogenerated on Wed May 5 2021 02:56:04