00001 /* 00002 * Copyright 2012 Open Source Robotics Foundation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 00018 #ifndef GAZEBO_ROS_LASER_HH 00019 #define GAZEBO_ROS_LASER_HH 00020 00021 #include <string> 00022 00023 #include <boost/bind.hpp> 00024 #include <boost/thread.hpp> 00025 00026 #include <ros/ros.h> 00027 #include <ros/advertise_options.h> 00028 #include <sensor_msgs/LaserScan.h> 00029 00030 #include <gazebo/physics/physics.hh> 00031 #include <gazebo/transport/TransportTypes.hh> 00032 #include <gazebo/msgs/MessageTypes.hh> 00033 #include <gazebo/common/Time.hh> 00034 #include <gazebo/common/Plugin.hh> 00035 #include <gazebo/common/Events.hh> 00036 #include <gazebo/sensors/SensorTypes.hh> 00037 #include <gazebo/plugins/GpuRayPlugin.hh> 00038 00039 #include <sdf/sdf.hh> 00040 00041 #include <gazebo_plugins/PubQueue.h> 00042 00043 namespace gazebo 00044 { 00045 class GazeboRosLaser : public GpuRayPlugin 00046 { 00048 public: GazeboRosLaser(); 00049 00051 public: ~GazeboRosLaser(); 00052 00055 public: void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf); 00056 00058 private: int laser_connect_count_; 00059 private: void LaserConnect(); 00060 private: void LaserDisconnect(); 00061 00062 // Pointer to the model 00063 private: std::string world_name_; 00064 private: physics::WorldPtr world_; 00066 private: sensors::GpuRaySensorPtr parent_ray_sensor_; 00067 00069 private: ros::NodeHandle* rosnode_; 00070 private: ros::Publisher pub_; 00071 private: PubQueue<sensor_msgs::LaserScan>::Ptr pub_queue_; 00072 00074 private: std::string topic_name_; 00075 00077 private: std::string frame_name_; 00078 00080 private: std::string tf_prefix_; 00081 00083 private: std::string robot_namespace_; 00084 00085 // deferred load in case ros is blocking 00086 private: sdf::ElementPtr sdf; 00087 private: void LoadThread(); 00088 private: boost::thread deferred_load_thread_; 00089 private: unsigned int seed; 00090 00091 private: gazebo::transport::NodePtr gazebo_node_; 00092 private: gazebo::transport::SubscriberPtr laser_scan_sub_; 00093 private: void OnScan(ConstLaserScanStampedPtr &_msg); 00094 00096 private: PubMultiQueue pmq; 00097 }; 00098 } 00099 #endif