Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter services #342

Merged
merged 30 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c1662fd
WIP Adding describe paramater service
luca-della-vedova Nov 3, 2023
2ff7638
Implement parameter setting services
luca-della-vedova Nov 6, 2023
3b6e6e3
Restructure and cleanup
luca-della-vedova Nov 6, 2023
322f760
Merge remote-tracking branch 'origin/main' into luca/parameter_service
luca-della-vedova Nov 7, 2023
c14417b
Implement list_parameters with prefixes
luca-della-vedova Nov 7, 2023
f9bc86d
Minor cleanups
luca-della-vedova Nov 7, 2023
0605261
Fix tests, cleanups
luca-della-vedova Nov 7, 2023
6f8a6ef
Fix order of drop calls
luca-della-vedova Nov 7, 2023
45ccda9
Add first bunch of unit tests for list and get / set parameters
luca-della-vedova Nov 8, 2023
315e088
Clear warnings in rclrs
luca-della-vedova Nov 8, 2023
8d53f2a
Fix clippy, add set atomically tests
luca-della-vedova Nov 9, 2023
095a00f
Add describe parameter and get parameter types tests
luca-della-vedova Nov 9, 2023
e34a4b9
Merge branch 'main' into luca/parameter_service
luca-della-vedova Dec 7, 2023
d3585ca
Minor cleanups, remove several unwraps
luca-della-vedova Mar 18, 2024
74f384d
Remove commented code
luca-della-vedova Mar 18, 2024
68ccd97
Address first round of feedback
luca-della-vedova Mar 19, 2024
1360479
Allow undeclared parameters in parameter getting services
luca-della-vedova Mar 19, 2024
eb354a6
Clippy
luca-della-vedova Mar 19, 2024
06ca77e
Merging with main
mxgrey Apr 8, 2024
fbfdf2e
Run rustfmt
mxgrey Apr 8, 2024
cdf3854
Update rclrs/src/parameter/service.rs
luca-della-vedova Apr 12, 2024
fc7598d
Merge branch 'main' into luca/parameter_service
luca-della-vedova Apr 12, 2024
3274f42
Change behavior to return NOT_SET for non existing parameters
luca-della-vedova Apr 23, 2024
00c7951
Make use_sim_time parameter read only
luca-della-vedova Apr 23, 2024
e4dd176
Format
luca-della-vedova Apr 23, 2024
5da50a2
Add a comment to denote why unwrap is safe
luca-della-vedova Apr 23, 2024
9b2577c
Merge branch 'main' into luca/parameter_service
luca-della-vedova Apr 29, 2024
d73d07c
Use main fmt
luca-della-vedova Apr 29, 2024
f2cc667
Add a builder parameter to start parameter services
luca-della-vedova Apr 29, 2024
4b68266
Merge branch 'main' into luca/parameter_service
luca-della-vedova May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rclrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ rosidl_runtime_rs = "0.4"
tempfile = "3.3.0"
# Needed for publisher and subscriber tests
test_msgs = {version = "*"}
# Needed for parameter service tests
tokio = { version = "*", features = ["rt", "time", "macros"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we all ok with adding a test dependency? Personally, I feel it's all right, just want to make sure the other maintainers are cool with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't see any other way to do it, if we want to test clients and services we need some sort of async runtime. I am personally not very familiar with tokio so it wouldn't have been my first choice but I saw that it was the framework of choice for the services example so I stuck to it for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason to be shy about test dependencies if they're able to add any amount of value to our ability to have worthwhile tests. Especially a dependency as well vetted as tokio.

I could understand hesitation if it were a dependency on the actual package because that could limit what platforms are able to use rclrs, but test dependencies don't have any negative downstream impacts.


[build-dependencies]
# Needed for FFI
Expand Down
15 changes: 15 additions & 0 deletions rclrs/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
/// - `use_global_arguments: true`
/// - `arguments: []`
/// - `enable_rosout: true`
/// - `start_parameter_services: true`
/// - `clock_type: ClockType::RosTime`
/// - `clock_qos: QOS_PROFILE_CLOCK`
///
Expand Down Expand Up @@ -49,6 +50,7 @@ pub struct NodeBuilder {
use_global_arguments: bool,
arguments: Vec<String>,
enable_rosout: bool,
start_parameter_services: bool,
clock_type: ClockType,
clock_qos: QoSProfile,
}
Expand Down Expand Up @@ -97,6 +99,7 @@ impl NodeBuilder {
use_global_arguments: true,
arguments: vec![],
enable_rosout: true,
start_parameter_services: true,
clock_type: ClockType::RosTime,
clock_qos: QOS_PROFILE_CLOCK,
}
Expand Down Expand Up @@ -231,6 +234,15 @@ impl NodeBuilder {
self
}

/// Enables or disables parameter services.
///
/// Parameter services can be used to allow external nodes to list, get and set
/// parameters for this node.
pub fn start_parameter_services(mut self, start: bool) -> Self {
self.start_parameter_services = start;
self
}

/// Sets the node's clock type.
pub fn clock_type(mut self, clock_type: ClockType) -> Self {
self.clock_type = clock_type;
Expand Down Expand Up @@ -308,6 +320,9 @@ impl NodeBuilder {
parameter,
});
node.time_source.attach_node(&node);
if self.start_parameter_services {
node.parameter.create_services(&node)?;
}
Ok(node)
}

Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/node/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,16 @@ mod tests {

assert!(subscription_infos.is_empty());

// Test that the graph has no services
// Test that the graph only has 6 services (parameter services)
let names_and_topics = node
.get_service_names_and_types_by_node(node_name, "")
.unwrap();

assert_eq!(names_and_topics.len(), 0);
assert_eq!(names_and_topics.len(), 6);

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

assert_eq!(names_and_topics.len(), 0);
assert_eq!(names_and_topics.len(), 6);

// Test that the graph has no clients
let names_and_topics = node
Expand Down
Loading
Loading