1
1
use crate :: {
2
2
clock:: { Clock , ClockSource , ClockType } ,
3
3
vendor:: rosgraph_msgs:: msg:: Clock as ClockMsg ,
4
- MandatoryParameter , Node , QoSProfile , Subscription , QOS_PROFILE_CLOCK ,
4
+ ReadOnlyParameter , Node , QoSProfile , Subscription , QOS_PROFILE_CLOCK ,
5
5
} ;
6
6
use std:: sync:: { Arc , Mutex , RwLock , Weak } ;
7
7
@@ -16,7 +16,9 @@ pub(crate) struct TimeSource {
16
16
clock_qos : QoSProfile ,
17
17
clock_subscription : Mutex < Option < Arc < Subscription < ClockMsg > > > > ,
18
18
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 > > > ,
20
22
}
21
23
22
24
/// A builder for creating a [`TimeSource`][1].
@@ -84,12 +86,12 @@ impl TimeSource {
84
86
/// Attaches the given node to to the `TimeSource`, using its interface to read the
85
87
/// `use_sim_time` parameter and create the clock subscription.
86
88
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.
89
91
let param = node
90
92
. declare_parameter ( "use_sim_time" )
91
93
. default ( false )
92
- . mandatory ( )
94
+ . read_only ( )
93
95
. unwrap ( ) ;
94
96
* self . node . lock ( ) . unwrap ( ) = Arc :: downgrade ( node) ;
95
97
self . set_ros_time_enable ( param. get ( ) ) ;
0 commit comments