|
EasyFleet
A simple-by-default framework for multi-robot, multi-capability fleets built on ROS 2
|
Comfortable wrapper around rclcpp_action::Client<ActionT>. More...
#include <action_client.hpp>
Classes | |
| struct | GoalResult |
| Terminal outcome of a goal, as delivered to a ResultCallback or returned by send_goal_and_wait(). More... | |
Public Types | |
| enum class | GoalOutcome : uint8_t { SUCCEEDED , ABORTED , CANCELED , REJECTED , TIMEOUT , SERVER_UNAVAILABLE } |
| Outcome of a goal, unifying rejection/timeout/unavailability with the normal terminal states of the action state machine. | |
| using | SharedPtr = std::shared_ptr<ActionClient<ActionT>> |
| Shared pointer to an ActionClient<ActionT>. | |
| using | Goal = typename ActionT::Goal |
| Goal type of the wrapped action. | |
| using | Feedback = typename ActionT::Feedback |
| Feedback type of the wrapped action. | |
| using | Result = typename ActionT::Result |
| Result type of the wrapped action. | |
| using | ClientGoalHandle = typename rclcpp_action::Client<ActionT>::GoalHandle |
| rclcpp_action goal handle type of the wrapped action. | |
| using | FeedbackCallback = std::function<void (std::shared_ptr<const Feedback>)> |
| Callback invoked with feedback as it arrives for an in-flight goal. | |
| using | ResultCallback = std::function<void (const GoalResult &)> |
| Callback invoked once a goal reaches a terminal state. | |
| using | GoalResponseCallback |
| Callback invoked once the server has accepted or rejected a goal. | |
Public Member Functions | |
| ActionClient (const ActionClient &)=delete | |
| ActionClient & | operator= (const ActionClient &)=delete |
| const std::string & | get_action_name () const noexcept |
| The action name this client was created for. | |
| bool | is_server_ready () const |
| Whether the action server is currently reachable. | |
| bool | wait_for_server () |
| Block until the server is reachable, using the constructor's default_server_timeout. | |
| bool | wait_for_server (std::chrono::milliseconds timeout) |
| Block until the server is reachable or timeout elapses. | |
| bool | send_goal (const Goal &goal, ResultCallback result_callback=nullptr, FeedbackCallback feedback_callback=nullptr, GoalResponseCallback goal_response_callback=nullptr) |
| Send a goal without blocking. | |
| GoalResult | send_goal_and_wait (const Goal &goal, FeedbackCallback feedback_callback=nullptr, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
| Send a goal and block the calling thread until it reaches a terminal state (or timeout elapses, if positive). | |
| bool | cancel_goal (const rclcpp_action::GoalUUID &goal_id) |
| Request cancellation of a specific in-flight goal. | |
| void | cancel_all_goals () |
| Request cancellation of every goal currently tracked by this client. | |
| std::size_t | active_goal_count () const |
| Number of goals accepted by the server and not yet in a terminal state. | |
Static Public Member Functions | |
| static SharedPtr | create (rclcpp::Node &parent_node, const std::string &action_name, std::chrono::milliseconds default_server_timeout=std::chrono::seconds(5)) |
| Constructs a new client for action_name, spinning its own internal node in the background. | |
Comfortable wrapper around rclcpp_action::Client<ActionT>.
Each ActionClient<ActionT> owns a small internal node dedicated to a single action and spins it on a background thread for its entire lifetime. This means callers never have to worry about whether their own node's executor is spinning: goals can be sent, results awaited (even synchronously, via send_goal_and_wait()), and feedback/cancel handled, from any thread, independently of how the owning node is executed.
A node typically owns one ActionClient<ActionT>::SharedPtr per action it talks to, created with create().
| using GoalResponseCallback |
Callback invoked once the server has accepted or rejected a goal.
| std::size_t active_goal_count | ( | ) | const |
Number of goals accepted by the server and not yet in a terminal state.
| bool cancel_goal | ( | const rclcpp_action::GoalUUID & | goal_id | ) |
Request cancellation of a specific in-flight goal.
Returns false if the goal is unknown (already terminal, or never accepted).
| goal_id | Id of the goal to cancel. |
|
static |
Constructs a new client for action_name, spinning its own internal node in the background.
| parent_node | Node on whose behalf the action is called; only used to inherit its namespace and to derive a name for the internal node (never stored), so a reference – never null, unlike a pointer – is all this needs. |
| action_name | Name of the action to call. |
| default_server_timeout | Timeout used by the no-argument overload of wait_for_server(). |
|
noexcept |
The action name this client was created for.
| bool is_server_ready | ( | ) | const |
Whether the action server is currently reachable.
| bool send_goal | ( | const Goal & | goal, |
| ResultCallback | result_callback = nullptr, | ||
| FeedbackCallback | feedback_callback = nullptr, | ||
| GoalResponseCallback | goal_response_callback = nullptr ) |
Send a goal without blocking.
Returns false immediately (without contacting the server) if it is not currently reachable; in that case, result_callback, if any, is invoked synchronously with GoalOutcome::SERVER_UNAVAILABLE.
| goal | Goal to send. |
| result_callback | Invoked once the goal reaches a terminal state. |
| feedback_callback | Invoked as feedback arrives for this goal. |
| goal_response_callback | Invoked once the server accepts/rejects the goal. |
| ActionClient< ActionT >::GoalResult send_goal_and_wait | ( | const Goal & | goal, |
| FeedbackCallback | feedback_callback = nullptr, | ||
| std::chrono::milliseconds | timeout = std::chrono::milliseconds(0) ) |
Send a goal and block the calling thread until it reaches a terminal state (or timeout elapses, if positive).
Safe to call from any thread, including one that also spins the owning node: this object spins its own dedicated internal node to drive the exchange.
| goal | Goal to send. |
| feedback_callback | Invoked as feedback arrives for this goal. |
| timeout | Maximum time to wait for a terminal state; 0 (the default) waits indefinitely. |
| bool wait_for_server | ( | ) |
Block until the server is reachable, using the constructor's default_server_timeout.
| bool wait_for_server | ( | std::chrono::milliseconds | timeout | ) |
Block until the server is reachable or timeout elapses.
| timeout | Maximum time to wait. |