Package asmach :: Module container :: Class Container

Class Container

source code


Smach container interface.

This provides an interface for hooking into smach containers. This includes methods to get and set state, as well as provide start / transition / termination callback storage and registration utilities.

Note that it is up to the implementation of the containers both when the callbacks are called as well as what arguments are given to them.

Callback semantics:

Instance Methods
 
__init__(self, outcomes=[], input_keys=[], output_keys=[])
Constructor.
source code
smach.State
__getitem__(self, key)
Access child state by key.
source code
dict of string: State
get_children(self)
Get the children of this container.
source code
 
set_initial_state(self, initial_states, userdata)
Set initial active state of a container.
source code
list of string
get_initial_states(self)
Get the initial state description.
source code
list of string
get_active_states(self)
Get a description of the current state.
source code
list of 3-tuple
get_internal_edges(self)
Get the internal outcome edges of this container.
source code
 
check_consistency(self)
Check constistency of this container.
source code
 
set_userdata(self, userdata)
Stores reference to parent userdata if share flage is set.
source code
 
register_start_cb(self, start_cb, cb_args=[])
Adds a start callback to this container.
source code
 
register_transition_cb(self, transition_cb, cb_args=[])
Adds a transition callback to this container.
source code
 
register_termination_cb(self, termination_cb, cb_args=[])
Adds a termination callback to this state machine.
source code
 
call_start_cbs(self)
Calls the registered start callbacks.
source code
 
call_transition_cbs(self)
Calls the registered transition callbacks.
source code
 
call_termination_cbs(self, terminal_states, outcome)
Calls the registered termination callbacks.
source code
 
__enter__(self) source code
 
__exit__(self, exc_type, exc_val, exc_tb) source code
 
opened(self, **kwargs)
Context manager method for opening a smach container.
source code
 
open(self)
Opens this container for modification.
source code
 
close(self)
Close the container.
source code
bool
is_opened(self)
Returns True if this container is currently opened for construction.
source code
 
assert_opened(self, msg='') source code

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

    Inherited from state.State
 
execute_async(self, continuation, resume, ud) source code
 
get_registered_input_keys(self)
Get a tuple of registered input keys.
source code
tuple of string
get_registered_outcomes(self)
Get a list of registered outcomes.
source code
 
get_registered_output_keys(self)
Get a tuple of registered output keys.
source code
 
preempt_requested(self)
True if a preempt has been requested.
source code
 
recall_preempt(self)
Sets preempt_requested to False
source code
 
register_input_keys(self, keys)
Add keys to the set of keys from which this state may read.
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_outcomes(self, new_outcomes)
Add outcomes to the outcome set.
source code
 
register_output_keys(self, keys)
Add keys to the set of keys to which this state may write.
source code
 
request_preempt(self)
Sets preempt_requested to True
source code
 
service_preempt(self)
Sets preempt_requested to False
source code
Instance Variables
  userdata
Userdata to be passed to child states.
Properties

Inherited from object: __class__

Method Details

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

source code 

Constructor. Initializes callback lists (empty).

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

__getitem__(self, key)
(Indexing operator)

source code 

Access child state by key.

Returns: smach.State
Child state with label equal to key

get_children(self)

source code 

Get the children of this container. This is empty for leaf states.

Returns: dict of string: State
The sub-states of this container.

set_initial_state(self, initial_states, userdata)

source code 

Set initial active state of a container.

Parameters:
  • initial_states (list of string) - A description of the initial active state of this container.
  • userdata (UserData) - Initial userdata for this container.

get_active_states(self)

source code 

Get a description of the current state. Note that this is specific to container implementation.

Returns: list of string

get_internal_edges(self)

source code 

Get the internal outcome edges of this container. Get a list of 3-tuples (OUTCOME, LABEL_FROM, LABEL_TO) which coresspond to transitions inside this container.

Returns: list of 3-tuple

register_start_cb(self, start_cb, cb_args=[])

source code 

Adds a start callback to this container. Start callbacks receive arguments:

  • userdata
  • local_userdata
  • initial_states
  • *cb_args

register_transition_cb(self, transition_cb, cb_args=[])

source code 

Adds a transition callback to this container. Transition callbacks receive arguments:

  • userdata
  • local_userdata
  • active_states
  • *cb_args

register_termination_cb(self, termination_cb, cb_args=[])

source code 

Adds a termination callback to this state machine. Termination callbacks receive arguments:

  • userdata
  • local_userdata
  • terminal_states
  • container_outcome
  • *cb_args

call_start_cbs(self)

source code 

Calls the registered start callbacks. Callback functions are called with two arguments in addition to any user-supplied arguments:

  • userdata
  • a list of initial states

call_transition_cbs(self)

source code 

Calls the registered transition callbacks. Callback functions are called with two arguments in addition to any user-supplied arguments:

  • userdata
  • a list of active states

call_termination_cbs(self, terminal_states, outcome)

source code 

Calls the registered termination callbacks. Callback functions are called with three arguments in addition to any user-supplied arguments:

  • userdata
  • a list of terminal states
  • the outcome of this container

opened(self, **kwargs)

source code 

Context manager method for opening a smach container.

Decorators:
  • @contextmanager

open(self)

source code 

Opens this container for modification.

This appends the container to the construction stack and locks the reentrant lock if it is a valid container to open.