Fawkes API  Fawkes Development Version
gazsim_timesource_thread.h
1 /***************************************************************************
2  * gazsim_timesource_plugin.cpp - Plugin sets the fawkes time
3  * to the simulation time
4  *
5  * Created: Sat Sep 21 20:56:38 2013
6  * Copyright 2013 Frederik Zwilling
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_GAZSIM__TIMESOURCE_THREAD_H_
24 #define __PLUGINS_GAZSIM__TIMESOURCE_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/clock.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/blocked_timing.h>
31 #include <boost/asio.hpp>
32 #include <google/protobuf/message.h>
33 #include <gazebo/physics/physics.hh>
34 #include <plugins/gazebo/aspect/gazebo.h>
35 
36 #include "gazsim_timesource_source.h"
37 #include "../msgs/SimTime.pb.h"
38 
39 typedef const boost::shared_ptr<gazsim_msgs::SimTime const> ConstSimTimePtr;
40 
42 : public fawkes::Thread,
43  public fawkes::ClockAspect,
46  public fawkes::LoggingAspect,
48 {
49  public:
52 
53  virtual void init();
54  virtual void loop();
55  virtual void finalize();
56 
57  private:
58  //Timesource to give the fawkes clock
59  fawkes::GazsimTimesource* time_source_;
60 
61  //subscriber to get time msgs from
62  gazebo::transport::SubscriberPtr time_sync_sub_;
63 
64  //handler
65  void on_time_sync_msg(ConstSimTimePtr &msg);
66 
67 };
68 
69 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
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 use blocked timing.
Plugin provides the simulation time from gazebo.
virtual void init()
Initialize the thread.
virtual void loop()
Code to execute in the thread.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
This time-source provides the simulation time from Gazebo in Fawkes.
virtual void finalize()
Finalize the thread.