Package smach :: Module state :: Class State

Class State

source code


Base class for SMACH states.

A SMACH state interacts with SMACH containers in two ways. The first is its outcome identifier, and the second is the set of userdata variables which it reads from and writes to at runtime. Both of these interactions are declared before the state goes active (when its execute() method is called) and are checked during construction.

Instance Methods
 
__init__(self, outcomes=[], input_keys=[], output_keys=[], io_keys=[])
State constructor
source code
 
execute(self, ud)
Called when executing a state.
source code
 
register_outcomes(self, new_outcomes)
Add outcomes to the outcome set.
source code
tuple of string
get_registered_outcomes(self)
Get a list of registered outcomes.
source code
 
register_io_keys(self, keys)
Add keys to the set of keys from which this state may read and write.
source code
 
register_input_keys(self, keys)
Add keys to the set of keys from which this state may read.
source code
 
get_registered_input_keys(self)
Get a tuple of registered input keys.
source code
 
register_output_keys(self, keys)
Add keys to the set of keys to which this state may write.
source code
 
get_registered_output_keys(self)
Get a tuple of registered output keys.
source code
 
request_preempt(self)
Sets preempt_requested to True
source code
 
service_preempt(self)
Sets preempt_requested to False
source code
 
recall_preempt(self)
Sets preempt_requested to False
source code
 
preempt_requested(self)
True if a preempt has been requested.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, outcomes=[], input_keys=[], output_keys=[], io_keys=[])
(Constructor)

source code 

State constructor

Parameters:
  • outcomes (array of strings) - Custom outcomes for this state.
  • input_keys (array of strings) - The userdata keys from which this state might read at runtime.
  • output_keys (array of strings) - The userdata keys to which this state might write at runtime.
  • io_keys (array of strings) - The userdata keys to which this state might write or from which it might read at runtime.
Overrides: object.__init__

execute(self, ud)

source code 

Called when executing a state. In the base class this raises a NotImplementedError.

Parameters:
  • ud (UserData structure) - Userdata for the scope in which this state is executing

get_registered_outcomes(self)

source code 

Get a list of registered outcomes.

Returns: tuple of string
Tuple of registered outcome strings.

register_io_keys(self, keys)

source code 

Add keys to the set of keys from which this state may read and write.

Parameters:
  • keys (list of strings) - List of keys which may be read from and written to when this state is active.

register_input_keys(self, keys)

source code 

Add keys to the set of keys from which this state may read.

Parameters:
  • keys (list of strings) - List of keys which may be read from when this state is active.

register_output_keys(self, keys)

source code 

Add keys to the set of keys to which this state may write.

Parameters:
  • keys (list of strings) - List of keys which may be written to when this state is active.