pub struct ActionServer<A, const GOAL_BUF: usize = nros_node::::executor::handles::ActionServer::{constant#0}, const RESULT_BUF: usize = nros_node::::executor::handles::ActionServer::{constant#1}, const FEEDBACK_BUF: usize = nros_node::::executor::handles::ActionServer::{constant#2}, const MAX_GOALS: usize = 4>where
A: RosAction,{ /* private fields */ }Expand description
Typed action server with goal state management.
Wraps ActionServerCore for
raw-bytes protocol handling, adding typed goal/feedback/result
serialization at the boundary.
Implementations§
Source§impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>where
A: RosAction,
impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>where
A: RosAction,
Sourcepub fn try_accept_goal(
&mut self,
goal_handler: impl FnOnce(&GoalId, &<A as RosAction>::Goal) -> GoalResponse,
) -> Result<Option<GoalId>, NodeError>
pub fn try_accept_goal( &mut self, goal_handler: impl FnOnce(&GoalId, &<A as RosAction>::Goal) -> GoalResponse, ) -> Result<Option<GoalId>, NodeError>
Try to accept a new goal.
Checks for incoming send_goal requests. If one is available, calls the handler to decide acceptance. Returns the goal ID if accepted.
Sourcepub fn publish_feedback(
&mut self,
goal_id: &GoalId,
feedback: &<A as RosAction>::Feedback,
) -> Result<(), NodeError>
pub fn publish_feedback( &mut self, goal_id: &GoalId, feedback: &<A as RosAction>::Feedback, ) -> Result<(), NodeError>
Publish feedback for a goal.
Sourcepub fn set_goal_status(&mut self, goal_id: &GoalId, status: GoalStatus)
pub fn set_goal_status(&mut self, goal_id: &GoalId, status: GoalStatus)
Set a goal’s status.
Also publishes the updated GoalStatusArray on the status topic.
Sourcepub fn complete_goal(
&mut self,
goal_id: &GoalId,
status: GoalStatus,
result: <A as RosAction>::Result,
)
pub fn complete_goal( &mut self, goal_id: &GoalId, status: GoalStatus, result: <A as RosAction>::Result, )
Complete a goal and store the result.
Also publishes the updated GoalStatusArray on the status topic.
Sourcepub fn try_handle_cancel(
&mut self,
cancel_handler: impl FnOnce(&GoalId, GoalStatus) -> CancelResponse,
) -> Result<Option<(GoalId, CancelResponse)>, NodeError>
pub fn try_handle_cancel( &mut self, cancel_handler: impl FnOnce(&GoalId, GoalStatus) -> CancelResponse, ) -> Result<Option<(GoalId, CancelResponse)>, NodeError>
Try to handle a cancel_goal request.
Sourcepub fn try_handle_get_result(&mut self) -> Result<Option<GoalId>, NodeError>
pub fn try_handle_get_result(&mut self) -> Result<Option<GoalId>, NodeError>
Try to handle a get_result request.
Sourcepub fn poll<GF, CF>(
&mut self,
on_goal: GF,
on_cancel: CF,
) -> Result<(), NodeError>
pub fn poll<GF, CF>( &mut self, on_goal: GF, on_cancel: CF, ) -> Result<(), NodeError>
Drain all pending server-side work in one call.
Calls try_accept_goal, try_handle_cancel, and
try_handle_get_result in sequence. Invoke this on every
spin_once iteration in manual-poll code — otherwise clients
will hang on get_result because create_action_server()
servers are not arena-registered.
The two callbacks may be called zero or one times per poll():
on_goalfires when a new goal arrives.on_cancelfires when a cancel request arrives.
Get-result requests are drained unconditionally (no callback needed — the result is pulled from the goal’s stored state).
§Example
let mut server = node.create_action_server::<Fibonacci>("/fibonacci")?;
loop {
executor.spin_once(Duration::from_millis(10));
server.poll(
|id, goal| {
/* accept or reject based on `goal` */
GoalResponse::AcceptAndExecute
},
|_id, _status| CancelResponse::Accept,
)?;
}Sourcepub fn get_goal(&self, goal_id: &GoalId) -> Option<ActiveGoal<A>>
pub fn get_goal(&self, goal_id: &GoalId) -> Option<ActiveGoal<A>>
Get a reference to an active goal.
Sourcepub fn active_goal_count(&self) -> usize
pub fn active_goal_count(&self) -> usize
Get the number of active goals.