pub struct ActionServerHandle<A>where
A: RosAction,{ /* private fields */ }Expand description
Handle to an action server registered in the executor’s arena.
Returned by Executor::register_action_server(). Provides methods
to interact with the server (publish feedback, complete goals) while the
executor automatically handles goal acceptance, cancel requests, and
result serving during spin_once().
Implementations§
Source§impl<A> ActionServerHandle<A>where
A: RosAction,
impl<A> ActionServerHandle<A>where
A: RosAction,
Sourcepub fn handle_id(&self) -> HandleId
pub fn handle_id(&self) -> HandleId
Get the HandleId for this action server.
Used with Trigger::One or HandleSet for trigger configuration.
Sourcepub fn publish_feedback(
&self,
executor: &mut Executor<'_>,
goal_id: &GoalId,
feedback: &<A as RosAction>::Feedback,
) -> Result<(), NodeError>
pub fn publish_feedback( &self, executor: &mut Executor<'_>, goal_id: &GoalId, feedback: &<A as RosAction>::Feedback, ) -> Result<(), NodeError>
Publish feedback for an active goal.
Serialises the feedback message and sends it to all clients monitoring this goal. Returns an error if the handle slot has been removed from the executor.
Sourcepub fn succeed(
&self,
executor: &mut Executor<'_>,
goal_id: &GoalId,
result: <A as RosAction>::Result,
) -> Result<(), NodeError>
pub fn succeed( &self, executor: &mut Executor<'_>, goal_id: &GoalId, result: <A as RosAction>::Result, ) -> Result<(), NodeError>
Complete a goal with a terminal status and result payload.
The goal is moved from the active set to the completed-results
slab. Clients waiting on a result will receive the response.
status should be one of Succeeded, Aborted, or Canceled.
§Errors
NodeError::BufferTooSmall when the handle slot has been removed from
the executor, or when the serialized result exceeds the server’s
RESULT_BUF and so cannot be retained for a later get_result (issue
0796 — this used to return () and swallow both).
Terminate goal_id as SUCCEEDED — phase-379 W5.
The three terminal verbs (succeed / abort / cancel) name the
ACTION SPEC’s terminal states, which is also what rclcpp_action’s
ServerGoalHandle spells them: succeed(result), abort(result),
canceled(result). They take the goal ID rather than hanging off a
handle because a goal here lives in a fixed-capacity arena and is named
by its UUID — see the divergence row for why neither client library’s
ownership model is available without an allocator.
complete_goal remains the general form for a status computed at
runtime.
Sourcepub fn abort(
&self,
executor: &mut Executor<'_>,
goal_id: &GoalId,
result: <A as RosAction>::Result,
) -> Result<(), NodeError>
pub fn abort( &self, executor: &mut Executor<'_>, goal_id: &GoalId, result: <A as RosAction>::Result, ) -> Result<(), NodeError>
Terminate goal_id as ABORTED. See Self::succeed.
Sourcepub fn cancel(
&self,
executor: &mut Executor<'_>,
goal_id: &GoalId,
result: <A as RosAction>::Result,
) -> Result<(), NodeError>
pub fn cancel( &self, executor: &mut Executor<'_>, goal_id: &GoalId, result: <A as RosAction>::Result, ) -> Result<(), NodeError>
Terminate goal_id as CANCELED. See Self::succeed.
Spelled cancel, not rclcpp’s canceled: the other two are imperatives
(succeed, abort), and mixing an imperative with a past participle
inside one family reads as an accident. The SPEC state is CANCELED
either way.
pub fn complete_goal( &self, executor: &mut Executor<'_>, goal_id: &GoalId, status: GoalStatus, result: <A as RosAction>::Result, ) -> Result<(), NodeError>
Sourcepub fn set_goal_status(
&self,
executor: &mut Executor<'_>,
goal_id: &GoalId,
status: GoalStatus,
)
pub fn set_goal_status( &self, executor: &mut Executor<'_>, goal_id: &GoalId, status: GoalStatus, )
Update a goal’s status without completing it.
Use this to transition a goal to Executing or Canceling
while it is still active. To finish a goal, use complete_goal.
Sourcepub fn active_goal_count(&self, executor: &Executor<'_>) -> usize
pub fn active_goal_count(&self, executor: &Executor<'_>) -> usize
Get the number of currently active goals.
Returns 0 if the action server handle has been removed from the executor.
Sourcepub fn for_each_active_goal(
&self,
executor: &Executor<'_>,
f: impl FnMut(&ActiveGoal<A>),
)
pub fn for_each_active_goal( &self, executor: &Executor<'_>, f: impl FnMut(&ActiveGoal<A>), )
Iterate over all currently active goals.
Calls f for each goal that has been accepted but not yet
completed. Useful for monitoring progress or canceling stale goals.
Trait Implementations§
Source§impl<A> Clone for ActionServerHandle<A>where
A: RosAction,
impl<A> Clone for ActionServerHandle<A>where
A: RosAction,
Source§fn clone(&self) -> ActionServerHandle<A>
fn clone(&self) -> ActionServerHandle<A>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more