Module actionlib.action_client
Action client. This module contains the ActionClient class to call the execution of actions provided by an action server. It reads the given action message specifications and opens the appropriate topics for communication. It is recommended to use the actionlib.action_client()
function to acquire the client.
The ActionClient will connect to an ActionServer via several topics (cf. the actionlib documentation for details). The Lua implementation supports sending an virtually arbitrary number of goals. Each goal is associated with a ClientGoalHandle which provides information about the goal and its current state. Additionally for a goal one or more listeners can be registered to get notified if the state changes or feedback or result messages are received.
Copyright© Tim Niemueller, Carnegie Mellon University, Intel Research Pittsburgh
Release: Released under BSD license
Functions
ActionClient:add_listener (goal_id, listener) | Add listener. |
ActionClient:cancel_all_goals () | Cancel all current goals. |
ActionClient:cancel_goals_before (time) | Cancel all goals before a specific time. |
ActionClient:generate_goal_id () | Generate a unique goal ID. |
ActionClient:has_server () | Check if there is a server for this action client. |
ActionClient:new (o) | Constructor. |
ActionClient:process_feedback (message) | Process feedback. |
ActionClient:process_result (message) | Process result. |
ActionClient:process_status (message) | Process status message. |
ActionClient:remove_listener (goal_id, listener) | Remove listener. |
ActionClient:send_goal (goal, listener) | Send and order execution of a goal. |
ActionClient:wait_for_result () | Wait for result. |
ActionClient:wait_for_server () | Wait for server to appear. |
ClientGoalHandle:add_listener (listener, function) | Add a listener. |
ClientGoalHandle:cancel () | Cancel this goal. |
ClientGoalHandle:canceled () | Check if goal has been canceled. |
ClientGoalHandle:failed () | Check if goal has failed. |
ClientGoalHandle:feedback_received () | Check if feedback has been received. |
ClientGoalHandle:new (o) | Constructor. |
ClientGoalHandle:notify_listeners () | Notify listeners of new event. |
ClientGoalHandle:preempted () | Check if goal was preempted |
ClientGoalHandle:remove_listener (listener) | Remove listener. |
ClientGoalHandle:running () | Check if goal is active |
ClientGoalHandle:set_feedback (feedback) | Set feedback. |
ClientGoalHandle:set_result (result) | Set the result. |
ClientGoalHandle:set_state (state) | Set the state of the state machine. |
ClientGoalHandle:state_changed () | Check if the state has changed. |
ClientGoalHandle:succeeded () | Check if goal succeeded |
ClientGoalHandle:terminal () | Check if goal is in a terminal state. |
ClientGoalHandle:update_status (status, One) | Update the status. |
ClientGoalHandle:waiting_for_cancel_ack () | Check if goal is awaiting cancellation. |
ClientGoalHandle:waiting_for_result () | Check if goal is awaiting result. |
ClientGoalHandle:waiting_for_start_ack () | Check if goal is pending |
Functions
- ActionClient:add_listener (goal_id, listener)
-
Add listener. A listener is a function which is called on events like state changes or incoming feedback with two arguments, the goal handle and the associated action client.
Parameters
- goal_id: the goal ID to register the listener or
- listener: listener to add
- ActionClient:cancel_all_goals ()
- Cancel all current goals.
- ActionClient:cancel_goals_before (time)
-
Cancel all goals before a specific time.
Parameters
- time: time before which all goals shall be canceled
- ActionClient:generate_goal_id ()
-
Generate a unique goal ID.
Return value:
unique goal ID - ActionClient:has_server ()
-
Check if there is a server for this action client.
Return value:
true if an action server exists, false otherwise - ActionClient:new (o)
-
Constructor.
Parameters
- o: Object initializer, must contain the following fields: name namespace for topics type type of action with the string representation of the action name
- ActionClient:process_feedback (message)
-
Process feedback.
Parameters
- message: Appropriately typed feedback message
- ActionClient:process_result (message)
-
Process result.
Parameters
- message: Appropriately typed result message
- ActionClient:process_status (message)
-
Process status message.
Parameters
- message: GoalStatusArray message to process
- ActionClient:remove_listener (goal_id, listener)
-
Remove listener.
Parameters
- goal_id:
- listener: listener to remove
- ActionClient:send_goal (goal, listener)
-
Send and order execution of a goal.
Parameters
- goal: appropriately typed goal message
- listener: listener function for this goal (optional)
Return value:
goal handle for the issued goal - ActionClient:wait_for_result ()
- Wait for result. This method will block and spin the main loop until a result message has been received from the server. Warning, this method may stall if the server dies.
- ActionClient:wait_for_server ()
- Wait for server to appear. To avoids ending goals while there is no server to process them this method can be used to wait until a server appears. Note that this method will block and spin the main loop until this happens, there is no way to interrupt this.
- ClientGoalHandle:add_listener (listener, function)
-
Add a listener.
Parameters
- listener:
- function: which is called with two arguments, the handle and the associated client, on future events.
- ClientGoalHandle:cancel ()
- Cancel this goal.
- ClientGoalHandle:canceled ()
-
Check if goal has been canceled.
Return value:
true if goal has been canceled, i.e. been preempted or recalled, false otherwise - ClientGoalHandle:failed ()
-
Check if goal has failed.
Return value:
true if goal was aborted, preempted, recalled, or rejected, false otherwise - ClientGoalHandle:feedback_received ()
-
Check if feedback has been received.
Return value:
true if feedback has been received in the last spin, false otherwise. - ClientGoalHandle:new (o)
-
Constructor. Do not call this directly. Goal handles are generated by the ActionClient.
Parameters
- o: table which is setup as the object instance and which must have at least the following fields: goal_id the ID of the goal this handle represents client the action client this handle is associated to.
- ClientGoalHandle:notify_listeners ()
- Notify listeners of new event. To be called only by ActionClient.
- ClientGoalHandle:preempted ()
-
Check if goal was preempted
Return value:
true if goal was preempted, false otherwise - ClientGoalHandle:remove_listener (listener)
-
Remove listener.
Parameters
- listener: The listener to remove.
- ClientGoalHandle:running ()
-
Check if goal is active
Return value:
true if goal is active, false otherwise - ClientGoalHandle:set_feedback (feedback)
-
Set feedback. To be called only by ActionClient.
Parameters
- feedback: received feedback message
- ClientGoalHandle:set_result (result)
-
Set the result. This is to be called only by the ActionClient.
Parameters
- result: result message
- ClientGoalHandle:set_state (state)
-
Set the state of the state machine. To be used only internally.
Parameters
- state: new state
- ClientGoalHandle:state_changed ()
-
Check if the state has changed.
Return value:
true if the state has changed in the last spin, false otherwise. - ClientGoalHandle:succeeded ()
-
Check if goal succeeded
Return value:
true if goal succeeded, false otherwise - ClientGoalHandle:terminal ()
-
Check if goal is in a terminal state.
Return value:
true if the goal has succeeded, failed, or canceled - ClientGoalHandle:update_status (status, One)
-
Update the status.
Parameters
- status:
- One: of the GoalStatus constants
- ClientGoalHandle:waiting_for_cancel_ack ()
-
Check if goal is awaiting cancellation.
Return value:
true if goal is preempting or recalling, false otherwise. - ClientGoalHandle:waiting_for_result ()
-
Check if goal is awaiting result.
Return value:
true if the goal has succeeded but the result has not been received, yet, false otherwise. - ClientGoalHandle:waiting_for_start_ack ()
-
Check if goal is pending
Return value:
true if goal is pending, false otherwise