synchros2.action_handle module

class synchros2.action_handle.ActionHandle[source]

Bases: object

Handle for the lifecycle of an action.

Handles the two stage process that is getting a result after sending an ActionGoal to an ActionServer as well as holding the various callbacks for sending an ActionGoal (cancel, failure, feedback, result)

__init__(action_name: str, logger: rclpy.impl.rcutils_logger.RcutilsLogger | None = None, context: rclpy.context.Context | None = None)[source]

Constructor

Parameters:
  • action_name (str) – The name of the action (for logging purposes)

  • logger (Optional[RcutilsLogger]) – An optional logger to use. If none is provided, one is created

  • context (Optional[Context]) – An optional ros context

cancel() None[source]

Send the desire to cancel a command

get_feedback_callback(feedback: Any) None[source]

Public feedback callback that can be given to the ActionClient

Currently just passes the feedback to the user provided callback

property result: Any | None

Returns the result of the action if it has been received from the ActionServer, None otherwise

set_feedback_callback(feedback_callback: Callable[[Any], None]) None[source]

Sets the callback used to process feedback received while an Action is being executed

set_on_cancel_failure_callback(on_cancel_failure_callback: Callable) None[source]

Set the callback to execute upon failing to cancel the action

set_on_cancel_success_callback(on_cancel_success_callback: Callable) None[source]

Set the callback to execute upon successfully canceling the action

set_on_failure_callback(on_failure_callback: Callable) None[source]

Set the callback to execute upon failure

set_result_callback(result_callback: Callable[[Any], None]) None[source]

Sets the callback for processing the result from executing an Action

set_send_goal_future(send_goal_future: rclpy.task.Future) None[source]

Sets the future received from sending the Action.Goal

wait_for_acceptance(timeout_sec: float | None = None) bool[source]

Waits until goal is accepted or timeout.

Parameters:

timeout_sec (Optional[float]) – A timeout in seconds. No timeout is used if None

Returns:

True if successful; False if the timeout was triggered or the goal was rejected

wait_for_result(timeout_sec: float | None = None) bool[source]

Waits until a result is received or times out

A result is received through succeed, abort, or cancel being called on the server.

Parameters:

timeout_sec (Optional[float]) – A timeout in seconds. No timeout is used if None

Returns:

True if successful; False if the timeout was triggered or the action was rejected, cancelled, or abort