Fawkes API  Fawkes Development Version
gazsim_localization_thread.h
1 /***************************************************************************
2  * gazsim_localization_thread.h - Thread provides
3  * the simulated position of a robot in Gazeo
4  *
5  * Created: Thu Aug 08 17:40:10 2013
6  * Copyright 2013 Frederik Zwilling
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef _PLUGINS_GAZSIM_LOCALIZATION_THREAD_H_
23 #define _PLUGINS_GAZSIM_LOCALIZATION_THREAD_H_
24 
25 #include <aspect/blackboard.h>
26 #include <aspect/blocked_timing.h>
27 #include <aspect/clock.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <aspect/tf.h>
31 #include <core/threading/thread.h>
32 #include <plugins/gazebo/aspect/gazebo.h>
33 
34 //from Gazebo
35 #include <gazebo/msgs/MessageTypes.hh>
36 #include <gazebo/transport/TransportTypes.hh>
37 #include <gazebo/transport/transport.hh>
38 
39 namespace fawkes {
40 class Position3DInterface;
41 }
42 
44  public fawkes::ClockAspect,
45  public fawkes::LoggingAspect,
49  public fawkes::GazeboAspect,
51 {
52 public:
54 
55  virtual void init();
56  virtual void loop();
57  virtual void finalize();
58 
59 private:
60  //Subscriber to receive localization data from gazebo
61  gazebo::transport::SubscriberPtr localization_sub_;
62  std::string gps_topic_;
63 
64  //provided interface
65  fawkes::Position3DInterface *localization_if_;
66 
67  //handler function for incoming localization data messages
68  void on_localization_msg(ConstPosePtr &msg);
69 
70  //is there new information to write in the interface?
71  bool new_data_;
72 
73  //localization data
74  double x_;
75  double y_;
76  double z_;
77  double quat_x_;
78  double quat_y_;
79  double quat_z_;
80  double quat_w_;
81 
82  //time the transform should be up to date
83  double transform_tolerance_;
84 
85  //frame ids for transform
86  std::string odom_frame_id_;
87  std::string global_frame_id_;
88 };
89 
90 #endif
Thread simulates the Localization in Gazebo.
virtual void finalize()
Finalize the thread.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to get access to a Gazebo node handle.
Definition: gazebo.h:37
Thread aspect to log output.
Definition: logging.h:33
Position3DInterface Fawkes BlackBoard Interface.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Thread aspect to access the transform system.
Definition: tf.h:39
Fawkes library namespace.