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 <core/threading/thread.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <aspect/blackboard.h>
30 #include <aspect/blocked_timing.h>
31 #include <aspect/tf.h>
32 #include <plugins/gazebo/aspect/gazebo.h>
33 
34 //from Gazebo
35 #include <gazebo/transport/TransportTypes.hh>
36 #include <gazebo/msgs/MessageTypes.hh>
37 #include <gazebo/transport/transport.hh>
38 
39 
40 namespace fawkes {
41  class Position3DInterface;
42 }
43 
45 : public fawkes::Thread,
46  public fawkes::ClockAspect,
47  public fawkes::LoggingAspect,
51  public fawkes::GazeboAspect,
53 {
54  public:
56 
57  virtual void init();
58  virtual void loop();
59  virtual void finalize();
60 
61  private:
62  //Subscriber to receive localization data from gazebo
63  gazebo::transport::SubscriberPtr localization_sub_;
64  std::string gps_topic_;
65 
66  //provided interface
67  fawkes::Position3DInterface *localization_if_;
68 
69  //handler function for incoming localization data messages
70  void on_localization_msg(ConstPosePtr &msg);
71 
72  //is there new information to write in the interface?
73  bool new_data_;
74 
75  //localization data
76  double x_;
77  double y_;
78  double z_;
79  double quat_x_;
80  double quat_y_;
81  double quat_z_;
82  double quat_w_;
83 
84  //time the transform should be up to date
85  double transform_tolerance_;
86 
87  //frame ids for transform
88  std::string odom_frame_id_;
89  std::string global_frame_id_;
90 };
91 
92 #endif
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
Fawkes library namespace.
Thread aspect to get access to a Gazebo node handle.
Definition: gazebo.h:37
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to access the transform system.
Definition: tf.h:42
Thread aspect to use blocked timing.
Position3DInterface Fawkes BlackBoard Interface.
Thread aspect to log output.
Definition: logging.h:35
Thread simulates the Localization in Gazebo.
Thread aspect to access configuration data.
Definition: configurable.h:35