Class: ActionServer

ActionServer(node, typeClass, actionName, executeCallback, goalCallback, handleAcceptedCallback, cancelCallback, options)

- ROS Action server.

Constructor

new ActionServer(node, typeClass, actionName, executeCallback, goalCallback, handleAcceptedCallback, cancelCallback, options)

Creates a new action server.
Parameters:
Name Type Description
node Node The ROS node to add the action server to.
typeClass function | string | object Type of the action.
actionName string Name of the action. Used as part of the underlying topic and service names.
executeCallback function Callback function for processing accepted goals.
goalCallback function Callback function for handling new goal requests.
handleAcceptedCallback function Callback function for handling newly accepted goals.
cancelCallback function Callback function for handling cancel requests.
options object Action server options.
Properties
Name Type Description
resultTimeout number How long in seconds a result is kept by the server after a goal reaches a terminal state in seconds, default: 900.
enableTypedArray boolean The topic will use TypedArray if necessary, default: true.
qos object ROS Middleware "quality of service" options.
Properties
Name Type Description
goalServiceQosProfile QoS Quality of service option for the goal service, default: QoS.profileServicesDefault.
resultServiceQosProfile QoS Quality of service option for the result service, default: QoS.profileServicesDefault.
cancelServiceQosProfile QoS Quality of service option for the cancel service, default: QoS.profileServicesDefault..
feedbackSubQosProfile QoS Quality of service option for the feedback subscription, default: new QoS(QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT, 10).
statusSubQosProfile QoS Quality of service option for the status subscription, default: QoS.profileActionStatusDefault.
Source:

Methods

destroy() → {undefined}

Destroy the action server and all goals.
Source:
Returns:
Type
undefined

registerCancelCallback(cancelCallback) → {undefined}

Register a callback for handling cancel requests. The purpose of the cancel callback is to decide if a request to cancel an on-going (or queued) goal should be accepted or rejected. The callback should take one parameter containing the cancel request and must return a CancelResponse value. There can only be one cancel callback per ActionServer, therefore calling this function will replace any previously registered callback.
Parameters:
Name Type Description
cancelCallback function Callback function, if not provided, then unregisters any previously registered callback.
Source:
Returns:
Type
undefined

registerExecuteCallback(executeCallback) → {undefined}

Register a callback for executing action goals. The purpose of the execute callback is to execute the action goal and return a result when finished. The callback should take one parameter containing goal request and must return a result instance (i.e. `action_type.Result`). There can only be one execute callback per ActionServer, therefore calling this function will replace any previously registered callback.
Parameters:
Name Type Description
executeCallback function Callback function.
Source:
Returns:
Type
undefined

registerGoalCallback(goalCallback) → {undefined}

Register a callback for handling new goal requests. The purpose of the goal callback is to decide if a new goal should be accepted or rejected. The callback should take the goal request message as a parameter and must return a GoalResponse value.
Parameters:
Name Type Description
goalCallback function Callback function, if not provided, then unregisters any previously registered callback.
Source:
Returns:
Type
undefined

registerHandleAcceptedCallback(handleAcceptedCallback) → {undefined}

Register a callback for handling newly accepted goals. The provided function is called whenever a new goal has been accepted by this action server. The function should expect an instance of ServerGoalHandle as an argument, which represents a handle to the goal that was accepted. The goal handle can be used to interact with the goal, e.g. publish feedback, update the status, or execute a deferred goal. There can only be one handle accepted callback per ActionServer, therefore calling this function will replace any previously registered callback.
Parameters:
Name Type Description
handleAcceptedCallback function Callback function, if not provided, then unregisters any previously registered callback.
Source:
Returns:
Type
undefined