nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
rclcpp_action::Client< A > Class Template Reference

#include <client.hpp>

Classes

struct  GoalAccept

Public Types

using CancelResponse = detail::Refused<Client>
using FeedbackType = typename A::Feedback
using GoalHandle = ::rclcpp_action::ClientGoalHandle<A>
 Upstream's goal handle for this action (issue 2015).
using GoalType = typename A::Goal
using ResultType = typename A::Result
using SharedPtr = ::rclcpp::Owned<Client>
using WrappedResult = typename GoalHandle::WrappedResult
 Upstream's result wrapper (hosted; refused on a freestanding build).

Public Member Functions

bool action_server_is_ready () const
const char * get_action_name () const
::rclcpp::Result get_result (const ::rclcpp_action::GoalUUID &goal_id, ResultType &result)
 get_result taking a GoalUUID value (phase-417 W4.b).
::rclcpp::Result get_result (const uint8_t goal_id[16], ResultType &result)
template<size_t Cap>
::rclcpp::Result get_result_sized (const uint8_t goal_id[16], ResultType &result)
::rclcpp::Result send_goal (const GoalType &goal, ::rclcpp_action::GoalUUID &goal_id)
::rclcpp::Result send_goal (const GoalType &goal, uint8_t goal_id[16])
template<typename T = void>
::rclcpp::Result wait_for_action_server ()
 REFUSED — wait_for_action_server() with no budget.
::rclcpp::Result wait_for_action_server (uint32_t timeout_ms)

Detailed Description

template<typename A>
class rclcpp_action::Client< A >

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:

RCLCPP_TRY(node.create_action_client(client, "/fibonacci"));
typename decltype(client)::GoalType goal;
goal.order = 10;
uint8_t goal_id[16];
RCLCPP_TRY(client.send_goal(goal, goal_id));
typename decltype(client)::ResultType result;
RCLCPP_TRY(client.get_result(goal_id, result));
Definition client.hpp:256
typename A::Result ResultType
Definition client.hpp:259
typename A::Goal GoalType
Definition client.hpp:258
*rclcpp::Client< AddTwoInts > client
Definition client.hpp:123
#define RCLCPP_TRY(expr)
Definition result.hpp:259

Member Typedef Documentation

◆ CancelResponse

template<typename A>
using rclcpp_action::Client< A >::CancelResponse = detail::Refused<Client>

◆ FeedbackType

template<typename A>
using rclcpp_action::Client< A >::FeedbackType = typename A::Feedback

◆ GoalHandle

Upstream's goal handle for this action (issue 2015).

◆ GoalType

template<typename A>
using rclcpp_action::Client< A >::GoalType = typename A::Goal

◆ ResultType

template<typename A>
using rclcpp_action::Client< A >::ResultType = typename A::Result

◆ SharedPtr

template<typename A>
using rclcpp_action::Client< A >::SharedPtr = ::rclcpp::Owned<Client>

Issue 2015 — upstream's Client<A>::SharedPtr. Not a std::shared_ptr: rclcpp::Owned<Client> holds the client BY VALUE (no allocator), which is what rclcpp_action::create_client returns.

◆ WrappedResult

template<typename A>
using rclcpp_action::Client< A >::WrappedResult = typename GoalHandle::WrappedResult

Upstream's result wrapper (hosted; refused on a freestanding build).

Member Function Documentation

◆ action_server_is_ready()

template<typename A>
bool rclcpp_action::Client< A >::action_server_is_ready ( ) const
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".

◆ get_action_name()

template<typename A>
const char * rclcpp_action::Client< A >::get_action_name ( ) const
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.

◆ get_result() [1/2]

template<typename A>
::rclcpp::Result rclcpp_action::Client< A >::get_result ( const ::rclcpp_action::GoalUUID & goal_id,
ResultType & result )
inline

get_result taking a GoalUUID value (phase-417 W4.b).

◆ get_result() [2/2]

template<typename A>
::rclcpp::Result rclcpp_action::Client< A >::get_result ( const uint8_t goal_id[16],
ResultType & result )
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).

Parameters
goal_id16-byte goal UUID from send_goal().
resultOutput result struct (filled on success).
Returns
Result indicating success, timeout, or failure.

◆ get_result_sized()

template<typename A>
template<size_t Cap>
::rclcpp::Result rclcpp_action::Client< A >::get_result_sized ( const uint8_t goal_id[16],
ResultType & result )
inline

get_result with the receive buffer sized by the CALLER. See Subscription::try_recv_sized (issue 0964).

◆ send_goal() [1/2]

template<typename A>
::rclcpp::Result rclcpp_action::Client< A >::send_goal ( const GoalType & goal,
::rclcpp_action::GoalUUID & goal_id )
inline

send_goal writing the generated id into a GoalUUID value (phase-417 W4.b) — the shape you can put in a map.

◆ send_goal() [2/2]

template<typename A>
::rclcpp::Result rclcpp_action::Client< A >::send_goal ( const GoalType & goal,
uint8_t goal_id[16] )
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.

Parameters
goalGoal to send.
goal_idOutput 16-byte goal UUID (filled on success).
Returns
Result indicating success or failure.

◆ wait_for_action_server() [1/2]

template<typename A>
template<typename T = void>
::rclcpp::Result rclcpp_action::Client< A >::wait_for_action_server ( )
inline

REFUSED — wait_for_action_server() with no budget.

◆ wait_for_action_server() [2/2]

template<typename A>
::rclcpp::Result rclcpp_action::Client< A >::wait_for_action_server ( uint32_t timeout_ms)
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.


The documentation for this class was generated from the following files: