leica_plugin.h
Go to the documentation of this file.
1 
18 /*
19  Desc: based on GazeboRosGpuLaser plugin for simulating ray sensors in Gazebo
20  Author: Mihai Emanuel Dolha
21  Date: 29 March 2012
22 */
23 
24 #pragma once
25 #ifndef _LEICA_PLUGIN_H
26 #define _LEICA_PLUGIN_H
27 
28 #include <string>
29 
30 #include <boost/bind.hpp>
31 #include <boost/thread.hpp>
32 #include <thread>
33 
34 #include <sdf/sdf.hh>
35 
36 #include <ros/ros.h>
37 #include <ros/advertise_options.h>
38 #include <sensor_msgs/LaserScan.h>
39 #include "std_msgs/Float32.h"
40 #include "sensor_msgs/RegionOfInterest.h"
41 
42 #include <gazebo/physics/physics.hh>
43 #include <gazebo/transport/TransportTypes.hh>
44 #include <gazebo/msgs/MessageTypes.hh>
45 #include <gazebo/common/Time.hh>
46 #include <gazebo/common/Plugin.hh>
47 #include <gazebo/common/Events.hh>
48 #include <gazebo/sensors/SensorTypes.hh>
49 #include <gazebo/plugins/GpuRayPlugin.hh>
50 #include <gazebo_plugins/PubQueue.h>
51 
52 #include <condition_variable>
53 
54 namespace gazebo
55 {
56 class LeicaPlugin : public GpuRayPlugin
57 {
58 public:
63  LeicaPlugin();
64 
69  ~LeicaPlugin();
70 
77  void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
78 
84  void configureScanWindow(const sensor_msgs::RegionOfInterestConstPtr &_msg);
85 
86 private:
91  void connectToLaser();
92 
97  void disconnectFromLaser();
98 
104  void gazeboMsgToROSMsg(ConstLaserScanStampedPtr &_msg);
105 
111 
116  void gazeboLoaderThread();
117 
122  unsigned int seed_;
123 
129 
135 
140  std::string world_name_;
141 
146  physics::WorldPtr world_;
147 
152  std::string topic_name_;
153 
158  std::string frame_name_;
159 
164  std::string tf_prefix_;
165 
170  std::string namespace_;
171 
176  std::mutex mutex_;
177 
182  std::condition_variable condition_variable_;
183 
188  std::thread queue_helper_thread_;
189 
194  sensors::GpuRaySensorPtr parent_ray_sensor_;
195 
201 
207 
213 
219 
224  gazebo::transport::NodePtr gazebo_node_;
225 
230  gazebo::transport::SubscriberPtr laser_scan_sub_;
231 
236  PubQueue<sensor_msgs::LaserScan>::Ptr pub_queue_;
237 
242  PubMultiQueue pmq_;
243 
248  sdf::ElementPtr sdf_;
249 
254  boost::thread deferred_load_thread_;
255 };
256 }
257 #endif
ros::Subscriber sub_
Subscriber for the laser sensor.
Definition: leica_plugin.h:212
ros::CallbackQueue cb_queue_
Queue for the callback functions.
Definition: leica_plugin.h:218
void gazeboMsgToROSMsg(ConstLaserScanStampedPtr &_msg)
Tailor the gazebo message to the ROS format.
physics::WorldPtr world_
Pointer to the virtual world where the simulation takes place.
Definition: leica_plugin.h:146
void disconnectFromLaser()
Unregister the laser.
std::string namespace_
The namespace of the Leica station.
Definition: leica_plugin.h:170
gazebo::transport::NodePtr gazebo_node_
Node for gazebo.
Definition: leica_plugin.h:224
void gazeboLoaderThread()
Load the sensor controller.
PubQueue< sensor_msgs::LaserScan >::Ptr pub_queue_
Publisher queue.
Definition: leica_plugin.h:236
std::string world_name_
Stores the name of the virtual world where the simulation takes place.
Definition: leica_plugin.h:140
sdf::ElementPtr sdf_
Pointer to the *.sdf file.
Definition: leica_plugin.h:248
std::string frame_name_
Stores the name of the root of the reference system tree.
Definition: leica_plugin.h:158
LeicaPlugin()
Construct a new Gazebo ROS Laser object.
void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
Load the plugin controller.
void connectToLaser()
Register de new laser and connect to its topic.
std::mutex mutex_
Mutex used so that no laser sensor data is published until the configuration of the scan window has b...
Definition: leica_plugin.h:176
int laser_connect_count_
A counter to register the number of laser sensors in use.
Definition: leica_plugin.h:134
boost::thread deferred_load_thread_
Object for the sensor controller thread.
Definition: leica_plugin.h:254
void configureScanWindow(const sensor_msgs::RegionOfInterestConstPtr &_msg)
Configure the scan window from a topic.
void callbacksQueueHelperThread()
Thread that calls all functions in the callback queue when resources are available.
ros::NodeHandle * nh_
Pointer to the ROS node.
Definition: leica_plugin.h:200
std::thread queue_helper_thread_
Thread that calls all functions in the callback queue when resources are available.
Definition: leica_plugin.h:188
gazebo::transport::SubscriberPtr laser_scan_sub_
Gazebo part of the laser sensor subscriber.
Definition: leica_plugin.h:230
std::string tf_prefix_
tf_prefix_ as the namespace
Definition: leica_plugin.h:164
ros::Publisher pub_
Publisher for the laser sensor.
Definition: leica_plugin.h:206
std::string topic_name_
Saves the name of the topic where the laser scanner publishes what it reads.
Definition: leica_plugin.h:152
unsigned int seed_
Seed for the Gaussian noise generator.
Definition: leica_plugin.h:122
std::condition_variable condition_variable_
Variable used to wait until the configuration of the scan window has been completed.
Definition: leica_plugin.h:182
bool start_laser_
Flag to start the laser after the scan window has been set.
Definition: leica_plugin.h:128
PubMultiQueue pmq_
Object for the ROS queue system.
Definition: leica_plugin.h:242
sensors::GpuRaySensorPtr parent_ray_sensor_
Pointer to the laser sensor object.
Definition: leica_plugin.h:194
~LeicaPlugin()
Destroy the Gazebo ROS Laser object.


leica_gazebo_simulation
Author(s): Ines Lara Sicilia
autogenerated on Mon Feb 22 2021 03:50:48