Package smach :: Module util :: Class CBInterface

Class CBInterface

source code


Decorator to describe the extension of a state's SMACH userdata and outcome interface.

Some SMACH states can be extended with the use of user callbacks. Since the SMACH interface and SMACH userdata are strictly controlled, the ways in which these callbacks interact with SMACH must be delcared. This decorator allows this information to be attached to a given callback function.

If a callback adds a potential outcome to a state, suppose 'critical_failure', then one could write this when defining the callback:

>>> import smach
>>> @smach.cb_interface(outcomes=['critical_failure'])
>>> def my_cb(x,y,z):
>>>     # User code
>>>     return 'critical_failure'

Suppose a state retrieves data that it passes into a callback. If the user wants to take that data and put some of all of it into userdata, this interface must be declared. In this case, the user could write:

>>> import smach
>>> @smach.cb_interface(output_keys=['processed_res'])
>>> def my_cb(ud, data):
>>>     ud.processed_res = data
Instance Methods
 
__init__(self, cb, outcomes=None, input_keys=None, output_keys=None, io_keys=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__call__(self, *args, **kwargs) source code
 
get_registered_input_keys(self)
Get a tuple of registered input keys.
source code
 
get_registered_output_keys(self)
Get a tuple of registered output keys.
source code
tuple of string
get_registered_outcomes(self)
Get a list of registered outcomes.
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, cb, outcomes=None, input_keys=None, output_keys=None, io_keys=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

get_registered_outcomes(self)

source code 

Get a list of registered outcomes.

Returns: tuple of string
Tuple of registered outcome strings.