8 from flexbe_core
import Behavior, Autonomy, OperatableStateMachine, EventState, Logger
12 ''' Simple behavior for the flexbe_testing self-test of behaviors. '''
15 super(SelftestBehaviorSM, self).
__init__()
16 self.
name =
'Selftest Behavior'
17 self.add_parameter(
'value',
'wrong')
20 _state_machine = OperatableStateMachine(outcomes=[
'finished',
'failed'], input_keys=[
'data'], output_keys=[
'result'])
21 _state_machine.userdata.data =
None
22 _state_machine.userdata.result =
None
25 OperatableStateMachine.add(
'Modify Data',
27 transitions={
'done':
'Decide Param'},
28 autonomy={
'done': Autonomy.Off},
29 remapping={
'input_value':
'data',
'output_value':
'result'})
30 OperatableStateMachine.add(
'Decide Param',
32 transitions={
'finished':
'finished',
'failed':
'failed'},
33 autonomy={
'finished': Autonomy.Off,
'failed': Autonomy.Off},
34 remapping={
'input_value':
'data'})
38 ''' Copy of the flexbe_states.CalculationState for use in the test behavior. '''
53 except Exception
as e:
54 Logger.logwarn(
'Failed to execute calculation function!\n%s' % str(e))
56 Logger.logwarn(
'Passed no calculation!')
59 ''' Copy of the flexbe_states.DecisionState for use in the test behavior. '''
69 outcome = str(self.
_conditions(userdata.input_value))
70 except Exception
as e:
71 Logger.logwarn(
'Passed no function as predicate!\n%s' % str(e))
73 if outcome
is not None and outcome
in self._outcomes: