|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <action_client.hpp>
Classes | |
| struct | GoalAccept |
| struct | SendGoalOptions |
Public Types | |
| using | FeedbackType = typename A::Feedback |
| using | GoalType = typename A::Goal |
| using | ResultType = typename A::Result |
Friends | |
| class | Node |
Typed action client for a ROS 2 action.
Mirrors rclcpp_action::Client<A>. The action type A must provide nested Goal, Result, and Feedback types with TYPE_NAME, TYPE_HASH, SERIALIZED_SIZE_MAX, ffi_serialize(), and ffi_deserialize().
Usage:
|
inline |
Destructor — releases action client resources.
|
inline |
|
inline |
Default constructor — creates an uninitialized action client. Use Node::create_action_client() to initialize.
|
inline |
Cancel a goal (non-blocking) — issue 0796.
Sends the action_msgs/srv/CancelGoal request and returns; read the RPC outcome with try_recv_cancel_response() once the executor has spun. Mirrors C's nros_action_cancel_goal and Rust's ActionClient::cancel_goal — rclcpp_action's async_cancel_goal returns a future, which RFC-0021 has no runtime to await.
Until this existed, a C++ application written against the CALLBACK tier could start a goal and had no way to stop it: cancel was only on the L1 PollingActionClient::send_cancel_request.
| goal_id | 16-byte goal UUID from send_goal() / send_goal_async(). |
|
inline |
Get a reference to the action client's feedback stream.
The stream yields FeedbackType values across all currently-active goals for this client — feedback is not goal-scoped at this layer. Callers that need per-goal separation should use the callback API (set_callbacks(SendGoalOptions{ .feedback = … })), which delivers (goal_id, bytes, len, ctx) via an executor-driven trampoline.
Usage (blocking):
Usage (non-blocking):
|
inline |
|
inline |
Get the result for a goal (blocking with timeout).
Sends a get_result request and spins the executor until a reply arrives or timeout (Phase 82 compliant – drives the executor).
| goal_id | 16-byte goal UUID from send_goal(). |
| result | Output result struct (filled on success). |
|
inline |
Request the result for a goal asynchronously (non-blocking).
Returns immediately after sending the get_result request. The result arrives via the result callback during poll().
| goal_id | 16-byte goal UUID from send_goal_async(). |
|
inline |
Request a goal result and return a Future for the result.
Sends the get_result request asynchronously and returns a Future that resolves when the result arrives. Poll the future (or call wait()) to retrieve the deserialized result.
Usage:
| goal_id | 16-byte goal UUID from send_goal() or GoalAccept. |
|
inline |
get_result_future with the RESULT buffer sized by the caller.
A Future<T> holds its receive buffer as a member, so the capacity is a class template argument: this returns Future<ResultType, Cap> (issue 0964).
|
inline |
get_result with the receive buffer sized by the CALLER. See Subscription::try_recv_sized (issue 0964).
|
inline |
Check if the action client is initialized and valid.
|
inline |
|
inline |
Poll for pending async replies (non-blocking).
Checks for goal acceptance, feedback, and result replies. Invokes the corresponding callbacks registered via set_callbacks(). Call this in the spin loop after spin_once().
|
inline |
Send a goal asynchronously (non-blocking).
Returns immediately after sending the goal request. The goal UUID is filled on success. Responses arrive via callbacks registered with the executor (see SendGoalOptions and Node::create_action_client).
| goal | Goal to send. |
| goal_id | Output 16-byte goal UUID (filled on success). |
|
inline |
Send a goal and return a Future for the acceptance response.
Returns immediately after sending the goal request. Poll the returned future (or call wait()) to get the GoalAccept result.
Usage:
| goal | Goal to send. |
|
inline |
Register async callbacks for goal response, feedback, and result.
| options | Callback pointers and context. |
|
inline |
Try to read the reply to a cancel_goal() (non-blocking).
| out | Receives the RPC return code on success. |
|
inline |
Try to receive feedback (non-blocking).
| feedback | Output feedback struct (filled on success). |
|
inline |
try_recv_feedback with the receive buffer sized by the CALLER. See Subscription::try_recv_sized (issue 0964).
|
inline |
Send a goal and receive the generated goal UUID (blocking).
Internally spins the executor until the server accepts or rejects the goal (Phase 82 compliant – drives the executor).
| goal | Goal to send. |
| goal_id | Output 16-byte goal UUID (filled on success). |
Mirrors rclcpp_action::Client::wait_for_action_server. Probes the send_goal queryable, which is the load-bearing entity for the first send_goal(). Prefer this over retrying send_goal() on timeout: it waits for the real condition and re-probes, so a server that comes up after the wait starts is still seen.
Spins the executor while probing — not for use inside a callback.