Skip to content

Commit c509f9f

Browse files
luca-della-vedovamxgreyjhdcs
authored
Add parameter services (#342)
* WIP Adding describe paramater service * Implement parameter setting services Signed-off-by: Luca Della Vedova <[email protected]> * Restructure and cleanup Signed-off-by: Luca Della Vedova <[email protected]> * Implement list_parameters with prefixes Signed-off-by: Luca Della Vedova <[email protected]> * Minor cleanups Signed-off-by: Luca Della Vedova <[email protected]> * Fix tests, cleanups Signed-off-by: Luca Della Vedova <[email protected]> * Fix order of drop calls Signed-off-by: Luca Della Vedova <[email protected]> * Add first bunch of unit tests for list and get / set parameters Signed-off-by: Luca Della Vedova <[email protected]> * Clear warnings in rclrs Signed-off-by: Luca Della Vedova <[email protected]> * Fix clippy, add set atomically tests Signed-off-by: Luca Della Vedova <[email protected]> * Add describe parameter and get parameter types tests Signed-off-by: Luca Della Vedova <[email protected]> * Minor cleanups, remove several unwraps Signed-off-by: Luca Della Vedova <[email protected]> * Remove commented code Signed-off-by: Luca Della Vedova <[email protected]> * Address first round of feedback Signed-off-by: Luca Della Vedova <[email protected]> * Allow undeclared parameters in parameter getting services Signed-off-by: Luca Della Vedova <[email protected]> * Clippy Signed-off-by: Luca Della Vedova <[email protected]> * Run rustfmt Signed-off-by: Michael X. Grey <[email protected]> * Update rclrs/src/parameter/service.rs Co-authored-by: jhdcs <[email protected]> * Change behavior to return NOT_SET for non existing parameters Signed-off-by: Luca Della Vedova <[email protected]> * Make use_sim_time parameter read only Signed-off-by: Luca Della Vedova <[email protected]> * Format Signed-off-by: Luca Della Vedova <[email protected]> * Add a comment to denote why unwrap is safe Signed-off-by: Luca Della Vedova <[email protected]> * Use main fmt Signed-off-by: Luca Della Vedova <[email protected]> * Add a builder parameter to start parameter services Signed-off-by: Luca Della Vedova <[email protected]> --------- Signed-off-by: Luca Della Vedova <[email protected]> Signed-off-by: Michael X. Grey <[email protected]> Co-authored-by: Michael X. Grey <[email protected]> Co-authored-by: jhdcs <[email protected]>
1 parent 2e746d6 commit c509f9f

File tree

9 files changed

+1406
-238
lines changed

9 files changed

+1406
-238
lines changed

Diff for: rclrs/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ rosidl_runtime_rs = "0.4"
3434
tempfile = "3.3.0"
3535
# Needed for publisher and subscriber tests
3636
test_msgs = {version = "*"}
37+
# Needed for parameter service tests
38+
tokio = { version = "*", features = ["rt", "time", "macros"] }
3739

3840
[build-dependencies]
3941
# Needed for FFI

Diff for: rclrs/src/node/builder.rs

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::{
1818
/// - `use_global_arguments: true`
1919
/// - `arguments: []`
2020
/// - `enable_rosout: true`
21+
/// - `start_parameter_services: true`
2122
/// - `clock_type: ClockType::RosTime`
2223
/// - `clock_qos: QOS_PROFILE_CLOCK`
2324
///
@@ -49,6 +50,7 @@ pub struct NodeBuilder {
4950
use_global_arguments: bool,
5051
arguments: Vec<String>,
5152
enable_rosout: bool,
53+
start_parameter_services: bool,
5254
clock_type: ClockType,
5355
clock_qos: QoSProfile,
5456
}
@@ -97,6 +99,7 @@ impl NodeBuilder {
9799
use_global_arguments: true,
98100
arguments: vec![],
99101
enable_rosout: true,
102+
start_parameter_services: true,
100103
clock_type: ClockType::RosTime,
101104
clock_qos: QOS_PROFILE_CLOCK,
102105
}
@@ -231,6 +234,15 @@ impl NodeBuilder {
231234
self
232235
}
233236

237+
/// Enables or disables parameter services.
238+
///
239+
/// Parameter services can be used to allow external nodes to list, get and set
240+
/// parameters for this node.
241+
pub fn start_parameter_services(mut self, start: bool) -> Self {
242+
self.start_parameter_services = start;
243+
self
244+
}
245+
234246
/// Sets the node's clock type.
235247
pub fn clock_type(mut self, clock_type: ClockType) -> Self {
236248
self.clock_type = clock_type;
@@ -308,6 +320,9 @@ impl NodeBuilder {
308320
parameter,
309321
});
310322
node.time_source.attach_node(&node);
323+
if self.start_parameter_services {
324+
node.parameter.create_services(&node)?;
325+
}
311326
Ok(node)
312327
}
313328

Diff for: rclrs/src/node/graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,16 @@ mod tests {
519519

520520
assert!(subscription_infos.is_empty());
521521

522-
// Test that the graph has no services
522+
// Test that the graph only has 6 services (parameter services)
523523
let names_and_topics = node
524524
.get_service_names_and_types_by_node(node_name, "")
525525
.unwrap();
526526

527-
assert_eq!(names_and_topics.len(), 0);
527+
assert_eq!(names_and_topics.len(), 6);
528528

529529
let names_and_topics = node.get_service_names_and_types().unwrap();
530530

531-
assert_eq!(names_and_topics.len(), 0);
531+
assert_eq!(names_and_topics.len(), 6);
532532

533533
// Test that the graph has no clients
534534
let names_and_topics = node

0 commit comments

Comments
 (0)