nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
client.hpp File Reference
#include <cstdint>
#include <cstddef>
#include <string.h>
#include "rclcpp/detail/config.hpp"
#include "rclcpp/detail/entity_name.hpp"
#include "rclcpp/logging.hpp"
#include "rclcpp/owned.hpp"
#include "rclcpp/result.hpp"
#include "rclcpp/size_bound.hpp"
#include "rclcpp/future.hpp"
#include "rclcpp/stream.hpp"
#include "rclcpp/time.hpp"
#include "rclcpp_action/server.hpp"
#include "rclcpp_action/detail/upstream.hpp"
#include "rclcpp/detail/nros_cpp_ffi.h"
#include "rclcpp/node.hpp"
Include dependency graph for client.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  rclcpp_action::Client< A >
class  rclcpp_action::ClientGoalHandle< A >
struct  rclcpp_action::Client< A >::GoalAccept
struct  GoalAccept
struct  rclcpp_action::SendGoalOptions

Namespaces

namespace  rclcpp
namespace  rclcpp_action

Typedefs

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
typedef void(* nros_cpp_action_client_cancel_reply_callback_t) (const uint8_t goal_id[16], int64_t seq, const uint8_t *reply, size_t reply_len, void *ctx)
typedef void(* nros_cpp_action_client_feedback_callback_t) (const uint8_t goal_id[16], const uint8_t *data, size_t len, void *ctx)
typedef void(* nros_cpp_action_client_goal_response_callback_t) (bool accepted, const uint8_t goal_id[16], void *ctx)
typedef void(* nros_cpp_action_client_result_callback_t) (const uint8_t goal_id[16], int32_t status, const uint8_t *data, size_t len, void *ctx)
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).

Enumerations

enum class  rclcpp_action::ResultCode : int8_t { rclcpp_action::UNKNOWN = 0 , rclcpp_action::SUCCEEDED = 4 , rclcpp_action::CANCELED = 5 , rclcpp_action::ABORTED = 6 }

Functions

bool action_server_is_ready () const
template<typename T = void, typename... Args>
void rclcpp_action::async_cancel_all_goals (Args &&...)
 REFUSED without std::promise — issue 2027.
template<typename T = void, typename... Args>
void rclcpp_action::async_cancel_goal (Args &&...)
 REFUSED without std::promise — issue 2027.
template<typename T = void, typename... Args>
void rclcpp_action::async_cancel_goals_before (Args &&...)
 REFUSED without std::promise — issue 2027.
template<typename T = void, typename... Args>
void rclcpp_action::async_get_result (Args &&...)
template<typename T = void>
::rclcpp::Future< GoalAccept > rclcpp_action::async_send_goal (const GoalType &, const SendGoalOptions &=SendGoalOptions())
 REFUSED on a freestanding build — issue 2015.
::rclcpp::Result rclcpp_action::cancel_goal (const ::rclcpp_action::GoalUUID &goal_id)
 cancel_goal taking a GoalUUID value (phase-417 W4.b).
::rclcpp::Result rclcpp_action::cancel_goal (const uint8_t goal_id[16])
 rclcpp_action::Client ()
 rclcpp_action::Client (Client &&other)
::rclcpp::Stream< FeedbackType > & rclcpp_action::feedback_stream ()
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)
::rclcpp::Result rclcpp_action::get_result_async (const ::rclcpp_action::GoalUUID &goal_id)
 get_result_async taking a GoalUUID value (phase-417 W4.b).
::rclcpp::Result rclcpp_action::get_result_async (const uint8_t goal_id[16])
::rclcpp::Future< ResultType > rclcpp_action::get_result_future (const ::rclcpp_action::GoalUUID &goal_id)
 get_result_future taking a GoalUUID value (phase-417 W4.b).
::rclcpp::Future< ResultType > rclcpp_action::get_result_future (const uint8_t goal_id[16])
template<size_t Cap>
::rclcpp::Future< ResultType, Cap > rclcpp_action::get_result_future_sized (const uint8_t goal_id[16])
template<size_t Cap>
::rclcpp::Result get_result_sized (const uint8_t goal_id[16], ResultType &result)
template<typename A>
class rclcpp_action::Client rclcpp_action::GOAL (issue 2011)
bool rclcpp_action::is_valid () const
 Check if the action client is initialized and valid.
nros_cpp_ret_t nros_cpp_action_client_set_callbacks (void *handle, nros_cpp_action_client_goal_response_callback_t goal_response, nros_cpp_action_client_feedback_callback_t feedback, nros_cpp_action_client_result_callback_t result, void *context)
nros_cpp_ret_t nros_cpp_action_client_set_cancel_reply_callback (void *handle, nros_cpp_action_client_cancel_reply_callback_t cb)
Client & rclcpp_action::operator= (Client &&other)
void rclcpp_action::poll ()
::rclcpp::Result send_goal (const GoalType &goal, ::rclcpp_action::GoalUUID &goal_id)
::rclcpp::Result send_goal (const GoalType &goal, uint8_t goal_id[16])
::rclcpp::Result rclcpp_action::send_goal_async (const GoalType &goal, ::rclcpp_action::GoalUUID &goal_id)
::rclcpp::Result rclcpp_action::send_goal_async (const GoalType &goal, uint8_t goal_id[16])
::rclcpp::Result rclcpp_action::set_callbacks (const SendGoalOptions &options)
::rclcpp::Result rclcpp_action::try_recv_cancel_response (::rclcpp_action::CancelReturnCode &out)
::rclcpp::Result rclcpp_action::try_recv_feedback (FeedbackType &feedback)
template<size_t Cap>
::rclcpp::Result rclcpp_action::try_recv_feedback_sized (FeedbackType &feedback)
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)
 rclcpp_action::~Client ()

Variables

static const size_t rclcpp_action::CANCEL_STASH_CAP = 4
struct rclcpp_action::SendGoalOptions rclcpp_action::GOAL
static const size_t rclcpp_action::MAX_CANCEL_INFOS = 16

Typedef Documentation

◆ CancelResponse

using CancelResponse = detail::Refused<Client>

◆ FeedbackType

using FeedbackType = typename A::Feedback

◆ GoalHandle

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

◆ GoalType

using GoalType = typename A::Goal

◆ nros_cpp_action_client_cancel_reply_callback_t

typedef void(* nros_cpp_action_client_cancel_reply_callback_t) (const uint8_t goal_id[16], int64_t seq, const uint8_t *reply, size_t reply_len, void *ctx)

Issue 2034 — (goal_id, seq, reply, reply_len, ctx): a cancel reply the executor's spin took, with its request's sequence id and whole frame.

◆ nros_cpp_action_client_feedback_callback_t

typedef void(* nros_cpp_action_client_feedback_callback_t) (const uint8_t goal_id[16], const uint8_t *data, size_t len, void *ctx)

◆ nros_cpp_action_client_goal_response_callback_t

typedef void(* nros_cpp_action_client_goal_response_callback_t) (bool accepted, const uint8_t goal_id[16], void *ctx)

◆ nros_cpp_action_client_result_callback_t

typedef void(* nros_cpp_action_client_result_callback_t) (const uint8_t goal_id[16], int32_t status, const uint8_t *data, size_t len, void *ctx)

◆ ResultType

using ResultType = typename A::Result

◆ SharedPtr

using 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

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

Function Documentation

◆ action_server_is_ready()

bool GOAL::action_server_is_ready ( ) const

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()

const char * GOAL::get_action_name ( ) const

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]

::rclcpp::Result GOAL::get_result ( const ::rclcpp_action::GoalUUID & goal_id,
ResultType & result )

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

◆ get_result() [2/2]

::rclcpp::Result GOAL::get_result ( const uint8_t goal_id[16],
ResultType & result )

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<size_t Cap>
::rclcpp::Result GOAL::get_result_sized ( const uint8_t goal_id[16],
ResultType & result )

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

◆ nros_cpp_action_client_set_callbacks()

nros_cpp_ret_t nros_cpp_action_client_set_callbacks ( void * handle,
nros_cpp_action_client_goal_response_callback_t goal_response,
nros_cpp_action_client_feedback_callback_t feedback,
nros_cpp_action_client_result_callback_t result,
void * context )

◆ nros_cpp_action_client_set_cancel_reply_callback()

nros_cpp_ret_t nros_cpp_action_client_set_cancel_reply_callback ( void * handle,
nros_cpp_action_client_cancel_reply_callback_t cb )

◆ send_goal() [1/2]

::rclcpp::Result GOAL::send_goal ( const GoalType & goal,
::rclcpp_action::GoalUUID & goal_id )

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]

::rclcpp::Result GOAL::send_goal ( const GoalType & goal,
uint8_t goal_id[16] )

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 T = void>
::rclcpp::Result GOAL::wait_for_action_server ( )

REFUSED — wait_for_action_server() with no budget.

◆ wait_for_action_server() [2/2]

::rclcpp::Result GOAL::wait_for_action_server ( uint32_t timeout_ms)

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.