Skip to content

Conversation

@nwn
Copy link
Contributor

@nwn nwn commented Jul 6, 2024

Picking up @esteve's work in #295 to add support for actions.

@Guelakais
Copy link
Contributor

copy of 295

@esteve
Copy link
Collaborator

esteve commented Jul 8, 2024

@Guelakais

copy of 295

No, it's not a copy, @nwn very kindly picked up the work I did in #295 and continued it where I left it.

@esteve
Copy link
Collaborator

esteve commented Jul 8, 2024

@nwn let me know if the message generator is in a more or less complete state and I'll split it off from this PR. Thanks for continuing the work from #295

@Guelakais
Copy link
Contributor

@Guelakais

copy of 295

No, it's not a copy, @nwn very kindly picked up the work I did in #295 and continued it where I left it.

Ah, ok. Sorry

@nwn
Copy link
Contributor Author

nwn commented Jul 13, 2024

@nwn let me know if the message generator is in a more or less complete state and I'll split it off from this PR. Thanks for continuing the work from #295

Thanks, @esteve. There's still some pieces missing, but I'll let you know when it's ready to be split off.

@esteve esteve mentioned this pull request Aug 29, 2024
@mxgrey
Copy link
Collaborator

mxgrey commented Sep 25, 2024

I'll have some time available beginning this week or next week, and I think the most valuable thing I can do for rclrs right now is help to get action generation finished so we can spin out rosidl_generator_rs and get that on the buildfarm.

I'll start by reviewing the current state of the PR and see if I can identify anywhere that I can help, but if @nwn has any guidance on where things could use attention then I'll be happy to take directions.

@nwn
Copy link
Contributor Author

nwn commented Sep 28, 2024

I'll start by reviewing the current state of the PR and see if I can identify anywhere that I can help, but if @nwn has any guidance on where things could use attention then I'll be happy to take directions.

Awesome, thanks @mxgrey! I haven't had the time to do much on this in the past month, but I'll try to organize things a bit so it's clearer what our next steps are.

@nwn nwn force-pushed the nwn-actions branch 2 times, most recently from 9e6f572 to 75fd275 Compare September 28, 2024 19:28
@nwn nwn mentioned this pull request Sep 28, 2024
@nwn
Copy link
Contributor Author

nwn commented Sep 30, 2024

In the interest of breaking this work into smaller pieces and also getting the message generation side merged sooner, I've split off all the rosidl_{generator,runtime}_rs changes into a separate PR, #417. Next, I'll clean this one up and rebase it on top of that branch.

@jonatanolofsson
Copy link

@nwn Would you be able to describe what work remains, or what would enable this feature to move forward? Thank you so much for your contributions to this btw!

@mxgrey
Copy link
Collaborator

mxgrey commented May 15, 2025

@jonatanolofsson We're planning to resume working on actions by building off of #446 so that we can take advantage of async capabilities.

It'll probably take a while for #446 to get through the review process because of how huge the changes are, but I'll probably start prototyping it soon, while the review is still ongoing.

esteve and others added 15 commits June 7, 2025 13:25
Update uses of a `Mutex<rcl_node_t>` with a `NodeHandle`, as was done
elsewhere in the crate. Also, correct the documented UUID size to 16
rather than 24.

The minimal_action_client compiles, but the minimal_action_server does
not yet, complaining about expecting the `rmw` versions of messages
rather than the idiomatic ones.
nwn added 16 commits June 7, 2025 15:36
This provides a convenient RAII-style way to ensure that a function is
always called when a specific value gets dropped.
This skips some of the steps that rclcpp performs, as they appear to be
unnecessary. Testing should reveal whether that's true or not.
This trims the send_goal_response() function down to only be a wrapper
around the rcl_action equivalent. In addition to improving logical
separation, this also simplifies control flow when handling rejection.
Rather than having a bunch of standalone traits implementing various
message functions like `ExtractUuid` and `SetAccepted`, with the
trait bounds on each associated type in `ActionImpl`, we'll instead add
these functions directly to the `ActionImpl` trait. This is simpler on
both the rosidl_runtime_rs and the rclrs side.
This requires a mutex to enable simultaneous goal acceptance in a
multithreaded executor. We also make ServerGoalHandles implement Send
and Sync, since they will be accessed by multiple threads during
callbacks. Due to containing a raw pointer field, the type doesn't
automatically implement Send/Sync; however, we guarantee that the uses
of this pointer is safe and synchronized, allowing us to safely
implement the traits.
Adds a trait method to create a feedback message given the goal ID and
the user-facing feedback message type. Depending on how many times we do
this, it may end up valuable to define a GoalUuid type in
rosidl_runtime_rs itself. We wouldn't be able to utilize the
`RCL_ACTION_UUID_SIZE` constant imported from `rcl_action`, but this is
pretty much guaranteed to be 16 forever.

Defining this method signature also required inverting the super-trait
relationship between Action and ActionImpl. Now ActionImpl is the
sub-trait as this gives it access to all of Action's associated types.
Action doesn't need to care about anything from ActionImpl (hopefully).
This still needs to be hooked up to the ActionServerGoalHandle, though.
These aren't actually implemented as callbacks like in rclcpp, but
rather just regular method calls. This required making some of the
ActionServer and ActionServerBase methods use an Arc receiver, but the
ActionServer is only ever created within an Arc, so this is fine.
These now call into the action server to send a response to prior
(queued) and future goal result requests. There are still some
synchronization tweaks needed for this to be correct.
This adds methods to ActionImpl for creating and accessing
action-specific message types. These are needed by the rclrs
ActionClient to generically read and write RMW messages.

Due to issues with qualified paths in certain places
(rust-lang/rust#86935), the generator now
refers directly to its service and message types rather than going
through associated types of the various traits. This also makes the
generated code a little easier to read, with the trait method signatures
from rosidl_runtime_rs still enforcing type-safety.
nwn added 4 commits June 7, 2025 20:39
Just the bare minimum to get things working after the rebase. Lots of
clean-up still to do.
When compiling the examples that use the action client/server, you got
"undefined reference" errors for any `rcl_action_*` functions during the
linking phase. Telling rustc to link against the rcl_action shared
library fixes this.
This matches the pattern used by the other endpoint structs.
This works similarly to the option struct used for the other endpoint
types, except that it cannot use the PrimitiveOptions stuff since
actions have multiple different QoS settings.
mxgrey added a commit to mxgrey/ros2_rust that referenced this pull request Jul 18, 2025
@mxgrey mxgrey mentioned this pull request Aug 10, 2025
@mxgrey
Copy link
Collaborator

mxgrey commented Aug 10, 2025

I think it would be reasonable to close this PR in favor of #503

I captured the key contributions of this PR and put in a commit to credit @nwn once the PR is squash-merged.

@jonatanolofsson
Copy link

@mxgrey Impressive work! Thank you!

@esteve
Copy link
Collaborator

esteve commented Aug 21, 2025

@nwn thanks for all the hard work, closing in favor of #503

@esteve esteve closed this Aug 21, 2025
esteve added a commit that referenced this pull request Oct 27, 2025
* Remove lockfiles from being tracked

Signed-off-by: Michael X. Grey <[email protected]>

* Port draft action implementation from #410

Signed-off-by: Michael X. Grey <[email protected]>

* Rework readiness for waitables

Signed-off-by: Michael X. Grey <[email protected]>

* Reworking action server goal handle lifecycles

Signed-off-by: Michael X. Grey <[email protected]>

* Fleshing out the state machines for action server goals -- cancelling is WIP

Signed-off-by: Michael X. Grey <[email protected]>

* Finished action server goal state machine API -- need to finish action_server.rs

Signed-off-by: Michael X. Grey <[email protected]>

* Progress on action_server implementation

Signed-off-by: Michael X. Grey <[email protected]>

* Action server finished -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Creating action server and action goal receiver -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Introducing action clients into the wait set processing

Signed-off-by: Michael X. Grey <[email protected]>

* Incorporate action clients into wait sets

Signed-off-by: Michael X. Grey <[email protected]>

* Fleshing out implementation of action clients

Signed-off-by: Michael X. Grey <[email protected]>

* Implementing goal status client

Signed-off-by: Michael X. Grey <[email protected]>

* Implementing goal result client

Signed-off-by: Michael X. Grey <[email protected]>

* CancellationClient API in progress

Signed-off-by: Michael X. Grey <[email protected]>

* Finish action cancellation request API

Signed-off-by: Michael X. Grey <[email protected]>

* Finish API for action clients -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Link against rcl_action

Signed-off-by: Michael X. Grey <[email protected]>

* Add initial tests and improve ergonomics

Signed-off-by: Michael X. Grey <[email protected]>

* Add co-author credit

Co-authored-by: Nathan Wiebe Neufeldt <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>

* Re-export traits from rosidl_runtime_rs

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings to include actions -- added script for automating the binding generation

Signed-off-by: Michael X. Grey <[email protected]>

* Apply cargo fmt

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for kilted

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for humble

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for rolling

Signed-off-by: Michael X. Grey <[email protected]>

* Fix use of serde

Signed-off-by: Michael X. Grey <[email protected]>

* Use desktop image so it includes rcl_action which we need for action bindings

Signed-off-by: Michael X. Grey <[email protected]>

* Fix serde

Signed-off-by: Michael X. Grey <[email protected]>

* Finish documentation for GoalClientStream

Signed-off-by: Michael X. Grey <[email protected]>

* Enable serde for goal status info

Signed-off-by: Michael X. Grey <[email protected]>

* Fix action cancellation pipeline

Signed-off-by: Michael X. Grey <[email protected]>

* More trait re-exports

Signed-off-by: Michael X. Grey <[email protected]>

* Add tests for action cancellation

Signed-off-by: Michael X. Grey <[email protected]>

* Fix use of action client options

Signed-off-by: Michael X. Grey <[email protected]>

* Fix style

Signed-off-by: Michael X. Grey <[email protected]>

* Remove use of .clear_poison because it is not stable in 1.75

Signed-off-by: Michael X. Grey <[email protected]>

* chore: revert bindings-related changes (#5)

Signed-off-by: Esteve Fernandez <[email protected]>

* update rosidl_runtime_rs for action support (#6)

Signed-off-by: Esteve Fernandez <[email protected]>

* revert bindings generation changes

---------

Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Esteve Fernandez <[email protected]>
Co-authored-by: Nathan Wiebe Neufeldt <[email protected]>
Co-authored-by: Esteve Fernandez <[email protected]>
esteve added a commit that referenced this pull request Oct 27, 2025
* Remove lockfiles from being tracked

Signed-off-by: Michael X. Grey <[email protected]>

* Port draft action implementation from #410

Signed-off-by: Michael X. Grey <[email protected]>

* Rework readiness for waitables

Signed-off-by: Michael X. Grey <[email protected]>

* Reworking action server goal handle lifecycles

Signed-off-by: Michael X. Grey <[email protected]>

* Fleshing out the state machines for action server goals -- cancelling is WIP

Signed-off-by: Michael X. Grey <[email protected]>

* Finished action server goal state machine API -- need to finish action_server.rs

Signed-off-by: Michael X. Grey <[email protected]>

* Progress on action_server implementation

Signed-off-by: Michael X. Grey <[email protected]>

* Action server finished -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Creating action server and action goal receiver -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Introducing action clients into the wait set processing

Signed-off-by: Michael X. Grey <[email protected]>

* Incorporate action clients into wait sets

Signed-off-by: Michael X. Grey <[email protected]>

* Fleshing out implementation of action clients

Signed-off-by: Michael X. Grey <[email protected]>

* Implementing goal status client

Signed-off-by: Michael X. Grey <[email protected]>

* Implementing goal result client

Signed-off-by: Michael X. Grey <[email protected]>

* CancellationClient API in progress

Signed-off-by: Michael X. Grey <[email protected]>

* Finish action cancellation request API

Signed-off-by: Michael X. Grey <[email protected]>

* Finish API for action clients -- needs testing

Signed-off-by: Michael X. Grey <[email protected]>

* Link against rcl_action

Signed-off-by: Michael X. Grey <[email protected]>

* Add initial tests and improve ergonomics

Signed-off-by: Michael X. Grey <[email protected]>

* Add co-author credit

Co-authored-by: Nathan Wiebe Neufeldt <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>

* Re-export traits from rosidl_runtime_rs

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings to include actions -- added script for automating the binding generation

Signed-off-by: Michael X. Grey <[email protected]>

* Apply cargo fmt

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for kilted

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for humble

Signed-off-by: Michael X. Grey <[email protected]>

* Update bindings for rolling

Signed-off-by: Michael X. Grey <[email protected]>

* Fix use of serde

Signed-off-by: Michael X. Grey <[email protected]>

* Use desktop image so it includes rcl_action which we need for action bindings

Signed-off-by: Michael X. Grey <[email protected]>

* Fix serde

Signed-off-by: Michael X. Grey <[email protected]>

* Finish documentation for GoalClientStream

Signed-off-by: Michael X. Grey <[email protected]>

* Enable serde for goal status info

Signed-off-by: Michael X. Grey <[email protected]>

* Fix action cancellation pipeline

Signed-off-by: Michael X. Grey <[email protected]>

* More trait re-exports

Signed-off-by: Michael X. Grey <[email protected]>

* Add tests for action cancellation

Signed-off-by: Michael X. Grey <[email protected]>

* Fix use of action client options

Signed-off-by: Michael X. Grey <[email protected]>

* Fix style

Signed-off-by: Michael X. Grey <[email protected]>

* Remove use of .clear_poison because it is not stable in 1.75

Signed-off-by: Michael X. Grey <[email protected]>

* chore: revert bindings-related changes (#5)

Signed-off-by: Esteve Fernandez <[email protected]>

* update rosidl_runtime_rs for action support (#6)

Signed-off-by: Esteve Fernandez <[email protected]>

* revert bindings generation changes

---------

Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Esteve Fernandez <[email protected]>
Co-authored-by: Nathan Wiebe Neufeldt <[email protected]>
Co-authored-by: Esteve Fernandez <[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.

5 participants