Package smach :: Module iterator :: Class Iterator

Class Iterator

source code


Sequence Container

This container inherits functionality from smach.StateMachine and adds some auto-generated transitions that create a sequence of states from the order in which said states are added to the container.

Instance Methods
 
__init__(self, outcomes, input_keys, output_keys, it=[], it_label='it_data', exhausted_outcome='exhausted')
Constructor.
source code
 
execute(self, parent_ud)
Called when executing a state.
source code
 
request_preempt(self)
Sets preempt_requested to True
source code
dict of string: State
get_children(self)
Get the children of this container.
source code
smach.State
__getitem__(self, key)
Access child state by key.
source code
list of string
get_initial_states(self)
Get the initial states description.
source code
 
set_initial_state(self, initial_states, userdata)
Set initial active states of a container.
source code
list of string
get_active_states(self)
Get a description of the current states.
source code
list of 3-tuple
get_internal_edges(self)
Get the internal outcome edges of this container.
source code
 
check_consistency(self)
Check consistency of this container.
source code

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

    Inherited from container.Container
 
__enter__(self) source code
 
__exit__(self, exc_type, exc_val, exc_tb) source code
 
assert_opened(self, msg='') source code
 
call_start_cbs(self)
Calls the registered start callbacks.
source code
 
call_termination_cbs(self, terminal_states, outcome)
Calls the registered termination callbacks.
source code
 
call_transition_cbs(self)
Calls the registered transition callbacks.
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
 
open(self)
Opens this container for modification.
source code
 
opened(self, **kwargs)
Context manager method for opening a smach container.
source code
 
register_start_cb(self, start_cb, cb_args=[])
Adds a start callback to this container.
source code
 
register_termination_cb(self, termination_cb, cb_args=[])
Adds a termination callback to this state machine.
source code
 
register_transition_cb(self, transition_cb, cb_args=[])
Adds a transition callback to this container.
source code
    Inherited from state.State
 
get_registered_input_keys(self)
Get a tuple of registered input keys.
source code
tuple of str
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
 
service_preempt(self)
Sets preempt_requested to False
source code
Static Methods
 
set_iteritems(it, it_label='it_data')
Set the list or generator for the iterator to iterate over.
source code
 
set_contained_state(label, state, loop_outcomes=[], break_outcomes=[], final_outcome_map={})
Set the contained state
source code
Instance Variables
    Inherited from container.Container
  userdata
Userdata to be passed to child states.
Properties

Inherited from object: __class__

Method Details

__init__(self, outcomes, input_keys, output_keys, it=[], it_label='it_data', exhausted_outcome='exhausted')
(Constructor)

source code 

Constructor.

Parameters:
  • outcomes (list of string) - The potential outcomes of this container.
  • iteritems - Items to iterate over on each cycle
  • iteritems_label - The label that the item in the current iteration will be given when it is put into the container's local userdata.
  • it_label (string)
  • it (iterable)
Overrides: object.__init__

set_iteritems(it, it_label='it_data')
Static Method

source code 

Set the list or generator for the iterator to iterate over.

Parameters:
  • iteritems - Items to iterate over on each cycle
  • iteritems_label - The label that the item in the current iteration will be given when it is put into the container's local userdata.
  • exhausted_outcome (string) - If the iterable is exhausted without a break condition this outcome is emitted by the container.
  • it_label (string)
  • it (iterable)

set_contained_state(label, state, loop_outcomes=[], break_outcomes=[], final_outcome_map={})
Static Method

source code 

Set the contained state

Parameters:
  • label (string) - The label of the state being added.
  • state (smach.State) - An instance of a class implementing the smach.State interface.
  • loop_outcomes - List of contained state outcomes that should cause the iterator to continue. If this is empty, all outcomes that are not in the break_outcomes list will cause the iterator to continue to iterate. NOTE: loop_outcomes will be overriden by break_outcomes if both parameters are used.
  • break_outcomes - List of contained state outcomes that should cause the iterator to break. When the contained state emits an outcome in this list, the container will terminate and return either that outcome or the outcome it is mapped to in final_outcome_map. NOTE: loop_outcomes will be overriden by break_outcomes if both parameters are used.
  • final_outcome_map - A map from contained state outcomes to container outcomes. On termination of the iterator (either from finishing or from a break) this map will be used to translate contained state outcomes to container outcomes. Unspecified contained state outcomes will fall through as container outcomes.

execute(self, parent_ud)

source code 

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

Parameters:
  • ud - Userdata for the scope in which this state is executing
Overrides: state.State.execute
(inherited documentation)

request_preempt(self)

source code 

Sets preempt_requested to True

Overrides: state.State.request_preempt
(inherited documentation)

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.
Overrides: container.Container.get_children
(inherited documentation)

__getitem__(self, key)
(Indexing operator)

source code 

Access child state by key.

Returns: smach.State
Child state with label equal to key
Overrides: container.Container.__getitem__
(inherited documentation)

get_initial_states(self)

source code 

Get the initial states description.

Returns: list of string
Overrides: container.Container.get_initial_states
(inherited documentation)

set_initial_state(self, initial_states, userdata)

source code 

Set initial active states of a container.

Parameters:
  • initial_states - A description of the initial active state of this container.
  • userdata - Initial userdata for this container.
Overrides: container.Container.set_initial_state
(inherited documentation)

get_active_states(self)

source code 

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

Returns: list of string
Overrides: container.Container.get_active_states
(inherited documentation)

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 correspond to transitions inside this container.

Returns: list of 3-tuple
Overrides: container.Container.get_internal_edges
(inherited documentation)

check_consistency(self)

source code 

Check consistency of this container.

Overrides: container.Container.check_consistency
(inherited documentation)