Skip to main content

ActionServer

Struct ActionServer 

Source
pub struct ActionServer<A: RosAction, const GOAL_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const RESULT_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const FEEDBACK_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const MAX_GOALS: usize = 4> { /* 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: RosAction, 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>

Source

pub fn try_accept_goal( &mut self, goal_handler: impl FnOnce(&GoalId, &A::Goal) -> GoalResponse, ) -> Result<Option<GoalId>, NodeError>
where A::Goal: Clone,

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.

Source

pub fn publish_feedback( &mut self, goal_id: &GoalId, feedback: &A::Feedback, ) -> Result<(), NodeError>

Publish feedback for a goal.

Source

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.

Source

pub fn complete_goal( &mut self, goal_id: &GoalId, status: GoalStatus, result: A::Result, )

Complete a goal and store the result.

Also publishes the updated GoalStatusArray on the status topic.

Source

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.

Source

pub fn try_handle_get_result(&mut self) -> Result<Option<GoalId>, NodeError>
where A::Result: Clone + Default,

Try to handle a get_result request.

Source

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_goal fires when a new goal arrives.
  • on_cancel fires 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,
    )?;
}
Source

pub fn get_goal(&self, goal_id: &GoalId) -> Option<ActiveGoal<A>>
where A::Goal: Clone,

Get a reference to an active goal.

Source

pub fn active_goal_count(&self) -> usize

Get the number of active goals.

Auto Trait Implementations§

§

impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> Freeze for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>
where <A as RosAction>::Goal: Freeze, <A as RosAction>::Result: Freeze,

§

impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> RefUnwindSafe for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>

§

impl<A, const GOAL_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const RESULT_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const FEEDBACK_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const MAX_GOALS: usize = 4> !Send for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>

§

impl<A, const GOAL_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const RESULT_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const FEEDBACK_BUF: usize = { crate::config::DEFAULT_RX_BUF_SIZE }, const MAX_GOALS: usize = 4> !Sync for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>

§

impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> Unpin for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>
where <A as RosAction>::Goal: Unpin, <A as RosAction>::Result: Unpin,

§

impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> UnsafeUnpin for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>

§

impl<A, const GOAL_BUF: usize, const RESULT_BUF: usize, const FEEDBACK_BUF: usize, const MAX_GOALS: usize> UnwindSafe for ActionServer<A, GOAL_BUF, RESULT_BUF, FEEDBACK_BUF, MAX_GOALS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.