smach.util module

class smach.util.CBInterface(cb, outcomes=None, input_keys=None, output_keys=None, io_keys=None)

Bases: object

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
get_registered_input_keys()

Get a tuple of registered input keys.

get_registered_outcomes()

Get a list of registered outcomes. @rtype: tuple of string @return: Tuple of registered outcome strings.

get_registered_output_keys()

Get a tuple of registered output keys.

class smach.util.cb_interface(outcomes=None, input_keys=None, output_keys=None)

Bases: object

smach.util.has_smach_interface(obj)

Returns True if the object has SMACH interface accessors.

smach.util.is_shutdown()
smach.util.set_shutdown_check(cb)