Skip to content

Commit 00c7951

Browse files
Make use_sim_time parameter read only
Signed-off-by: Luca Della Vedova <[email protected]>
1 parent 3274f42 commit 00c7951

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: rclrs/src/time_source.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
clock::{Clock, ClockSource, ClockType},
33
vendor::rosgraph_msgs::msg::Clock as ClockMsg,
4-
MandatoryParameter, Node, QoSProfile, Subscription, QOS_PROFILE_CLOCK,
4+
ReadOnlyParameter, Node, QoSProfile, Subscription, QOS_PROFILE_CLOCK,
55
};
66
use std::sync::{Arc, Mutex, RwLock, Weak};
77

@@ -16,7 +16,9 @@ pub(crate) struct TimeSource {
1616
clock_qos: QoSProfile,
1717
clock_subscription: Mutex<Option<Arc<Subscription<ClockMsg>>>>,
1818
last_received_time: Arc<Mutex<Option<i64>>>,
19-
use_sim_time: Mutex<Option<MandatoryParameter<bool>>>,
19+
// TODO(luca) Make this parameter editable when we have parameter callbacks implemented and can
20+
// safely change clock type at runtime
21+
use_sim_time: Mutex<Option<ReadOnlyParameter<bool>>>,
2022
}
2123

2224
/// A builder for creating a [`TimeSource`][1].
@@ -84,12 +86,12 @@ impl TimeSource {
8486
/// Attaches the given node to to the `TimeSource`, using its interface to read the
8587
/// `use_sim_time` parameter and create the clock subscription.
8688
pub(crate) fn attach_node(&self, node: &Arc<Node>) {
87-
// TODO(luca) register a parameter callback that calls set_ros_time(bool) once parameter
88-
// callbacks are implemented.
89+
// TODO(luca) Make this parameter editable and register a parameter callback
90+
// that calls set_ros_time(bool) once parameter callbacks are implemented.
8991
let param = node
9092
.declare_parameter("use_sim_time")
9193
.default(false)
92-
.mandatory()
94+
.read_only()
9395
.unwrap();
9496
*self.node.lock().unwrap() = Arc::downgrade(node);
9597
self.set_ros_time_enable(param.get());

0 commit comments

Comments
 (0)