cliff_detector.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2015, Michal Drwiega (drwiega.michal@gmail.com)
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are met:
00009  *     1. Redistributions of source code must retain the above copyright
00010  *        notice, this list of conditions and the following disclaimer.
00011  *     2. Redistributions in binary form must reproduce the above copyright
00012  *        notice, this list of conditions and the following disclaimer in the
00013  *        documentation and/or other materials provided with the distribution.
00014  *     3. Neither the name of the copyright holder nor the names of its
00015  *        contributors may be used to endorse or promote products derived
00016  *        from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00024  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00026  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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: // Public methods
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: // Private methods
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: // Private fields
00244 
00245   //-----------------------------------------------------------------------------------------------
00246   // ROS parameters configurated with config file or dynamic_reconfigure
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: // Public fields
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 }; // cliff_detector
00283 
00284 #endif


cliff_detector
Author(s): Michal Drwiega
autogenerated on Thu Jun 6 2019 22:10:46