rtt_rosclock_sim_clock_thread.h
Go to the documentation of this file.
1 /*
2  * (C) 2013, Johannes Meyer, TU Darmstadt
3  * (C) 2013, Intermodalics BVBA
4  * (C) 2014, Jonathan Bohren, The Johns Hopkins University
5  * - Generalized for multiple time sources
6  * - Integrated with rtt_rosclock package
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the copyright holder nor the names of its contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __RTT_ROSCLOCK_SIM_CLOCK_THREAD_H
35 #define __RTT_ROSCLOCK_SIM_CLOCK_THREAD_H
36 
37 #include <rtt/Service.hpp>
38 #include <rtt/os/Thread.hpp>
39 #include <rtt/os/TimeService.hpp>
40 
41 #include <ros/ros.h>
42 #include <ros/subscriber.h>
43 #include <ros/callback_queue.h>
44 
45 #include <rosgraph_msgs/Clock.h>
46 
47 namespace rtt_rosclock {
48 
54  {
55  public:
61  static void Release();
62 
63  virtual ~SimClockThread();
64 
69  };
70 
72  bool setClockSource(SimClockSource clock_source);
74  bool useROSClockTopic();
76  bool useManualClock();
77 
79  bool simTimeEnabled() const;
80 
89  bool updateClock(const ros::Time new_time);
90 
91  protected:
92 
96  void operator=(SimClockThread const&);
97 
100 
102  void resetTimeService();
103 
105  bool updateClockInternal(const ros::Time new_time);
106 
107  // RTT::os::Thread interface
108  virtual bool initialize();
109  virtual void loop();
110  virtual bool breakLoop();
111  virtual void finalize();
112 
115 
118 
121 
127  void clockMsgCallback(const rosgraph_msgs::ClockConstPtr& clock);
128  };
129 
130 }
131 
132 #endif // ifndef __RTT_ROSCLOCK_RTT_ROSCLOCK_ACTIVITY_H
133 
134 
135 
bool useManualClock()
Set the clock source to use a manual source, i.e. call updateClock() manually.
bool updateClockInternal(const ros::Time new_time)
Update the RTT clock and SimClockActivities with a new time (see updateClock() for manually updating)...
void operator=(SimClockThread const &)
void resetTimeService()
Re-set the RTT::os::TimeService to zero and restart logging.
static boost::shared_ptr< SimClockThread > GetInstance()
Get an instance to the singleton SimClockThread or NULL.
bool useROSClockTopic()
Set the clock source to use the ROS /clock topic.
SimClockSource
Simulation clock sources.
ros::Subscriber clock_subscriber_
ROS /clock topic subscriber.
static boost::shared_ptr< SimClockThread > Instance()
Get an instance to the singleton SimClockThread or create one.
static void Release()
Release the singleton SimClockThread.
bool updateClock(const ros::Time new_time)
ros::CallbackQueue callback_queue_
Custom callback queue used in this thread.
void clockMsgCallback(const rosgraph_msgs::ClockConstPtr &clock)
ROS message callback for /clock topic.
bool simTimeEnabled() const
Check if simulation time is enabled.
static boost::shared_ptr< SimClockThread > singleton
SimClockThread singleton.
bool setClockSource(SimClockSource clock_source)
Set the simulation clock source by ID (see ClockSource enum)
bool process_callbacks_
Keep running the thread loop if this is set to true.
SimClockThread()
Constructor is protected, use Instance() to create and get a singleton.
RTT::os::TimeService * time_service_
Convenient pointer to RTT time service.
SimClockSource clock_source_
Current clock source.


rtt_rosclock
Author(s):
autogenerated on Mon May 10 2021 02:45:33