Package smach_ros :: Module simple_action_state :: Class SimpleActionState

Class SimpleActionState

source code


Simple action client state.

Use this class to represent an actionlib as a state in a state machine.

Instance Methods
 
__init__(self, action_name, action_spec, goal=None, goal_key=None, goal_slots=[], goal_cb=None, goal_cb_args=[], goal_cb_kwargs={}, result_key=None, result_slots=[], result_cb=None, result_cb_args=[], result_cb_kwargs={}, input_keys=[], output_keys=[], outcomes=[], exec_timeout=None, preempt_timeout=rospy.Duration(60.0), server_wait_timeout=rospy.Duration(60.0))
Constructor for SimpleActionState action client wrapper.
source code
 
request_preempt(self)
Sets preempt_requested to True
source code
 
execute(self, ud)
Called when executing a state.
source code

Inherited from smach.state.State: get_registered_input_keys, get_registered_outcomes, get_registered_output_keys, preempt_requested, recall_preempt, register_input_keys, register_io_keys, register_outcomes, register_output_keys, service_preempt

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  WAITING_FOR_SERVER = 0
  INACTIVE = 1
  ACTIVE = 2
  PREEMPTING = 3
  COMPLETED = 4
Properties

Inherited from object: __class__

Method Details

__init__(self, action_name, action_spec, goal=None, goal_key=None, goal_slots=[], goal_cb=None, goal_cb_args=[], goal_cb_kwargs={}, result_key=None, result_slots=[], result_cb=None, result_cb_args=[], result_cb_kwargs={}, input_keys=[], output_keys=[], outcomes=[], exec_timeout=None, preempt_timeout=rospy.Duration(60.0), server_wait_timeout=rospy.Duration(60.0))
(Constructor)

source code 

Constructor for SimpleActionState action client wrapper.

Parameters:
  • action_name (string) - The name of the action as it will be broadcast over ros.
  • action_spec (actionlib action msg) - The type of action to which this client will connect.
  • goal (actionlib goal msg) - If the goal for this action does not need to be generated at runtime, it can be passed to this state on construction.
  • goal_key (string) - Pull the goal message from a key in the userdata. This will be done before calling the goal_cb if goal_cb is defined.
  • goal_slots (list of string) - Pull the goal fields (__slots__) from like-named keys in userdata. This will be done before calling the goal_cb if goal_cb is defined.
  • goal_cb (callable) - If the goal for this action needs to be generated at runtime, a callback can be stored which modifies the default goal object. The callback is passed two parameters:
    • userdata
    • current stored goal

    The callback returns a goal message.

  • result_key (string) - Put the result message into the userdata with the given key. This will be done after calling the result_cb if result_cb is defined.
  • result_slots (list of strings) - Put the result message fields (__slots__) into the userdata with keys like the field names. This will be done after calling the result_cb if result_cb is defined.
  • result_cb (callable) - If result information from this action needs to be stored or manipulated on reception of a result from this action, a callback can be stored which is passed this information. The callback is passed three parameters:
    • userdata (UserData)
    • result status (actionlib.GoalStatus)
    • result (actionlib result msg)
  • exec_timeout (rospy.Duration) - This is the timeout used for sending a preempt message to the delegate action. This is None by default, which implies no timeout.
  • preempt_timeout (rospy.Duration) - This is the timeout used for aborting after a preempt has been sent to the action and no result has been received. This timeout begins counting after a preempt message has been sent.
  • server_wait_timeout (rospy.Duration) - This is the timeout used for aborting while waiting for an action server to become active.
Overrides: object.__init__

request_preempt(self)

source code 

Sets preempt_requested to True

Overrides: smach.state.State.request_preempt
(inherited documentation)

execute(self, ud)

source code 

Called when executing a state. This calls the goal_cb if it is defined, and then dispatches the goal with a non-blocking call to the action client.

Parameters:
  • ud - Userdata for the scope in which this state is executing
Overrides: smach.state.State.execute