Skip to content

Add deferred service response example - #478

Merged
skyegalaxy merged 1 commit into
ros2:rollingfrom
nobleo:feature/add-deferred-service-response-example
Nov 2, 2026
Merged

skyegalaxy merged 1 commit into
ros2:rollingfrom
nobleo:feature/add-deferred-service-response-example

Conversation

@Rayman

@Rayman Rayman commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Description

I want to implement a service server that defers sending the response. This feature was implemented in
ros2/rclcpp#1709, but I could not find an existing example for this. So with this PR I've added an example.

Please note that the send_reponse call wants a mutable reference to the response. I suspect that is a bug in rclcpp.

Fixes # (issue)

Is this user-facing behavior change?

No

Did you use Generative AI?

Yes, GitHub Copilot on Auto

Additional Information

@Rayman
Rayman force-pushed the feature/add-deferred-service-response-example branch from 26568f6 to 75e4dfd Compare October 28, 2026 09:06
I want to implement a service server that defers sending the response.
This feature was implemented in
ros2/rclcpp#1709, but I could not find an
existing example for this. So with this PR I've added an example.

Signed-off-by: Ramon Wijnands <[email protected]>
@Rayman
Rayman force-pushed the feature/add-deferred-service-response-example branch from 75e4dfd to eee360d Compare October 28, 2026 09:48
@skyegalaxy
skyegalaxy self-requested a review October 29, 2026 16:38
@skyegalaxy

Copy link
Copy Markdown
Member

Pulls: #478
Gist: https://gist.githubusercontent.com/skyegalaxy/7f2f204b3c49061037cd45e9b6cb2b8e/raw/c54b2f2b8f528d74bedb3c084839e46859db930d/ros2.repos
BUILD args: --packages-above-and-dependencies examples_rclcpp_deferred_service
TEST args: --packages-above examples_rclcpp_deferred_service
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20955

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@skyegalaxy
skyegalaxy merged commit 74deefc into ros2:rolling Nov 2, 2026
3 checks passed
@Rayman
Rayman deleted the feature/add-deferred-service-response-example branch November 3, 2026 08:14
ahcorde pushed a commit to ros2/rmw that referenced this pull request Nov 24, 2026
In ros2/examples#478 I've noticed that
rclcpp send_reponse takes a mutable reference to the response. I think
this a bug in the API as you only need a constant reference to serialize
a message. The documentation for rmw verifies that:

  Access to the given ROS service response is read-only but it is not synchronized.
  https://github.com/ros2/rmw/blob/0932be49fb6b3c9a8f3de82cf894bb628d7af59c/rmw/include/rmw/rmw.h#L2403

This bug affects multiple layers, so I'm starting the discussion here if
my assumptions are correct. Can we change the message to a const
reference?

If we want this, this change must be accompanied by changes in the
following packages:
- rmw_implementation
- rmw_fastrtps
  rmw_fastrtps_cpp
- rcl
- rclcpp
- Other rmw implementations (Cyclone DDS, Connext, Zenoh, ...) need the
  same signature change.

The alternative to this is to do a const_cast in rclcpp.

Signed-off-by: Ramon Wijnands <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants