Skip to content

Commit b9a45bf

Browse files
committed
Show how to enable service introspection
1 parent e7c18ef commit b9a45bf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

rclrs/minimal_client_service/src/minimal_client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ fn main() -> Result<(), Error> {
99

1010
let client = node.create_client::<AddTwoInts>("add_two_ints")?;
1111

12+
// Enable introspection for this client
13+
// if you want to be able to introspect the service calls e.g. with ros2 service echo
14+
client.configure_introspection(ServiceIntrospectionState::Contents)?;
15+
1216
let promise = executor.commands().run(async move {
1317
println!("Waiting for service...");
1418
client.notify_on_service_ready().await.unwrap();

rclrs/minimal_client_service/src/minimal_service.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ fn main() -> Result<(), Error> {
1919

2020
let node = executor.create_node("minimal_service")?;
2121

22-
let _server = node.create_service::<AddTwoInts, _>("add_two_ints", handle_service)?;
22+
let server = node.create_service::<AddTwoInts, _>("add_two_ints", handle_service)?;
23+
24+
// Enable introspection for this service
25+
// if you want to be able to introspect the service calls e.g. with ros2 service echo
26+
server.configure_introspection(ServiceIntrospectionState::Contents)?;
2327

2428
println!("Starting server");
2529
executor.spin(SpinOptions::default()).first_error()?;

0 commit comments

Comments
 (0)