laserscan_kinect.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  *****************************************************************************/
00037 #ifndef LASERSCAN_KINECT
00038 #define LASERSCAN_KINECT
00039 
00040 #include <ros/console.h>
00041 #include <sensor_msgs/Image.h>
00042 #include <sensor_msgs/LaserScan.h>
00043 #include <sensor_msgs/image_encodings.h>
00044 #include <image_geometry/pinhole_camera_model.h>
00045 
00046 #include <limits.h>
00047 #include <algorithm>
00048 #include <vector>
00049 #include <cmath>
00050 #include <string>
00051 #include <boost/lexical_cast.hpp>
00052 
00053 #define MAX_UINT16  65535
00054 #define SCAN_TIME   1.0/30.0
00055 
00056 namespace laserscan_kinect
00057 { 
00058 class LaserScanKinect
00059 {
00060 public: // Public methods
00061   LaserScanKinect();
00062   ~LaserScanKinect() { }
00063 
00072   sensor_msgs::LaserScanPtr prepareLaserScanMsg(const sensor_msgs::ImageConstPtr& depth_msg,
00073                                                 const sensor_msgs::CameraInfoConstPtr& info_msg);
00078   void setOutputFrame (const std::string frame) { output_frame_id_ = frame; }
00085   void setRangeLimits(const float rmin, const float rmax);
00091   void setScanHeight(const int scan_height);
00097   void setDepthImgRowStep(const int row_step);
00103   void setCamModelUpdate (const bool enable) { cam_model_update_ = enable; }
00107   void setSensorMountHeight (const float height);
00113   void setSensorTiltAngle (const float angle);
00119   void setGroundRemove (const bool enable) { ground_remove_enable_ = enable; }
00125   void setGroundMargin (const float margin);
00131   void setTiltCompensation (const bool enable) { tilt_compensation_enable_ = enable; }
00137   void setScanConfigurated (const bool configurated) { is_scan_msg_configurated_ = configurated; }
00138 
00139 private: // Private methods
00146   double lengthOfVector(const cv::Point3d& ray) const;
00154   double angleBetweenRays(const cv::Point3d& ray1, const cv::Point3d& ray2) const;
00167   void fieldOfView( double & min, double & max, double x1, double y1,
00168                     double xc, double yc, double x2, double y2);
00174   void calcGroundDistancesForImgRows(double vertical_fov);
00180   void calcTiltCompensationFactorsForImgRows(double vertical_fov);
00186   void calcScanMsgIndexForImgCols(const sensor_msgs::ImageConstPtr& depth_msg);
00192   void convertDepthToPolarCoords(       const sensor_msgs::ImageConstPtr& depth_msg);
00193 
00194 private: // Private fields
00195   //-----------------------------------------------------------------------------------------------
00196   // ROS parameters configurated with configuration file or dynamic_reconfigure
00197   std::string output_frame_id_;     
00198   float range_min_;                 
00199   float range_max_;                 
00200   unsigned int  scan_height_;       
00201   unsigned int depth_img_row_step_; 
00202   bool  cam_model_update_;          
00203   float sensor_mount_height_;       
00204   float sensor_tilt_angle_;         
00205   bool  ground_remove_enable_;      
00206   float ground_margin_;             
00207   bool  tilt_compensation_enable_;  
00208   //-----------------------------------------------------------------------------------------------
00209 
00211   sensor_msgs::LaserScanPtr scan_msg_;
00212 
00214   image_geometry::PinholeCameraModel camera_model_;
00215 
00217   bool  is_scan_msg_configurated_;
00218 
00220   std::vector<unsigned int> scan_msg_index_;
00221 
00223   std::vector<unsigned int> dist_to_ground_;
00224 
00226   std::vector<double> tilt_compensation_factor_;
00227 
00228 }; // end of class
00229 }; // end of namespace laserscan_kinect
00230 
00231 #endif


laserscan_kinect
Author(s): Michal Drwiega
autogenerated on Thu Jun 6 2019 22:10:52