10 from flexbe_core
import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger
11 from flexbe_states.calculation_state
import CalculationState
12 from flexbe_states.decision_state
import DecisionState
20 Created on Fri Apr 17 2020 21 @author: Philipp Schillinger 25 Simple behavior for the flexbe_testing self-test of behaviors. 30 super(SelftestBehaviorSM, self).
__init__()
31 self.
name =
'Selftest Behavior' 34 self.add_parameter(
'value',
'wrong')
49 _state_machine = OperatableStateMachine(outcomes=[
'finished',
'failed'], input_keys=[
'data'], output_keys=[
'result'])
50 _state_machine.userdata.data =
None 51 _state_machine.userdata.result =
None 61 OperatableStateMachine.add(
'Modify Data',
62 CalculationState(calculation=
lambda x: x * 2),
63 transitions={
'done':
'Decide Param'},
64 autonomy={
'done': Autonomy.Off},
65 remapping={
'input_value':
'data',
'output_value':
'result'})
68 OperatableStateMachine.add(
'Decide Param',
69 DecisionState(outcomes=[
'finished',
'failed'], conditions=
lambda x:
'finished' if self.
value ==
'correct' else 'failed'),
70 transitions={
'finished':
'finished',
'failed':
'failed'},
71 autonomy={
'finished': Autonomy.Off,
'failed': Autonomy.Off},
72 remapping={
'input_value':
'data'})