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

[WIP] Action support #410

Draft
wants to merge 61 commits into
base: main
Choose a base branch
from
Draft

[WIP] Action support #410

wants to merge 61 commits into from

Commits on Sep 28, 2024

  1. Configuration menu
    Copy the full SHA
    f6ced1e View commit details
    Browse the repository at this point in the history
  2. Added action template

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    f279041 View commit details
    Browse the repository at this point in the history
  3. Added action generation

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    483164a View commit details
    Browse the repository at this point in the history
  4. Added basic create_action_client function

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    f555bbf View commit details
    Browse the repository at this point in the history
  5. Fix linter

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    a89c196 View commit details
    Browse the repository at this point in the history
  6. Split action client and server examples

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    203b252 View commit details
    Browse the repository at this point in the history
  7. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    0b0bf4d View commit details
    Browse the repository at this point in the history
  8. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    1cc545e View commit details
    Browse the repository at this point in the history
  9. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    9fe3169 View commit details
    Browse the repository at this point in the history
  10. fix visibility

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    e685f83 View commit details
    Browse the repository at this point in the history
  11. Instantiate a new ActionClient

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    1b5dd0c View commit details
    Browse the repository at this point in the history
  12. dded action generation

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    eaa47f1 View commit details
    Browse the repository at this point in the history
  13. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    3740a27 View commit details
    Browse the repository at this point in the history
  14. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    3e4e718 View commit details
    Browse the repository at this point in the history
  15. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    747f05d View commit details
    Browse the repository at this point in the history
  16. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    e1c837c View commit details
    Browse the repository at this point in the history
  17. checkin

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    af46ec4 View commit details
    Browse the repository at this point in the history
  18. Fix missing exported pre_field_serde field

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    3e6fd1b View commit details
    Browse the repository at this point in the history
  19. Removed extra code

    esteve authored and nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    55edf88 View commit details
    Browse the repository at this point in the history
  20. Fix rclrs to compile after rebase

    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 committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    dccc667 View commit details
    Browse the repository at this point in the history
  21. Sketch out action server construction and destruction

    This follows generally the same pattern as the service server. It
    required adding a typesupport function to the Action trait and pulling
    in some more rcl_action bindings.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    573754d View commit details
    Browse the repository at this point in the history
  22. Sketch out action client as well

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    3733e5e View commit details
    Browse the repository at this point in the history
  23. Pass rcl_clock_t from Node to ActionServer

    This is needed to initialize the rcl_action_server_t. In rclcpp, the
    clock ends up stored in the Server itself (by way of ServerBase and
    ServerBaseImpl); we'll see if that ends up being necessary here.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    ac4cc64 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    018ef66 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    279bd8a View commit details
    Browse the repository at this point in the history
  26. Begin implementing ActionServerGoalHandle functions

    So far, none of the implemented functionality actually depends on the
    action type. It could be separated out into a concrete type like is done
    in rclcpp, in case that reduces the cost of monomorphization.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    8b76a0e View commit details
    Browse the repository at this point in the history
  27. Make GoalUuid into a newtype

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    a45b8ba View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    03b9b74 View commit details
    Browse the repository at this point in the history
  29. Add documentation and clean up

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    045a66d View commit details
    Browse the repository at this point in the history
  30. Fix action typesupport function

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    38c5b95 View commit details
    Browse the repository at this point in the history
  31. Take goal, cancel, and accepted callbacks in ActionServer

    I'm not sure that this is actually the signature that we'll want, but
    we'll start from there.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    a323bd0 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    0319419 View commit details
    Browse the repository at this point in the history
  33. Add action client/server entities to wait set

    They still aren't handled in the .wait() method, though.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    b6c8b47 View commit details
    Browse the repository at this point in the history
  34. Handle action server/client readiness in WaitSet and executor

    Currently, action servers and clients that are ready in multiple ways
    are returned to the executor as a list of pairs, with one readiness mode
    per entry. This could alternatively be encoded as a bitfield or similar
    struct, with any given client/server only occurring once in the list.
    However, to ensure that the executor has control over execution order,
    we would need to expose individual `execute_readiness_mode()` methods
    from the client and server, rather than a unified `execute(Mode)`
    method. That's fine too, but something to keep in mind.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    2fbd496 View commit details
    Browse the repository at this point in the history
  35. Add rcl_action error codes

    There's one error code, ActionNameInvalid, that conflicts with the
    EventInvalid code. We should consult with upstream about this, as it
    causes issues for representing error codes as enum values. These two
    error codes are probably never returned by the same function, but it
    would be better to keep them unique.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    d5fc2f3 View commit details
    Browse the repository at this point in the history
  36. Add ActionImpl trait with internal messages and services

    This is incomplete, since the service types aren't yet being generated.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    e72d1c9 View commit details
    Browse the repository at this point in the history
  37. [WIP] Start defining server/client execute functions

    This is just the basic layout. I'm trying to avoid defining the `take_*`
    functions that rclcpp has to link taking messages to executing on them.
    I'm not sure if that's actually worthwhile yet.
    
    This area should also be revisited once it's functional to see whether
    portions can be moved into the non-polymorphic subfunctions. Doing so
    could reduce compile times by avoiding excessive monomorphization.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    02dcc7a View commit details
    Browse the repository at this point in the history
  38. Split srv.rs.em into idiomatic and rmw template files

    This results in the exact same file being produced for services,
    except for some whitespace changes. However, it enables actions to
    invoke the respective service template for its generation, similar to
    how the it works for services and their underlying messages.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    edebb76 View commit details
    Browse the repository at this point in the history
  39. Generate underlying service definitions for actions

    Not tested
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    c9a28f7 View commit details
    Browse the repository at this point in the history
  40. Add runtime trait to get the UUID from a goal request

    C++ uses duck typing for this, knowing that for any `Action`, the type
    `Action::Impl::SendGoalService::Request` will always have a `goal_id`
    field of type `unique_identifier_msgs::msg::UUID` without having to
    prove this to the compiler. Rust's generics are more strict, requiring
    that this be proven using type bounds.
    
    The `Request` type is also action-specific as it contains a `goal` field
    containing the `Goal` message type of the action. We therefore cannot
    enforce that all `Request`s are a specific type in `rclrs`.
    
    This seems most easily represented using associated type bounds on the
    `SendGoalService` associated type within `ActionImpl`. To avoid
    introducing to `rosidl_runtime_rs` a circular dependency on message
    packages like `unique_identifier_msgs`, the `ExtractUuid` trait only
    operates on a byte array rather than a more nicely typed `UUID` message
    type.
    
    I'll likely revisit this as we introduce more similar bounds on the
    generated types.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    dc8781c View commit details
    Browse the repository at this point in the history
  41. Use rcl-allocated goal handle pointer in ServerGoalHandle

    The `rcl_action_accept_new_goal()` function returns a pre-allocated
    `rcl_action_goal_handle_t` pointer, which is also stored within the
    action server proper. This means we cannot store a non-pointer version
    of this in the `ServerGoalHandle`. Instead, we'll keep a mutex-guarded
    mutable pointer. The `Arc` is unnecessary since this pointer is never
    shared with anyone. Also, we need to clean up the goal handle by calling
    `rcl_action_goal_handle_fini()` when the `ServerGoalHandle` is dropped.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    9d6a8b8 View commit details
    Browse the repository at this point in the history
  42. Split execute_goal_request() out into three functions

    The logic in `execute_goal_request()` was starting to get unwieldy, so I
    split it into three functions. The idea is that the first,
    `take_goal_request()`, should handle everything up until we call the
    user's callback. Meanwhile, `send_goal_response()` handles everything
    after the user callback, sending the response and, if accepted, setting
    everything up for the action server. `execute_goal_request()` is the
    overall function coordinating all of this. It passes request data from
    the `take*` function to the user callback and passes the returned
    response into the `send*` function. In addition to splitting the logic
    into digestible pieces, this means we could also easily make the
    goal-request callback asynchronous by delaying the `send*` function
    until the user has given their asynchronous response.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    5425072 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    9595b6e View commit details
    Browse the repository at this point in the history
  44. Add DropGuard convenience wrapper

    This provides a convenient RAII-style way to ensure that a function is
    always called when a specific value gets dropped.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    5496b10 View commit details
    Browse the repository at this point in the history
  45. Complete implementation of ActionServer::publish_status()

    This skips some of the steps that rclcpp performs, as they appear to be
    unnecessary. Testing should reveal whether that's true or not.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    46e7093 View commit details
    Browse the repository at this point in the history
  46. Move goal acceptance logic back into execute_goal_request()

    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.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    b15c0c5 View commit details
    Browse the repository at this point in the history
  47. Integrate RMW message methods into ActionImpl

    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.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    f8fedbc View commit details
    Browse the repository at this point in the history
  48. Add UUID->GoalHandle hash-map to action server

    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.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    241f642 View commit details
    Browse the repository at this point in the history
  49. Add rosidl_runtime_rs::ActionImpl::create_feedback_message()

    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).
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    1e75ce8 View commit details
    Browse the repository at this point in the history
  50. Add ActionServer::publish_feedback() method

    This still needs to be hooked up to the ActionServerGoalHandle, though.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    ea04dcb View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    b06c14c View commit details
    Browse the repository at this point in the history
  52. Implement goal cancel requests

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    249d5ec View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    213f891 View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    a7c45fc View commit details
    Browse the repository at this point in the history
  55. Implement ActionImpl trait methods in generator

    These still don't build without errors, but it's close.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    a33ec48 View commit details
    Browse the repository at this point in the history
  56. Fix formatting in example

    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    e98882f View commit details
    Browse the repository at this point in the history
  57. Hook up ServerGoalHandle callbacks into the ActionServer

    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.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    4ff9fd4 View commit details
    Browse the repository at this point in the history
  58. Replace set_result_response_status with create_result_response

    rclrs needs to be able to generically construct result responses,
    including the user-defined result field.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    d8a0a1d View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    4d597c8 View commit details
    Browse the repository at this point in the history
  60. Hook up goal termination methods for goal handles

    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.
    nwn committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    be5b7e1 View commit details
    Browse the repository at this point in the history
  61. Implement client-side trait methods for action messages

    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 committed Sep 28, 2024
    Configuration menu
    Copy the full SHA
    75fd275 View commit details
    Browse the repository at this point in the history