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 <aspect/blackboard.h>
25 #include <aspect/blocked_timing.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/threading/thread.h>
30 #include <plugins/gazebo/aspect/gazebo.h>
31 
32 //from Gazebo
33 #include <gazebo/msgs/MessageTypes.hh>
34 #include <gazebo/transport/TransportTypes.hh>
35 #include <gazebo/transport/transport.hh>
36 
37 namespace fawkes {
38 class Laser360Interface;
39 class Time;
40 } // namespace fawkes
41 
43  public fawkes::ClockAspect,
44  public fawkes::LoggingAspect,
49 {
50 public:
52 
53  virtual void init();
54  virtual void loop();
55  virtual void finalize();
56 
57 private:
58  ///Subscriber to receive laser data from gazebo
59  gazebo::transport::SubscriberPtr laser_sub_;
60  std::string laser_topic_;
61 
62  ///provided interface
63  fawkes::Laser360Interface *laser_if_;
64 
65  ///storage for laser data
66  float * laser_data_;
67  fawkes::Time *laser_time_;
68 
69  ///is there new information to write in the interface?
70  bool new_data_;
71 
72  ///handler function for incoming laser data messages
73  void on_laser_data_msg(ConstLaserScanStampedPtr &msg);
74 
75  ///maximal range of the laser sensor
76  float max_range_;
77 
78  std::string interface_id_;
79  std::string frame_id_;
80 };
81 
82 #endif
LaserSimThread::loop
virtual void loop()
Code to execute in the thread.
Definition: gazsim_laser_thread.cpp:87
fawkes::GazeboAspect
Definition: gazebo.h:42
LaserSimThread::finalize
virtual void finalize()
Finalize the thread.
Definition: gazsim_laser_thread.cpp:79
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:56
LaserSimThread::init
virtual void init()
Initialize the thread.
Definition: gazsim_laser_thread.cpp:52
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes
fawkes::LoggingAspect
Definition: logging.h:38
LaserSimThread
Definition: gazsim_laser_thread.h:42
fawkes::Time
Definition: time.h:98
fawkes::Thread
Definition: thread.h:45
fawkes::ConfigurableAspect
Definition: configurable.h:38
fawkes::Laser360Interface
Definition: Laser360Interface.h:39
fawkes::ClockAspect
Definition: clock.h:40
LaserSimThread::LaserSimThread
LaserSimThread()
Constructor.
Definition: gazsim_laser_thread.cpp:45