Add methods to access TimeSource and shared ROS clock

This commit is contained in:
Martin Škoudlil 2024-01-08 14:43:26 +01:00
parent 0b86dda116
commit 951db6caae
1 changed files with 15 additions and 0 deletions

View File

@ -1333,6 +1333,21 @@ impl Node {
let s = unsafe { CStr::from_ptr(ptr) };
s.to_str().unwrap_or("")
}
/// Get TimeSource of the node
///
/// See: [`TimeSource`]
#[cfg(feature = "sim-time")]
pub fn get_time_source(&self) -> TimeSource {
self.time_source.clone()
}
/// Get ROS clock of the node
///
/// This is the same clock that is used by ROS timers created in [`Node::create_timer`].
pub fn get_ros_clock(&self) -> Arc<Mutex<Clock>> {
self.ros_clock.clone()
}
}
#[derive(Debug, Clone, PartialEq)]