GazeboRosVelodyneLaser.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015-2017, Dataspeed Inc.
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
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Dataspeed Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef GAZEBO_ROS_VELODYNE_LASER_H_
00036 #define GAZEBO_ROS_VELODYNE_LASER_H_
00037 
00038 // Custom Callback Queue
00039 #include <ros/ros.h>
00040 #include <ros/callback_queue.h>
00041 #include <ros/advertise_options.h>
00042 
00043 #include <sdf/Param.hh>
00044 #include <gazebo/physics/physics.hh>
00045 #include <gazebo/transport/TransportTypes.hh>
00046 #include <gazebo/msgs/MessageTypes.hh>
00047 
00048 #include <gazebo/common/Time.hh>
00049 #include <gazebo/common/Plugin.hh>
00050 #include <gazebo/sensors/SensorTypes.hh>
00051 #include <gazebo/plugins/RayPlugin.hh>
00052 
00053 #include <boost/bind.hpp>
00054 #include <boost/thread.hpp>
00055 #include <boost/thread/mutex.hpp>
00056 #include <boost/thread/lock_guard.hpp>
00057 
00058 namespace gazebo
00059 {
00060 
00061   class GazeboRosVelodyneLaser : public RayPlugin
00062   {
00065     public: GazeboRosVelodyneLaser();
00066 
00068     public: ~GazeboRosVelodyneLaser();
00069 
00072     public: void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
00073 
00075     private: void ConnectCb();
00076 
00078     private: sensors::RaySensorPtr parent_ray_sensor_;
00079 
00081     private: ros::NodeHandle* nh_;
00082 
00084     private: ros::Publisher pub_;
00085 
00087     private: std::string topic_name_;
00088 
00090     private: std::string frame_name_;
00091 
00093     private: double min_range_;
00094 
00096     private: double max_range_;
00097 
00099     private: double gaussian_noise_;
00100 
00102     private: static double gaussianKernel(double mu, double sigma)
00103     {
00104       // using Box-Muller transform to generate two independent standard normally distributed normal variables
00105       // see wikipedia
00106       double U = (double)rand() / (double)RAND_MAX; // normalized uniform random variable
00107       double V = (double)rand() / (double)RAND_MAX; // normalized uniform random variable
00108       return sigma * (sqrt(-2.0 * ::log(U)) * cos(2.0 * M_PI * V)) + mu;
00109     }
00110 
00112     private: boost::mutex lock_;
00113 
00115     private: std::string robot_namespace_;
00116 
00117     // Custom Callback Queue
00118     private: ros::CallbackQueue laser_queue_;
00119     private: void laserQueueThread();
00120     private: boost::thread callback_laser_queue_thread_;
00121 
00122     // Subscribe to gazebo laserscan
00123     private: gazebo::transport::NodePtr gazebo_node_;
00124     private: gazebo::transport::SubscriberPtr sub_;
00125     private: void OnScan(const ConstLaserScanStampedPtr &_msg);
00126 
00127   };
00128 
00129 } // namespace gazebo
00130 
00131 #endif /* GAZEBO_ROS_VELODYNE_LASER_H_ */
00132 


velodyne_gazebo_plugins
Author(s): Kevin Hallenbeck
autogenerated on Thu Jun 6 2019 19:00:24