Fawkes API  Fawkes Development Version
gazsim_laser_thread.h
1 /***************************************************************************
2  * gazsim_laser_thread.h - Thread simulate the Hokuyo in Gazebo
3  *
4  * Created: Thu Aug 08 15:47:12 2013
5  * Copyright 2013 Frederik Zwilling
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #ifndef __PLUGINS_GAZSIM_LASER_THREAD_H_
22 #define __PLUGINS_GAZSIM_LASER_THREAD_H_
23 
24 #include <core/threading/thread.h>
25 #include <aspect/clock.h>
26 #include <aspect/configurable.h>
27 #include <aspect/logging.h>
28 #include <aspect/blackboard.h>
29 #include <aspect/blocked_timing.h>
30 #include <plugins/gazebo/aspect/gazebo.h>
31 
32 //from Gazebo
33 #include <gazebo/transport/TransportTypes.hh>
34 #include <gazebo/msgs/MessageTypes.hh>
35 #include <gazebo/transport/transport.hh>
36 
37 
38 namespace fawkes {
39  class Laser360Interface;
40  class Time;
41 }
42 
44 : public fawkes::Thread,
45  public fawkes::ClockAspect,
46  public fawkes::LoggingAspect,
51 {
52  public:
54 
55  virtual void init();
56  virtual void loop();
57  virtual void finalize();
58 
59  private:
60  ///Subscriber to receive laser data from gazebo
61  gazebo::transport::SubscriberPtr laser_sub_;
62  std::string laser_topic_;
63 
64  ///provided interface
65  fawkes::Laser360Interface *laser_if_;
66 
67  ///storage for laser data
68  float *laser_data_;
69  fawkes::Time *laser_time_;
70 
71  ///is there new information to write in the interface?
72  bool new_data_;
73 
74  ///handler function for incoming laser data messages
75  void on_laser_data_msg(ConstLaserScanStampedPtr &msg);
76 
77  ///maximal range of the laser sensor
78  float max_range_;
79 
80  std::string interface_id_;
81  std::string frame_id_;
82 };
83 
84 #endif
Laser360Interface Fawkes BlackBoard Interface.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Thread simulates the Hokuyo in Gazebo.
Fawkes library namespace.
Thread aspect to get access to a Gazebo node handle.
Definition: gazebo.h:37
A class for handling time.
Definition: time.h:91
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to use blocked timing.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35