From 951db6caae150fdec8c8fa2cc3f82154b42cb7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0koudlil?= Date: Mon, 8 Jan 2024 14:43:26 +0100 Subject: [PATCH] Add methods to access TimeSource and shared ROS clock --- r2r/src/nodes.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/r2r/src/nodes.rs b/r2r/src/nodes.rs index c0a385f..2fc1e99 100644 --- a/r2r/src/nodes.rs +++ b/r2r/src/nodes.rs @@ -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> { + self.ros_clock.clone() + } } #[derive(Debug, Clone, PartialEq)]