rtt_rosclock_service.cpp
Go to the documentation of this file.
1 #include <rtt/RTT.hpp>
3 
6 
8 
9 namespace {
11 }
12 
14  sim_clock_thread.reset();
15 }
16 
18  RTT::Service::shared_ptr rosclock = RTT::internal::GlobalService::Instance()->provides("ros")->provides("clock");
19 
20  rosclock->doc("RTT service for realtime and non-realtime clock measurement.");
21 
22  // Create sim time thread
25 
26  // Getting current time
27  rosclock->addOperation("host_now", &rtt_rosclock::host_now).doc(
28  "Get a ros::Time structure based on the NTP-corrected RT time or the ROS simulation time.");
29  rosclock->addOperation("host_wall_now", &rtt_rosclock::host_now).doc(
30  "Get a ros::Time structure based on the NTP-corrected RT time or the ROS wall time.");
31  rosclock->addOperation("rtt_now", &rtt_rosclock::rtt_now).doc(
32  "Get a ros::Time structure based on the RTT time source.");
33  rosclock->addOperation("rtt_wall_now", &rtt_rosclock::rtt_wall_now).doc(
34  "Get a ros::Time structure based on the RTT wall clock time.");
35 
36  // Getting time offset
37  rosclock->addOperation("host_offset_from_rtt", &rtt_rosclock::host_offset_from_rtt).doc(
38  "Get the difference between the Orocos wall clock and the NTP-corrected wall clock in seconds (host_wall - rtt_wall).");
39 
40  // Setting the source for the simulation clock
41  rosclock->addOperation("useROSClockTopic", &rtt_rosclock::use_ros_clock_topic).doc(
42  "Use the ROS /clock topic source for updating simulation time.");
43  rosclock->addOperation("useManualClock", &rtt_rosclock::use_manual_clock).doc(
44  "Use a manual source for simulation time by calling updateSimClock.");
45 
46  // Enabling/Disabling simulation clock
47  rosclock->addOperation("enableSimClock", &rtt_rosclock::enable_sim).doc(
48  "Enable simulation time based on the ROS /clock topic if the /use_sim_time parameter is set. This will override RTT::os::TimeService");
49  rosclock->addOperation("disableSimClock", &rtt_rosclock::disable_sim).doc(
50  "Disable simulation time based on the ROS /clock topic.");
51 
52  rosclock->addOperation("updateSimClock", &rtt_rosclock::update_sim_clock).doc(
53  "Update the current simulation time and update all SimClockActivities as per their respective frequencies.").arg(
54  "time","Current simulated time in seconds.");
55 }
56 
57 using namespace RTT;
58 extern "C" {
60  if (c != 0) return false;
62  return true;
63  }
64  std::string getRTTPluginName (){
65  return "rosclock";
66  }
67  std::string getRTTTargetName (){
68  return OROCOS_TARGET_NAME;
69  }
70 }
const bool enable_sim()
Use a simulated clock source.
const RTT::Seconds host_offset_from_rtt()
Get the difference in seconds between rtt_wall_now() and host_wall_now()
bool loadRTTPlugin(RTT::TaskContext *c)
static StartStopManager * Instance()
std::string getRTTPluginName()
boost::shared_ptr< rtt_rosclock::SimClockThread > sim_clock_thread
void use_manual_clock()
Use manual clock updates.
void use_ros_clock_topic()
Use ROS /clock topic for time measurement.
void loadROSClockService()
static boost::shared_ptr< SimClockThread > Instance()
Get an instance to the singleton SimClockThread or create one.
const ros::Time rtt_wall_now()
Get the current wall time according to RTT.
void update_sim_clock(const ros::Time new_time)
Update the current simulation time and trigger all simulated TaskContexts.
std::string getRTTTargetName()
const bool disable_sim()
Do&#39;t use a simulated clock source.
const ros::Time host_now()
Get the current time according to CLOCK_HOST_REALTIME or the simulation time.
const ros::Time rtt_now()
Get the current time according to RTT.
void stopFunction(stop_fun t)
void unloadROSClockService()
static RTT_API Service::shared_ptr Instance()


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