|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <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 | ::rclcpp::Node |
Typed action client for a ROS 2 action.
Mirrors upstream's 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 the arena entry (issue 1496).
The ActionClientCore with its three service clients and its feedback subscription lives in an ActionClientRawArenaEntry in the executor arena, whose callback context is storage_. nros_cpp_action_client_destroy (which needs no extra argument: CppActionClient keeps its own executor pointer and entry index) drops that entry in place — the entities are destroyed, so no late reply can read this storage — frees its callback slot and returns its arena bytes for reuse, so a create/destroy loop does not exhaust the executor.
|
inline |
Default constructor — creates an uninitialized action client. Use Node::create_action_client() to initialize.
|
inline |
Is an action server for this action visible right now? — phase-417 W4.b.
rclcpp_action::ClientBase::action_server_is_ready, the NON-BLOCKING half of wait_for_action_server. C has had rclc_action_client_action_server_is_ready and Rust ActionClient::action_server_is_ready since phase-338; C++ had neither, so the only way to ask here was to block (ledger row cpp:Client::action_server_is_ready, a C++-only gap rather than a decision).
Spins nothing, so unlike wait_for_action_server it is legal inside a callback. Its answer is a SNAPSHOT: false means "not visible yet", never "will not appear".
|
inline |
cancel_goal taking a GoalUUID value (phase-417 W4.b).
|
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 rclc_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 |
Read back the action name this client was created on — phase-417 W4.b.
The client half of "four surfaces, one accessor" (ledger row c:action_client_get_action_name); see rclcpp_action::Server<A>::get_action_name for why the 256-byte copy is where it is. Returns "" (never NULL) on an uninitialised client.
|
inline |
get_result taking a GoalUUID value (phase-417 W4.b).
|
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 |
get_result_async taking a GoalUUID value (phase-417 W4.b).
|
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 |
get_result_future taking a GoalUUID value (phase-417 W4.b).
|
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 |
|
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).
Upstream's async_send_goal returns a std::shared_future of a goal handle. This one blocks and reports through Result plus an out-param goal id: no future and no goal handle (RFC-0021: no async runtime, no allocator). The future-shaped spelling is send_goal_future, over rclcpp::Future.
| goal | Goal to send. |
| goal_id | Output 16-byte goal UUID (filled on success). |
|
inline |
send_goal_async writing the generated id into a GoalUUID value (phase-417 W4.b).
|
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.
Binds the callbacks to the CLIENT, not to one goal: rclcpp passes a SendGoalOptions to each async_send_goal, while here they are installed once and serve every goal this client sends (RFC-0041: callbacks bind to the entity). The pointers are read when a reply is DISPATCHED, so install them before the spin that delivers the reply — before or after send_goal_async both work.
| 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 |
REFUSED — wait_for_action_server() with no budget.
|
inline |
phase-338 W8 — block until the action server is discoverable.
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. Returns Unsupported at once when the backend cannot know whether a server is up (XRCE — issue 1686); a caller that may send blind proceeds.
The budget is REQUIRED — phase-417 stage 3, the same defect and the same fix as Client::wait_for_service; they were found together and are corrected together, under one message. Upstream's rclcpp_action::Client::wait_for_action_server(timeout = -1) waits forever; this used to substitute 5000 ms for an argument-free call, silently. RFC-0021 is why the unbounded form does not exist here, and NROS_RCLCPP_REFUSE_UNBOUNDED_WAIT is what a ported caller now reads.
Takes uint32_t MILLISECONDS, not a std::chrono::duration, and returns Result (timeout vs. not-initialised by code), not bool.
|
friend |