laserscan_kinect.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <string>
5 #include <mutex>
6 
7 #include <ros/console.h>
8 #include <sensor_msgs/Image.h>
9 #include <sensor_msgs/LaserScan.h>
12 
13 #include <laserscan_kinect/math.h>
14 
15 namespace laserscan_kinect {
16 
18  public:
19  LaserScanKinect(): scan_msg_(new sensor_msgs::LaserScan()) { }
20  ~LaserScanKinect() = default;
21 
30  sensor_msgs::LaserScanPtr getLaserScanMsg(const sensor_msgs::ImageConstPtr& depth_msg,
31  const sensor_msgs::CameraInfoConstPtr& info_msg);
36  void setOutputFrame(const std::string& frame) { output_frame_id_ = frame; }
43  void setRangeLimits(const float rmin, const float rmax);
49  void setScanHeight(const int scan_height);
55  void setDepthImgRowStep(const int row_step);
61  void setCamModelUpdate(const bool enable) { cam_model_update_ = enable; }
65  void setSensorMountHeight(const float height);
71  void setSensorTiltAngle(const float angle);
77  void setGroundRemove(const bool enable) { ground_remove_enable_ = enable; }
83  void setGroundMargin(const float margin);
89  void setTiltCompensation(const bool enable) { tilt_compensation_enable_ = enable; }
95  void setScanConfigurated(const bool configured) { is_scan_msg_configured_ = configured; }
100  void setPublishDbgImgEnable(const bool enable) { publish_dbg_image_ = enable; }
101 
102  void setThreadsNum(unsigned threads_num);
103 
105 
106  sensor_msgs::ImageConstPtr getDbgImage() const;
107 
108  protected:
109 
115  void calcGroundDistancesForImgRows(double vertical_fov);
121  void calcTiltCompensationFactorsForImgRows(double vertical_fov);
127  void calcScanMsgIndexForImgCols(const sensor_msgs::ImageConstPtr& depth_msg);
131  template <typename T>
132  float getSmallestValueInColumn(const sensor_msgs::ImageConstPtr &depth_msg, int col);
136  template <typename T>
137  void convertDepthToPolarCoords(const sensor_msgs::ImageConstPtr& depth_msg);
138 
139  sensor_msgs::ImagePtr prepareDbgImage(const sensor_msgs::ImageConstPtr& depth_msg,
140  const std::list<std::pair<int, int>>& min_dist_points_indices);
141 
142 private:
143  // ROS parameters configurated with configuration file or dynamic_reconfigure
144  std::string output_frame_id_;
145  float range_min_{0};
146  float range_max_{0};
147  unsigned scan_height_{0};
148  unsigned depth_img_row_step_{0};
149  bool cam_model_update_{false};
152  bool ground_remove_enable_{false};
153  float ground_margin_{0};
155  bool publish_dbg_image_{false};
156  unsigned threads_num_{1};
157 
159  sensor_msgs::LaserScanPtr scan_msg_;
160 
163 
166 
168  std::vector<unsigned> scan_msg_index_;
169 
171  std::vector<float> dist_to_ground_corrected;
172 
174  std::vector<float> tilt_compensation_factor_;
175 
178 
179  sensor_msgs::ImagePtr dbg_image_;
180  std::list<std::pair<int, int>> min_dist_points_indices_;
181 
183  std::mutex scan_msg_mutex_;
184 };
185 
186 } // namespace laserscan_kinect
void setPublishDbgImgEnable(const bool enable)
setPublishDbgImgEnable
void setRangeLimits(const float rmin, const float rmax)
setRangeLimits sets depth sensor min and max ranges
void calcScanMsgIndexForImgCols(const sensor_msgs::ImageConstPtr &depth_msg)
calcScanMsgIndexForImgCols
void setOutputFrame(const std::string &frame)
setOutputFrame sets the frame to output laser scan
void setDepthImgRowStep(const int row_step)
setDepthImgRowStep
void setScanConfigurated(const bool configured)
setScanConfigurated sets the configuration status
void setTiltCompensation(const bool enable)
setTiltCompensation enables or disables the feature which compensates sensor tilt ...
float getSmallestValueInColumn(const sensor_msgs::ImageConstPtr &depth_msg, int col)
getSmallestValueInColumn finds smallest values in depth image columns
unsigned scan_height_
Number of pixel rows used to scan computing.
bool publish_dbg_image_
Determines if debug image should be published.
sensor_msgs::ImageConstPtr getDbgImage() const
bool tilt_compensation_enable_
Determines if tilt compensation feature is on.
void setSensorTiltAngle(const float angle)
setSensorTiltAngle sets the sensor tilt angle (in degrees)
float sensor_tilt_angle_
Angle of sensor tilt.
float ground_margin_
Margin for floor remove feature (in meters)
bool is_scan_msg_configured_
Determines if laser scan message is configurated.
unsigned depth_img_row_step_
Row step in depth map processing.
std::list< std::pair< int, int > > min_dist_points_indices_
void setThreadsNum(unsigned threads_num)
void setSensorMountHeight(const float height)
setSensorMountHeight sets the height of sensor mount (in meters)
unsigned threads_num_
Determines threads number used in image processing.
image_geometry::PinholeCameraModel cam_model_
Class for managing CameraInfo messages.
float range_min_
Stores the current minimum range to use.
void setGroundRemove(const bool enable)
setGroundRemove enables or disables the feature which remove ground from scan
void convertDepthToPolarCoords(const sensor_msgs::ImageConstPtr &depth_msg)
convertDepthToPolarCoords converts depth map to 2D
bool cam_model_update_
If continously calibration update required.
std::vector< unsigned > scan_msg_index_
Calculated laser scan msg indexes for each depth image column.
sensor_msgs::ImagePtr prepareDbgImage(const sensor_msgs::ImageConstPtr &depth_msg, const std::list< std::pair< int, int >> &min_dist_points_indices)
sensor_msgs::LaserScanPtr getLaserScanMsg(const sensor_msgs::ImageConstPtr &depth_msg, const sensor_msgs::CameraInfoConstPtr &info_msg)
prepareLaserScanMsg converts depthimage and prepare new LaserScan message
std::vector< float > tilt_compensation_factor_
Calculated sensor tilt compensation factors.
int image_vertical_offset_
The vertical offset of image based on calibration data.
void setCamModelUpdate(const bool enable)
setCamModelUpdate sets the camera parameters
void calcGroundDistancesForImgRows(double vertical_fov)
calcGroundDistancesForImgRows calculate coefficients used in ground removing from scan ...
sensor_msgs::LaserScanPtr scan_msg_
Published scan message.
void setScanHeight(const int scan_height)
setScanHeight sets height of depth image which will be used in conversion process ...
void setGroundMargin(const float margin)
setGroundMargin sets the floor margin (in meters)
std::string output_frame_id_
Output frame_id for laserscan message.
void calcTiltCompensationFactorsForImgRows(double vertical_fov)
calcTiltCompensationFactorsForImgRows calculate factors used in tilt compensation ...
float sensor_mount_height_
Height of sensor mount from ground.
std::vector< float > dist_to_ground_corrected
Calculated maximal distances for measurements not included as floor.
bool ground_remove_enable_
Determines if remove ground from output scan.
float range_max_
Stores the current maximum range to use.


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