gazebo_ros_range.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Modified BSD License)
00003  *
00004  *  Copyright (c) 2013, PAL Robotics, S.L.
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 PAL Robotics, S.L. 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 
00037 #ifndef GAZEBO_ROS_RANGE_H
00038 #define GAZEBO_ROS_RANGE_H
00039 
00040 
00041 #include <string>
00042 
00043 #include <boost/bind.hpp>
00044 #include <boost/thread.hpp>
00045 #include <boost/thread/mutex.hpp>
00046 
00047 #include <ros/ros.h>
00048 #include <ros/callback_queue.h>
00049 #include <ros/advertise_options.h>
00050 #include <sensor_msgs/Range.h>
00051 
00052 #include <gazebo/physics/physics.hh>
00053 #include <gazebo/transport/TransportTypes.hh>
00054 #include <gazebo/msgs/MessageTypes.hh>
00055 #include <gazebo/common/Time.hh>
00056 #include <gazebo/common/Plugin.hh>
00057 #include <gazebo/common/Events.hh>
00058 #include <gazebo/sensors/SensorTypes.hh>
00059 #include <gazebo/plugins/RayPlugin.hh>
00060 
00061 #include <sdf/Param.hh>
00062 
00063 namespace gazebo
00064 {
00065 
00066 class GazeboRosRange : public RayPlugin
00067 {
00068 
00070     public: GazeboRosRange();
00071 
00073     public: ~GazeboRosRange();
00074 
00077     public: void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
00078 
00080     protected: virtual void OnNewLaserScans();
00081 
00083     private: void PutRangeData(common::Time &_updateTime);
00084 
00086     private: int range_connect_count_;
00087     private: void RangeConnect();
00088     private: void RangeDisconnect();
00089 
00090     // Pointer to the model
00091     private: physics::WorldPtr world_;
00093     private: sensors::SensorPtr parent_sensor_;
00094     private: sensors::RaySensorPtr parent_ray_sensor_;
00095 
00097     private: ros::NodeHandle* rosnode_;
00098     private: ros::Publisher pub_;
00099 
00101     private: sensor_msgs::Range range_msg_;
00102 
00104     private: std::string topic_name_;
00105 
00107     private: std::string frame_name_;
00108 
00110     private: std::string radiation_;
00111 
00113     private: double fov_;
00115     private: double gaussian_noise_;
00116 
00118     private: double GaussianKernel(double mu, double sigma);
00119 
00121     private: boost::mutex lock_;
00122 
00124     private: double hokuyo_min_intensity_;
00125 
00127     private: double update_rate_;
00128     private: double update_period_;
00129     private: common::Time last_update_time_;
00130 
00132     private: std::string robot_namespace_;
00133 
00134     private: ros::CallbackQueue range_queue_;
00135     private: void RangeQueueThread();
00136     private: boost::thread callback_queue_thread_;
00137 
00138     // deferred load in case ros is blocking
00139     private: sdf::ElementPtr sdf;
00140     private: void LoadThread();
00141     private: boost::thread deferred_load_thread_;
00142     private: unsigned int seed;
00143 };
00144 }
00145 #endif // GAZEBO_ROS_RANGE_H


gazebo_plugins
Author(s): John Hsu
autogenerated on Thu Feb 23 2017 03:43:23