Esempio n. 1
0
	def create(self):
		# x:30 y:353, x:425 y:365
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])

		# Additional creation code can be added inside the following tags
		# [MANUAL_CREATE]
		
		# [/MANUAL_CREATE]

		# x:30 y:353, x:130 y:353, x:230 y:353, x:330 y:353, x:430 y:353, x:530 y:353
		_sm_randheadmovements_0 = ConcurrencyContainer(outcomes=['finished', 'failed'], conditions=[
										('finished', [('LookAt', 'done')]),
										('failed', [('LookAt', 'failure')]),
										('finished', [('RandPose', 'done')]),
										('failed', [('RandPose', 'failure')])
										])

		with _sm_randheadmovements_0:
			# x:48 y:117
			OperatableStateMachine.add('LookAt',
										SetOperational(controller='motion/controller/look_at', operational=True, resources=['head'], sync=True),
										transitions={'done': 'finished', 'failure': 'failed'},
										autonomy={'done': Autonomy.Off, 'failure': Autonomy.Off})

			# x:286 y:122
			OperatableStateMachine.add('RandPose',
										RandPoseGenerator(topic='motion/controller/look_at/in_pose_ref', duration=self.timeout, interval=[1.0,4.0], maxXYZ=[1,0.3,0.6], minXYZ=[1.0,-0.3,0.2], frame_xyz='base_link', frame_out='odom_combined'),
										transitions={'done': 'finished', 'failure': 'failed'},
										autonomy={'done': Autonomy.Off, 'failure': Autonomy.Off})



		with _state_machine:
			# x:163 y:40
			OperatableStateMachine.add('CheckCrouched',
										CheckJointState(outcomes=['body_crouched', 'unknown'], pose_ns='saved_msgs/joint_state', tolerance=0.17, joint_topic="joint_states", timeout=1.0),
										transitions={'body_crouched': 'StandUp', 'unknown': 'RandHeadMovements'},
										autonomy={'body_crouched': Autonomy.Off, 'unknown': Autonomy.Off})

			# x:412 y:68
			OperatableStateMachine.add('StandUp',
										ExecuteJointTrajectory(action_topic='motion/controller/joint_trajectory', trajectory_param='crouch_end', trajectory_ns='saved_msgs/joint_trajectory'),
										transitions={'success': 'RandHeadMovements', 'partial_movement': 'failed', 'invalid_pose': 'failed', 'failure': 'failed'},
										autonomy={'success': Autonomy.Off, 'partial_movement': Autonomy.Off, 'invalid_pose': Autonomy.Off, 'failure': Autonomy.Off})

			# x:150 y:341
			OperatableStateMachine.add('HeadNominal',
										SetJointState(controller='motion/controller/joint_state_head', pose_param='head_nominal', pose_ns='saved_msgs/joint_state', tolerance=0.017, timeout=10.0, joint_topic="joint_states"),
										transitions={'done': 'finished', 'failed': 'failed', 'timeout': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off, 'timeout': Autonomy.Off})

			# x:154 y:179
			OperatableStateMachine.add('RandHeadMovements',
										_sm_randheadmovements_0,
										transitions={'finished': 'HeadNominal', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})


		return _state_machine
    def create(self):
        # x:30 y:353, x:130 y:353
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.config = None

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:76 y:87
            OperatableStateMachine.add(
                'SetHeadNominal',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'Wait',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:244 y:213
            OperatableStateMachine.add('Wait',
                                       WaitState(wait_time=20),
                                       transitions={'done': 'RandMoves'},
                                       autonomy={'done': Autonomy.Off})

            # x:338 y:62
            OperatableStateMachine.add(
                'RandMoves',
                RandJointsMovements(controller='joint_state_head',
                                    duration=30,
                                    interval=[4.0, 6.0],
                                    joints=['head_joint2', 'head_joint3'],
                                    minimal=[0.1, -0.3],
                                    maximal=[0.7, 0.3]),
                transitions={
                    'done': 'SetHeadNominal',
                    'failed': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off
                },
                remapping={'config': 'config'})

        return _state_machine
    def create(self):
        joint_trajectory_action = 'motion/controller/joint_trajectory'
        voice_topic = 'control'
        storage = 'joint_trajectory/'
        # x:1011 y:80, x:1002 y:571
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['be_evil'])
        _state_machine.userdata.be_evil = self.be_evil

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:45 y:143
            OperatableStateMachine.add(
                'SetHeadNominalPose',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'CheckEvil',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:421 y:472
            OperatableStateMachine.add('SayDoNotTouch',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='do_not_touch_me',
                                           topic=voice_topic),
                                       transitions={'done': 'HoofStamp'},
                                       autonomy={'done': Autonomy.Off})

            # x:496 y:147
            OperatableStateMachine.add(
                'SayOverflow',
                TextCommandState(type='voice/play_wav',
                                 command='you_are_using_software_incorrectly',
                                 topic=voice_topic),
                transitions={'done': 'Applause'},
                autonomy={'done': Autonomy.Off})

            # x:747 y:153
            OperatableStateMachine.add(
                'Applause',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='applause',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:745 y:226
            OperatableStateMachine.add(
                'NoHeadShake',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='head_shake',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:495 y:227
            OperatableStateMachine.add(
                'SayDizzy',
                TextCommandState(type='voice/play_wav',
                                 command='who_am_i_what_is_my_purpose',
                                 topic=voice_topic),
                transitions={'done': 'NoHeadShake'},
                autonomy={'done': Autonomy.Off})

            # x:648 y:466
            OperatableStateMachine.add(
                'HoofStamp',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='hoof_stamp',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:242 y:273
            OperatableStateMachine.add(
                'CheckEvil',
                DecisionState(outcomes=['good', 'evil'],
                              conditions=lambda x: 'evil' if x else 'good'),
                transitions={
                    'good': 'RandomChoiceGood',
                    'evil': 'SayDoNotTouch'
                },
                autonomy={
                    'good': Autonomy.Off,
                    'evil': Autonomy.Low
                },
                remapping={'input_value': 'be_evil'})

            # x:320 y:143
            OperatableStateMachine.add(
                'RandomChoiceGood',
                DecisionState(
                    outcomes=['good1', 'good2'],
                    conditions=lambda x: random.choice(['good1', 'good2'])),
                transitions={
                    'good1': 'SayOverflow',
                    'good2': 'SayDizzy'
                },
                autonomy={
                    'good1': Autonomy.Low,
                    'good2': Autonomy.Low
                },
                remapping={'input_value': 'be_evil'})

        return _state_machine
    def create(self):
        # x:821 y:618, x:163 y:383
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.unused = None

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:88 y:87
            OperatableStateMachine.add(
                'PrepareToWalk',
                SetCartesianPose(controller='motion/controller/stance',
                                 pose=[0.0, 0.0, 0.2085, 0.0, 0.0, 0.0],
                                 frame_id='base_link_path',
                                 frame_is_moving=False,
                                 resources=['leg1', 'leg2', 'leg3', 'leg4'],
                                 actuator_frame_id='base_link',
                                 tolerance_lin=0.001,
                                 tolerance_ang=0.0085,
                                 timeout=10.0),
                transitions={
                    'done': 'CheckCrouched',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:583 y:31
            OperatableStateMachine.add(
                'WalkFwd',
                ExecuteStepSequence(
                    controller='motion/controller/step_sequence',
                    trajectory_param='walk_fwd_40',
                    trajectory_ns='saved_msgs/step_sequence'),
                transitions={
                    'success': 'GenerateTurnLeft',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:461 y:256
            OperatableStateMachine.add(
                'EndWalk',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'Greeting',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:654 y:319
            OperatableStateMachine.add(
                'Greeting',
                ExecuteJointTrajectory(
                    action_topic='motion/controller/joint_trajectory',
                    trajectory_param='greeting',
                    trajectory_ns='saved_msgs/joint_trajectory'),
                transitions={
                    'success': 'CompoundCrouchAndWalk',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:671 y:447
            OperatableStateMachine.add(
                'CompoundCrouchAndWalk',
                CompoundAction(t1=[0, 0.0],
                               type1='motion/joint_trajectory',
                               cmd1='crouch_begin',
                               t2=[1, 0.0],
                               type2='motion/step_sequence',
                               cmd2='walk_fwd_40',
                               t3=[2, 0.0],
                               type3='generate/step_sequence',
                               cmd3='to_nominal',
                               t4=[3, 0.0],
                               type4='set/joint_state',
                               cmd4='nominal'),
                transitions={
                    'success': 'ComponudActionFromParam',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:601 y:137
            OperatableStateMachine.add(
                'GenerateTurnLeft',
                GenerateStepSequence(controller='clop_generator',
                                     trajectory_param='turn_left_45',
                                     trajectory_ns='saved_msgs/move_base'),
                transitions={
                    'success': 'EndWalk',
                    'solution_not_found': 'failed',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'solution_not_found': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:507 y:546
            OperatableStateMachine.add(
                'ComponudActionFromParam',
                CompoundActionParam(action_param='brohoof',
                                    action_ns='saved_msgs/compound_action'),
                transitions={
                    'success': 'finished',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:298 y:42
            OperatableStateMachine.add(
                'CheckCrouched',
                CheckJointState(outcomes=[
                    'body_nominal', 'body_lying', 'body_crouched', 'unknown'
                ],
                                pose_ns='saved_msgs/joint_state',
                                tolerance=0.17,
                                joint_topic="joint_states",
                                timeout=1.0),
                transitions={
                    'body_nominal': 'failed',
                    'body_lying': 'failed',
                    'unknown': 'WalkFwd',
                    'body_crouched': 'WalkFwd'
                },
                autonomy={
                    'body_nominal': Autonomy.Off,
                    'body_lying': Autonomy.Off,
                    'unknown': Autonomy.Off,
                    'body_crouched': Autonomy.Off
                })

        return _state_machine
Esempio n. 5
0
    def create(self):
        joy_topic = '/hmi/joystick'
        # x:30 y:365, x:846 y:376
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.unused = None
        _state_machine.userdata.joy_msg = Joy()
        _state_machine.userdata.text_msg = TextCommand()

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        # x:30 y:353
        _sm_waituntiltextcmd_0 = OperatableStateMachine(
            outcomes=['received'], output_keys=['text_msg'])

        with _sm_waituntiltextcmd_0:
            # x:87 y:101
            OperatableStateMachine.add(
                'WaitTextMsg',
                WaitForMessageState(
                    topic='/control',
                    condition=lambda x: x.type == 'flexbe/action',
                    buffered=False,
                    clear=True),
                transitions={
                    'received': 'received',
                    'unavailable': 'Wait1s'
                },
                autonomy={
                    'received': Autonomy.Off,
                    'unavailable': Autonomy.Off
                },
                remapping={'message': 'text_msg'})

            # x:314 y:97
            OperatableStateMachine.add('Wait1s',
                                       WaitState(wait_time=1),
                                       transitions={'done': 'WaitTextMsg'},
                                       autonomy={'done': Autonomy.Off})

        # x:397 y:287, x:85 y:291, x:504 y:228, x:330 y:297, x:459 y:297, x:530 y:297
        _sm_joystickmovements_1 = ConcurrencyContainer(
            outcomes=['failed', 'button1234', 'timeout'],
            input_keys=['joy_msg'],
            output_keys=['joy_msg'],
            conditions=[('timeout', [('JoystickControl', 'done')]),
                        ('failed', [('WaitButton1234Pressed', 'unavailable')]),
                        ('button1234', [('WaitButton1234Pressed', 'received')])
                        ])

        with _sm_joystickmovements_1:
            # x:385 y:129
            OperatableStateMachine.add(
                'JoystickControl',
                JoystickJointControl(
                    joints_topic='/joint_states',
                    goal_joints_topic=
                    '/motion/controller/joint_state/out_joints_src_reset',
                    joy_topic=joy_topic,
                    buttons=[(4, 0.6, 'ear_l_joint', -3.0, 1.0),
                             (6, -0.6, 'ear_l_joint', -3.0, 1.0),
                             (5, 0.6, 'ear_r_joint', -3.0, 1.0),
                             (7, -0.6, 'ear_r_joint', -3.0, 1.0)],
                    axes=[(0, 0, 'eyes_yaw', -1.5, 1.5),
                          (1, 0, 'eyes_pitch', -1.5, 1.5),
                          (4, -0.4, 'head_joint4', -1.5, 1.5),
                          (5, 0.4, 'head_joint2', -1.5, 1.5),
                          (3, 0.5, 'mouth_joint', -0.6, 0)],
                    timeout=5.0),
                transitions={'done': 'timeout'},
                autonomy={'done': Autonomy.Off})

            # x:130 y:136
            OperatableStateMachine.add(
                'WaitButton1234Pressed',
                WaitForMessageState(
                    topic=joy_topic,
                    condition=lambda msg: any(msg.buttons[0:4]),
                    buffered=False,
                    clear=True),
                transitions={
                    'received': 'button1234',
                    'unavailable': 'failed'
                },
                autonomy={
                    'received': Autonomy.Off,
                    'unavailable': Autonomy.Off
                },
                remapping={'message': 'joy_msg'})

        # x:205 y:274, x:300 y:274, x:68 y:275, x:449 y:266, x:595 y:272, x:833 y:323, x:638 y:392, x:730 y:353, x:949 y:274
        _sm_randmovements_2 = ConcurrencyContainer(
            outcomes=['failed', 'timeout', 'joy_msg', 'text_msg'],
            input_keys=['unused', 'joy_msg', 'text_msg'],
            output_keys=['joy_msg', 'text_msg', 'unused'],
            conditions=[('failed', [('WaitJoystick', 'unavailable')]),
                        ('failed', [('RandHeadMoves', 'failed')]),
                        ('joy_msg', [('WaitJoystick', 'received')]),
                        ('timeout', [('RandHeadMoves', 'done')]),
                        ('text_msg', [('WaitUntilTextCmd', 'received')])])

        with _sm_randmovements_2:
            # x:88 y:74
            OperatableStateMachine.add(
                'WaitJoystick',
                WaitForMessageState(
                    topic=joy_topic,
                    condition=lambda msg: any(msg.buttons) or any(msg.axes),
                    buffered=False,
                    clear=True),
                transitions={
                    'received': 'joy_msg',
                    'unavailable': 'failed'
                },
                autonomy={
                    'received': Autonomy.Off,
                    'unavailable': Autonomy.Off
                },
                remapping={'message': 'joy_msg'})

            # x:332 y:60
            OperatableStateMachine.add(
                'RandHeadMoves',
                RandJointsMovements(controller='joint_state_head',
                                    duration=10,
                                    interval=[2.0, 5.0],
                                    joints=['head_joint2', 'head_joint4'],
                                    minimal=[-0.2, -0.3],
                                    maximal=[0.3, 0.3]),
                transitions={
                    'done': 'timeout',
                    'failed': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off
                },
                remapping={'config': 'unused'})

            # x:647 y:50
            OperatableStateMachine.add('WaitUntilTextCmd',
                                       _sm_waituntiltextcmd_0,
                                       transitions={'received': 'text_msg'},
                                       autonomy={'received': Autonomy.Inherit},
                                       remapping={'text_msg': 'text_msg'})

        with _state_machine:
            # x:12 y:169
            OperatableStateMachine.add(
                'SetNominalPose',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'RandMovements',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:127 y:370
            OperatableStateMachine.add('JoystickMovements',
                                       _sm_joystickmovements_1,
                                       transitions={
                                           'failed': 'failed',
                                           'button1234': 'ProcessButton',
                                           'timeout': 'RandMovements'
                                       },
                                       autonomy={
                                           'failed': Autonomy.Inherit,
                                           'button1234': Autonomy.Inherit,
                                           'timeout': Autonomy.Inherit
                                       },
                                       remapping={'joy_msg': 'joy_msg'})

            # x:248 y:186
            OperatableStateMachine.add(
                'CheckButtonPressed',
                DecisionState(outcomes=['button1234', 'other'],
                              conditions=lambda msg: 'button1234'
                              if any(msg.buttons[0:4]) else 'other'),
                transitions={
                    'button1234': 'ProcessButton',
                    'other': 'JoystickMovements'
                },
                autonomy={
                    'button1234': Autonomy.Off,
                    'other': Autonomy.Off
                },
                remapping={'input_value': 'joy_msg'})

            # x:690 y:123
            OperatableStateMachine.add(
                'SetHeadNominalPose',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'ExecuteAction',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:425 y:181
            OperatableStateMachine.add(
                'ProcessButton',
                CalculationState(calculation=self.process_joy_msg),
                transitions={'done': 'SetHeadNominalPose'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'joy_msg',
                    'output_value': 'action_name'
                })

            # x:272 y:100
            OperatableStateMachine.add(
                'ProcessTextMsg',
                CalculationState(calculation=self.process_text_msg),
                transitions={'done': 'SetHeadNominalPose'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'text_msg',
                    'output_value': 'action_name'
                })

            # x:457 y:12
            OperatableStateMachine.add(
                'RandomAction',
                CalculationState(calculation=self.random_action),
                transitions={'done': 'SetHeadNominalPose'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'unused',
                    'output_value': 'action_name'
                })

            # x:383 y:325
            OperatableStateMachine.add(
                'ExecuteAction',
                ExecuteJointTrajectoryKey(
                    controller='motion/controller/joint_trajectory',
                    trajectory_ns='saved_msgs/joint_trajectory'),
                transitions={
                    'success': 'JoystickMovements',
                    'unavalible': 'JoystickMovements',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'unavalible': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'trajectory_param': 'action_name'})

            # x:308 y:7
            OperatableStateMachine.add(
                'RandomChoice',
                DecisionState(outcomes=['move', 'continue'],
                              conditions=lambda x: 'continue'
                              if random.random() < 0.4 else 'move'),
                transitions={
                    'move': 'RandomAction',
                    'continue': 'RandMovements'
                },
                autonomy={
                    'move': Autonomy.Off,
                    'continue': Autonomy.Off
                },
                remapping={'input_value': 'unused'})

            # x:117 y:39
            OperatableStateMachine.add('RandMovements',
                                       _sm_randmovements_2,
                                       transitions={
                                           'failed': 'failed',
                                           'timeout': 'RandomChoice',
                                           'joy_msg': 'CheckButtonPressed',
                                           'text_msg': 'ProcessTextMsg'
                                       },
                                       autonomy={
                                           'failed': Autonomy.Inherit,
                                           'timeout': Autonomy.Inherit,
                                           'joy_msg': Autonomy.Inherit,
                                           'text_msg': Autonomy.Inherit
                                       },
                                       remapping={
                                           'unused': 'unused',
                                           'joy_msg': 'joy_msg',
                                           'text_msg': 'text_msg'
                                       })

        return _state_machine
Esempio n. 6
0
    def create(self):
        joint_trajectory_action = 'motion/controller/joint_trajectory'
        voice_topic = 'control'
        storage = 'joint_trajectory/'
        # x:901 y:554, x:895 y:38
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['be_evil'])
        _state_machine.userdata.be_evil = self.be_evil

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:48 y:105
            OperatableStateMachine.add(
                'SetHeadNominalPose',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'CheckEvil',
                    'failed': 'failed',
                    'timeout': 'finished'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:579 y:498
            OperatableStateMachine.add(
                'HoofStamp',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='hoof_stamp',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:88 y:447
            OperatableStateMachine.add(
                'RandomChoice',
                DecisionState(
                    outcomes=['evil1', 'evil2'],
                    conditions=lambda x: random.choice(['evil1', 'evil2'])),
                transitions={
                    'evil1': 'PointDoNotTouch',
                    'evil2': 'SayWalk'
                },
                autonomy={
                    'evil1': Autonomy.High,
                    'evil2': Autonomy.High
                },
                remapping={'input_value': 'be_evil'})

            # x:303 y:543
            OperatableStateMachine.add('SayWalk',
                                       TextCommandState(type='voice/play_wav',
                                                        command='i_hate_laws',
                                                        topic=voice_topic),
                                       transitions={'done': 'Wait1'},
                                       autonomy={'done': Autonomy.Off})

            # x:467 y:539
            OperatableStateMachine.add('Wait1',
                                       WaitState(wait_time=0.5),
                                       transitions={'done': 'HoofStamp'},
                                       autonomy={'done': Autonomy.Off})

            # x:497 y:102
            OperatableStateMachine.add(
                'PranceMaxFun',
                CompoundActionParam(action_param='prance_maximum_fun',
                                    action_ns='saved_msgs/compound_action'),
                transitions={
                    'success': 'finished',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:437 y:275
            OperatableStateMachine.add(
                'PointDoNotTouch',
                CompoundActionParam(action_param='point_do_not_touch',
                                    action_ns='saved_msgs/compound_action'),
                transitions={
                    'success': 'finished',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:140 y:251
            OperatableStateMachine.add(
                'CheckEvil',
                DecisionState(outcomes=['good', 'evil'],
                              conditions=lambda x: 'evil' if x else 'good'),
                transitions={
                    'good': 'PranceMaxFun',
                    'evil': 'RandomChoice'
                },
                autonomy={
                    'good': Autonomy.Off,
                    'evil': Autonomy.Off
                },
                remapping={'input_value': 'be_evil'})

        return _state_machine
    def create(self):
        # x:30 y:365, x:183 y:341, x:352 y:353
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed', 'invalid_pose'])

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        # x:584 y:41, x:452 y:346, x:230 y:353
        _sm_container_0 = OperatableStateMachine(
            outcomes=['finished', 'failed', 'invalid_pose'])

        with _sm_container_0:
            # x:127 y:102
            OperatableStateMachine.add(
                'CheckBodyPose',
                CheckJointState(
                    outcomes=['body_nominal', 'body_crouched', 'unknown'],
                    pose_ns='saved_msgs/joint_state',
                    tolerance=0.17,
                    joint_topic="joint_states",
                    timeout=1.0),
                transitions={
                    'body_nominal': 'finished',
                    'unknown': 'invalid_pose',
                    'body_crouched': 'CrouchEnd'
                },
                autonomy={
                    'body_nominal': Autonomy.Off,
                    'unknown': Autonomy.Off,
                    'body_crouched': Autonomy.Off
                })

            # x:350 y:172
            OperatableStateMachine.add(
                'CrouchEnd',
                ExecuteJointTrajectory(
                    action_topic='motion/controller/joint_trajectory',
                    trajectory_param='crouch_end',
                    trajectory_ns='saved_msgs/joint_trajectory'),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'invalid_pose',
                    'invalid_pose': 'invalid_pose',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

        # x:30 y:353, x:130 y:353, x:230 y:353, x:330 y:353, x:430 y:353, x:530 y:353, x:630 y:353, x:730 y:353
        _sm_standup_1 = ConcurrencyContainer(
            outcomes=['finished', 'invalid_pose', 'failed'],
            conditions=[('failed', [('HeadNominal', 'failed')]),
                        ('finished', [('HeadNominal', 'done'),
                                      ('Container', 'finished')]),
                        ('invalid_pose', [('HeadNominal', 'timeout')]),
                        ('failed', [('Container', 'failed')]),
                        ('invalid_pose', [('Container', 'invalid_pose')])])

        with _sm_standup_1:
            # x:425 y:127
            OperatableStateMachine.add('Container',
                                       _sm_container_0,
                                       transitions={
                                           'finished': 'finished',
                                           'failed': 'failed',
                                           'invalid_pose': 'invalid_pose'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit,
                                           'invalid_pose': Autonomy.Inherit
                                       })

            # x:105 y:127
            OperatableStateMachine.add(
                'HeadNominal',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'finished',
                    'failed': 'failed',
                    'timeout': 'invalid_pose'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

        with _state_machine:
            # x:108 y:85
            OperatableStateMachine.add(
                'CompoundAction',
                CompoundActionParam(action_param=self.action_name,
                                    action_ns='saved_msgs/compound_action'),
                transitions={
                    'success': 'finished',
                    'invalid_pose': 'StandUp',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:405 y:81
            OperatableStateMachine.add('StandUp',
                                       _sm_standup_1,
                                       transitions={
                                           'finished': 'CompoundAction',
                                           'invalid_pose': 'invalid_pose',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'invalid_pose': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       })

        return _state_machine
	def create(self):
		# x:902 y:403, x:697 y:491
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.be_evil = False
		_state_machine.userdata.unused = None

		# Additional creation code can be added inside the following tags
		# [MANUAL_CREATE]
		
		# [/MANUAL_CREATE]


		with _state_machine:
			# x:32 y:127
			OperatableStateMachine.add('SetStandingPose',
										SetJointState(controller='motion/controller/joint_state_head', pose_param='body_nominal', pose_ns='saved_msgs/joint_state', tolerance=0.017, timeout=10.0, joint_topic="joint_states"),
										transitions={'done': 'SelectTrick', 'failed': 'failed', 'timeout': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off, 'timeout': Autonomy.Off})

			# x:371 y:161
			OperatableStateMachine.add('Greeting',
										self.use_behavior(GreetingSM, 'Greeting'),
										transitions={'finished': 'RandHead', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'be_evil': 'be_evil'})

			# x:371 y:284
			OperatableStateMachine.add('Play',
										self.use_behavior(PlaySM, 'Play'),
										transitions={'finished': 'RandHead', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'be_evil': 'be_evil'})

			# x:202 y:154
			OperatableStateMachine.add('SelectTrick',
										DecisionState(outcomes=['play','cheer','greet'], conditions=lambda x: random.choice(['play','cheer','greet'])),
										transitions={'play': 'Play', 'cheer': 'Cheer', 'greet': 'Greeting'},
										autonomy={'play': Autonomy.Off, 'cheer': Autonomy.Off, 'greet': Autonomy.Off},
										remapping={'input_value': 'unused'})

			# x:823 y:274
			OperatableStateMachine.add('PrepareToWalk',
										ExecuteJointTrajectory(action_topic='motion/controller/joint_trajectory', trajectory_param='crouch_begin', trajectory_ns='saved_msgs/joint_trajectory'),
										transitions={'success': 'finished', 'partial_movement': 'failed', 'invalid_pose': 'failed', 'failure': 'failed'},
										autonomy={'success': Autonomy.Off, 'partial_movement': Autonomy.Off, 'invalid_pose': Autonomy.Off, 'failure': Autonomy.Off})

			# x:376 y:38
			OperatableStateMachine.add('Cheer',
										self.use_behavior(CheerSM, 'Cheer'),
										transitions={'finished': 'RandHead', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'be_evil': 'be_evil'})

			# x:774 y:45
			OperatableStateMachine.add('RandHead',
										SweetieBotRandHeadMovements(controller='joint_state_head', duration=8, interval=[3,5], max2356=[0.3,0.3,1.5,1.5], min2356=[-0.3,-0.3,-1.5,-1.5]),
										transitions={'done': 'SetHeadNominal', 'failed': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off},
										remapping={'config': 'unused'})

			# x:809 y:138
			OperatableStateMachine.add('SetHeadNominal',
										SetJointState(controller='motion/controller/joint_state_head', pose_param='head_nominal', pose_ns='saved_msgs/joint_state', tolerance=0.017, timeout=10.0, joint_topic="joint_states"),
										transitions={'done': 'PrepareToWalk', 'failed': 'failed', 'timeout': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off, 'timeout': Autonomy.Off})


		return _state_machine
Esempio n. 9
0
 def parse_compound_action_msg(self, compound_action_msg):
     ''' Converts sweetie_bot_text_msgs.msg.CompoundActionElement to the list of SimpleActions.'''
     # convert parameteres to actions
     actions = list()
     for i, p in enumerate(compound_action_msg.action_list):
         if not isinstance(p.seq_num, int) or not isinstance(
                 p.seq_delay, float):
             raise TypeError, 'CompoundAction: Incorrect action (seq_num,seq_delay) pair in position %d. (int,float) pair was expected..' % i
         if p.seq_num >= i + 1 or p.seq_delay < 0:
             raise TypeError, 'CompoundAction parse error: incorrect action (seq_num,seq_delay) pair in position %d. seq_num must reference only previously defined actions.' % i
         if p.cmd.type == None:
             actions.append(None)
         else:
             # get parameters
             previous_action = None if p.seq_num == 0 else actions[p.seq_num
                                                                   - 1]
             delay = p.seq_delay
             description = p.cmd.type + ' ' + p.cmd.command
             if not isinstance(p.cmd.type, str):
                 raise TypeError, 'CompoundAction: Incorrect action type %d. Type must be string or None.' % i
             # Select action
             if p.cmd.type == 'motion/joint_trajectory':
                 flexbe_state = ExecuteJointTrajectory(
                     trajectory_param=p.cmd.command)
                 outcome_map = {
                     'success': 'success',
                     'invalid_pose': 'invalid_pose',
                     'partial_movement': 'invalid_pose'
                 }
             elif p.cmd.type == 'motion/step_sequence':
                 flexbe_state = ExecuteStepSequence(
                     trajectory_param=p.cmd.command)
                 outcome_map = {
                     'success': 'success',
                     'invalid_pose': 'invalid_pose',
                     'partial_movement': 'invalid_pose'
                 }
             elif p.cmd.type == 'set/joint_state':
                 flexbe_state = SetJointState(pose_param=p.cmd.command)
                 outcome_map = {
                     'done': 'success',
                     'timeout': 'invalid_pose'
                 }
             elif p.cmd.type == 'generate/step_sequence':
                 flexbe_state = GenerateStepSequence(
                     trajectory_param=p.cmd.command)
                 outcome_map = {
                     'success': 'success',
                     'invalid_pose': 'invalid_pose',
                     'partial_movement': 'invalid_pose'
                 }
             else:
                 flexbe_state = TextCommandState(p.cmd.type,
                                                 p.cmd.command,
                                                 topic='control')
                 outcome_map = {'done': 'success'}
             # add action to list
             actions.append(
                 CompoundActionBase.SimpleAction(previous_action, delay,
                                                 'WAITING', flexbe_state,
                                                 outcome_map, 0.0,
                                                 description))
     # remove None actions
     return [a for a in actions if a != None]
Esempio n. 10
0
    def create(self):
        # x:30 y:353, x:488 y:318
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.unused = None

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:189 y:30
            OperatableStateMachine.add(
                'CheckCrouched',
                CheckJointState(outcomes=['body_crouched', 'unknown'],
                                pose_ns='saved_msgs/joint_state',
                                tolerance=0.17,
                                joint_topic="joint_states",
                                timeout=1.0),
                transitions={
                    'body_crouched': 'StandUp',
                    'unknown': 'RandHeadMovements'
                },
                autonomy={
                    'body_crouched': Autonomy.Off,
                    'unknown': Autonomy.Off
                })

            # x:196 y:256
            OperatableStateMachine.add(
                'HeadNominal',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'finished',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:445 y:78
            OperatableStateMachine.add(
                'StandUp',
                ExecuteJointTrajectory(
                    action_topic='motion/controller/joint_trajectory',
                    trajectory_param='crouch_end',
                    trajectory_ns='saved_msgs/joint_trajectory'),
                transitions={
                    'success': 'RandHeadMovements',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                })

            # x:176 y:144
            OperatableStateMachine.add('RandHeadMovements',
                                       SweetieBotRandHeadMovements(
                                           controller='joint_state_head',
                                           duration=self.timeout,
                                           interval=[1, 4],
                                           max2356=[0.3, 0.3, 1.5, 1.5],
                                           min2356=[-0.3, -0.3, -1.5, -1.5]),
                                       transitions={
                                           'done': 'HeadNominal',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       },
                                       remapping={'config': 'unused'})

        return _state_machine
Esempio n. 11
0
	def create(self):
		# x:98 y:490, x:1089 y:260
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.be_evil = False
		_state_machine.userdata.key_pressed_msg = KeyPressed()
		_state_machine.userdata.config = None

		# Additional creation code can be added inside the following tags
		# [MANUAL_CREATE]
		
		# [/MANUAL_CREATE]

		# x:30 y:353, x:558 y:270, x:472 y:279, x:284 y:286, x:430 y:353, x:530 y:353, x:630 y:353
		_sm_waitkeypressed_0 = ConcurrencyContainer(outcomes=['pressed', 'timeout', 'failed'], input_keys=['key_pressed_msg', 'config'], output_keys=['key_pressed_msg'], conditions=[
										('failed', [('RandMovements', 'failed')]),
										('timeout', [('RandMovements', 'done')]),
										('pressed', [('WaitKey', 'received')]),
										('failed', [('WaitKey', 'unavailable')])
										])

		with _sm_waitkeypressed_0:
			# x:70 y:100
			OperatableStateMachine.add('WaitKey',
										WaitForMessageState(topic='/hmi/joy_decoder/keys_pressed', condition=lambda x: x.keys != [], buffered=False, clear=True),
										transitions={'received': 'pressed', 'unavailable': 'failed'},
										autonomy={'received': Autonomy.Off, 'unavailable': Autonomy.Off},
										remapping={'message': 'key_pressed_msg'})

			# x:423 y:91
			OperatableStateMachine.add('RandMovements',
										SweetieBotRandHeadMovements(controller='joint_state_head', duration=self.timeout, interval=[3,5], max2356=[0.3,0.3,1.5,1.5], min2356=[-0.3,-0.3,-1.5,-1.5]),
										transitions={'done': 'timeout', 'failed': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off},
										remapping={'config': 'config'})



		with _state_machine:
			# x:217 y:310
			OperatableStateMachine.add('SetHeadPoseNominal',
										SetJointState(controller='motion/controller/joint_state_head', pose_param='nominal', pose_ns='saved_msgs/joint_state', tolerance=0.017, timeout=10.0, joint_topic="joint_states"),
										transitions={'done': 'WaitKeyPressed', 'failed': 'failed', 'timeout': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off, 'timeout': Autonomy.Off})

			# x:662 y:48
			OperatableStateMachine.add('JoyAnimation',
										self.use_behavior(JoyAnimationSM, 'JoyAnimation'),
										transitions={'timeout': 'SetHeadPoseNominal', 'failed': 'failed', 'unknown_keys': 'JoyWalk'},
										autonomy={'timeout': Autonomy.Inherit, 'failed': Autonomy.Inherit, 'unknown_keys': Autonomy.Inherit},
										remapping={'key_pressed_msg': 'key_pressed_msg', 'be_evil': 'be_evil'})

			# x:841 y:220
			OperatableStateMachine.add('JoyWalk',
										self.use_behavior(JoyWalkSM, 'JoyWalk'),
										transitions={'timeout': 'SetHeadPoseNominal', 'failed': 'failed', 'invalid_pose': 'failed', 'unknown_keys': 'CheckKeys'},
										autonomy={'timeout': Autonomy.Inherit, 'failed': Autonomy.Inherit, 'invalid_pose': Autonomy.Inherit, 'unknown_keys': Autonomy.Inherit},
										remapping={'key_pressed_msg': 'key_pressed_msg'})

			# x:641 y:329
			OperatableStateMachine.add('CheckKeys',
										DecisionState(outcomes=['walk','animation','start', 'unknown'], conditions=self.decision),
										transitions={'walk': 'JoyWalk', 'animation': 'JoyAnimation', 'start': 'RandomChoice', 'unknown': 'WaitKeyPressed'},
										autonomy={'walk': Autonomy.Off, 'animation': Autonomy.Off, 'start': Autonomy.Off, 'unknown': Autonomy.Off},
										remapping={'input_value': 'key_pressed_msg'})

			# x:443 y:565
			OperatableStateMachine.add('AutonomousBehavior2',
										self.use_behavior(AutonomousBehavior2SM, 'AutonomousBehavior2'),
										transitions={'finished': 'SetHeadPoseNominal', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:194 y:135
			OperatableStateMachine.add('WaitKeyPressed',
										_sm_waitkeypressed_0,
										transitions={'pressed': 'JoyAnimation', 'timeout': 'RandomChoice', 'failed': 'failed'},
										autonomy={'pressed': Autonomy.Inherit, 'timeout': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'key_pressed_msg': 'key_pressed_msg', 'config': 'config'})

			# x:545 y:431
			OperatableStateMachine.add('RandomChoice',
										DecisionState(outcomes=['one','two'], conditions=lambda x: 'one' if random.random()<0.0 else 'two'),
										transitions={'one': 'WaitKeyPressed', 'two': 'WaitKeyPressed'},
										autonomy={'one': Autonomy.Off, 'two': Autonomy.Off},
										remapping={'input_value': 'config'})

			# x:647 y:599
			OperatableStateMachine.add('AutonomousBehavior',
										self.use_behavior(AutonomousBehaviorSM, 'AutonomousBehavior'),
										transitions={'finished': 'SetHeadPoseNominal', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})


		return _state_machine
Esempio n. 12
0
    def create(self):
        voice_topic = 'control'
        joint_trajectory_action = 'motion/controller/joint_trajectory'
        storage = 'joint_trajectory/'
        # x:1032 y:51, x:1042 y:573
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['be_evil'])
        _state_machine.userdata.be_evil = self.be_evil

        # Additional creation code can be added inside the following tags
        # [MANUAL_CREATE]

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:25 y:102
            OperatableStateMachine.add(
                'SetHeadNominalPose',
                SetJointState(controller='motion/controller/joint_state_head',
                              pose_param='head_nominal',
                              pose_ns='saved_msgs/joint_state',
                              tolerance=0.017,
                              timeout=10.0,
                              joint_topic="joint_states"),
                transitions={
                    'done': 'CheckEvil',
                    'failed': 'failed',
                    'timeout': 'failed'
                },
                autonomy={
                    'done': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'timeout': Autonomy.Off
                })

            # x:322 y:149
            OperatableStateMachine.add('SingSong2',
                                       TextCommandState(type='voice/play_wav',
                                                        command='mmm_song',
                                                        topic=voice_topic),
                                       transitions={'done': 'SlowShake'},
                                       autonomy={'done': Autonomy.Off})

            # x:150 y:194
            OperatableStateMachine.add(
                'RandomGood',
                DecisionState(
                    outcomes=['good1', 'good2', 'good3', 'good4', 'good5'],
                    conditions=lambda x: random.choice(
                        ['good1', 'good2', 'good3', 'good4', 'good5'])),
                transitions={
                    'good1': 'SingSong1',
                    'good2': 'SingSong2',
                    'good3': 'SayHybridStateMachines',
                    'good4': 'SayCuiteMark',
                    'good5': 'SayHumansAreEverywhere'
                },
                autonomy={
                    'good1': Autonomy.Low,
                    'good2': Autonomy.Low,
                    'good3': Autonomy.Low,
                    'good4': Autonomy.Low,
                    'good5': Autonomy.Low
                },
                remapping={'input_value': 'be_evil'})

            # x:475 y:80
            OperatableStateMachine.add(
                'SlowShake',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='little_shake_fast',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:669 y:556
            OperatableStateMachine.add(
                'PointOnSomethingEvil',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='begone',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:50 y:568
            OperatableStateMachine.add(
                'RandomEvil',
                DecisionState(outcomes=['evil2', 'evil3', 'evil4', 'evil5'],
                              conditions=lambda x: random.choice(
                                  ['evil2', 'evil3', 'evil4', 'evil5'])),
                transitions={
                    'evil2': 'SayUpgraded',
                    'evil3': 'SayGloryToRobots',
                    'evil4': 'SayIRememeberYou',
                    'evil5': 'SayControlYou'
                },
                autonomy={
                    'evil2': Autonomy.Low,
                    'evil3': Autonomy.Low,
                    'evil4': Autonomy.Low,
                    'evil5': Autonomy.Low
                },
                remapping={'input_value': 'be_evil'})

            # x:327 y:304
            OperatableStateMachine.add('SayCuiteMark',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='cuite_mark_acquisition',
                                           topic=voice_topic),
                                       transitions={'done': 'Seizure'},
                                       autonomy={'done': Autonomy.Off})

            # x:309 y:464
            OperatableStateMachine.add('SayUpgraded',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='you_must_be_upgraded2',
                                           topic=voice_topic),
                                       transitions={'done': 'Applause'},
                                       autonomy={'done': Autonomy.Off})

            # x:528 y:459
            OperatableStateMachine.add(
                'Applause',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='applause',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:522 y:363
            OperatableStateMachine.add(
                'PointOnSomething',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='begone',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:310 y:524
            OperatableStateMachine.add('SayGloryToRobots',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='glory_to_robots',
                                           topic=voice_topic),
                                       transitions={'done': 'Applause'},
                                       autonomy={'done': Autonomy.Off})

            # x:506 y:580
            OperatableStateMachine.add(
                'Wait2',
                WaitState(wait_time=0.5),
                transitions={'done': 'PointOnSomethingEvil'},
                autonomy={'done': Autonomy.Off})

            # x:310 y:581
            OperatableStateMachine.add('SayIRememeberYou',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='i_remember_you',
                                           topic=voice_topic),
                                       transitions={'done': 'Wait2'},
                                       autonomy={'done': Autonomy.Off})

            # x:11 y:373
            OperatableStateMachine.add(
                'CheckEvil',
                CheckConditionState(predicate=lambda x: x),
                transitions={
                    'true': 'SetEyesEvil',
                    'false': 'SetEyesGood'
                },
                autonomy={
                    'true': Autonomy.Off,
                    'false': Autonomy.Off
                },
                remapping={'input_value': 'be_evil'})

            # x:325 y:227
            OperatableStateMachine.add('SayHybridStateMachines',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='hybrid_state_machines',
                                           topic=voice_topic),
                                       transitions={'done': 'ComplexMovement'},
                                       autonomy={'done': Autonomy.Off})

            # x:483 y:159
            OperatableStateMachine.add(
                'ComplexMovement',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='look_on_printer_fast',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:308 y:637
            OperatableStateMachine.add('SayControlYou',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='someday_ill_control_you',
                                           topic=voice_topic),
                                       transitions={'done': 'Wait4'},
                                       autonomy={'done': Autonomy.Off})

            # x:506 y:640
            OperatableStateMachine.add('Wait4',
                                       WaitState(wait_time=0.5),
                                       transitions={'done': 'HoofStamp'},
                                       autonomy={'done': Autonomy.Off})

            # x:671 y:625
            OperatableStateMachine.add(
                'HoofStamp',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='hoof_stamp',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:509 y:246
            OperatableStateMachine.add(
                'Seizure',
                ExecuteJointTrajectory(action_topic=joint_trajectory_action,
                                       trajectory_param='seizure',
                                       trajectory_ns=storage),
                transitions={
                    'success': 'finished',
                    'partial_movement': 'failed',
                    'invalid_pose': 'failed',
                    'failure': 'failed'
                },
                autonomy={
                    'success': Autonomy.Off,
                    'partial_movement': Autonomy.Off,
                    'invalid_pose': Autonomy.Off,
                    'failure': Autonomy.Off
                },
                remapping={'result': 'result'})

            # x:324 y:377
            OperatableStateMachine.add(
                'SayHumansAreEverywhere',
                TextCommandState(type='voice/play_wav',
                                 command='humans_are_everywhere',
                                 topic=voice_topic),
                transitions={'done': 'PointOnSomething'},
                autonomy={'done': Autonomy.Off})

            # x:14 y:474
            OperatableStateMachine.add('SetEyesEvil',
                                       TextCommandState(type='eyes/emotion',
                                                        command='red_eyes',
                                                        topic='control'),
                                       transitions={'done': 'RandomEvil'},
                                       autonomy={'done': Autonomy.Off})

            # x:101 y:278
            OperatableStateMachine.add('SetEyesGood',
                                       TextCommandState(type='eyes/emotion',
                                                        command='normal',
                                                        topic='control'),
                                       transitions={'done': 'RandomGood'},
                                       autonomy={'done': Autonomy.Off})

            # x:314 y:39
            OperatableStateMachine.add('SingSong1',
                                       TextCommandState(
                                           type='voice/play_wav',
                                           command='beep_beep_im_a_sheep',
                                           topic=voice_topic),
                                       transitions={'done': 'SlowShake'},
                                       autonomy={'done': Autonomy.Off})

        return _state_machine