Ejemplo n.º 1
0
    def create(self):
        # x:683 y:190, x:133 y:290
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.Direction = 'Right'
        _state_machine.userdata.Turn_Metric = {'x': 1.5, 'y': 1.5}
        _state_machine.userdata.Straight_Metric = 2.0

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:107 y:117
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=1),
                                       transitions={'done': 's1'},
                                       autonomy={'done': Autonomy.Off})

            # x:351 y:109
            OperatableStateMachine.add('s1',
                                       SubscriberState(topic='/pose',
                                                       blocking=True,
                                                       clear=False),
                                       transitions={
                                           'received': 'm1',
                                           'unavailable': 'failed'
                                       },
                                       autonomy={
                                           'received': Autonomy.Off,
                                           'unavailable': Autonomy.Off
                                       },
                                       remapping={'message': 'curr_pose'})

            # x:337 y:412
            OperatableStateMachine.add('w2',
                                       WaitState(wait_time=15),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:331 y:274
            OperatableStateMachine.add('m1',
                                       MoveBaseState(),
                                       transitions={
                                           'arrived': 'w2',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'arrived': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       },
                                       remapping={
                                           'Direction': 'Direction',
                                           'curr_pose': 'curr_pose',
                                           'Turn_Metric': 'Turn_Metric',
                                           'Straight_Metric': 'Straight_Metric'
                                       })

        return _state_machine
    def create(self):
        # x:476 y:530
        _state_machine = OperatableStateMachine(outcomes=['finished'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:215 y:156
            OperatableStateMachine.add('center',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'w2'},
                                       autonomy={'done': Autonomy.Off})

            # x:394 y:262
            OperatableStateMachine.add('right',
                                       SaraSetHeadAngle(pitch=0.1, yaw=-1.5),
                                       transitions={'done': 'w3'},
                                       autonomy={'done': Autonomy.Off})

            # x:206 y:372
            OperatableStateMachine.add('center2',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'w4'},
                                       autonomy={'done': Autonomy.Off})

            # x:47 y:153
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'center'},
                                       autonomy={'done': Autonomy.Off})

            # x:413 y:159
            OperatableStateMachine.add('w2',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'right'},
                                       autonomy={'done': Autonomy.Off})

            # x:415 y:370
            OperatableStateMachine.add('w3',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'center2'},
                                       autonomy={'done': Autonomy.Off})

            # x:39 y:371
            OperatableStateMachine.add('w4',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'left'},
                                       autonomy={'done': Autonomy.Off})

            # x:29 y:274
            OperatableStateMachine.add('left',
                                       SaraSetHeadAngle(pitch=0.1, yaw=1.5),
                                       transitions={'done': 'w1'},
                                       autonomy={'done': Autonomy.Off})

        return _state_machine
Ejemplo n.º 3
0
    def create(self):
        # x:33 y:340, x:133 y:340, x:233 y:340, x:144 y:140
        _state_machine = OperatableStateMachine(
            outcomes=['L_B', 'M_B', 'H_B', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:107 y:24
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=4),
                                       transitions={'done': 's1'},
                                       autonomy={'done': Autonomy.Off})

            # x:351 y:24
            OperatableStateMachine.add('s1',
                                       SubscriberState(topic='/FourWD/battery',
                                                       blocking=True,
                                                       clear=False),
                                       transitions={
                                           'received': 'w2',
                                           'unavailable': 'failed'
                                       },
                                       autonomy={
                                           'received': Autonomy.Off,
                                           'unavailable': Autonomy.Off
                                       },
                                       remapping={'message': 'battery_level'})

            # x:357 y:224
            OperatableStateMachine.add('w2',
                                       WaitState(wait_time=1),
                                       transitions={'done': 'd1'},
                                       autonomy={'done': Autonomy.Off})

            # x:105 y:224
            OperatableStateMachine.add(
                'd1',
                DecisionState(outcomes=['Low', 'Medium', 'High'],
                              conditions=lambda x: 'Low'
                              if x.data < 98 else 'Medium'),
                transitions={
                    'Low': 'L_B',
                    'Medium': 'M_B',
                    'High': 'H_B'
                },
                autonomy={
                    'Low': Autonomy.Off,
                    'Medium': Autonomy.Off,
                    'High': Autonomy.Off
                },
                remapping={'input_value': 'battery_level'})

        return _state_machine
Ejemplo n.º 4
0
	def create(self):
		# x:30 y:365, x:83 y:290
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])

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


		with _state_machine:
			# x:71 y:34
			OperatableStateMachine.add('w1',
										WaitState(wait_time=1),
										transitions={'done': 'battery_check'},
										autonomy={'done': Autonomy.Off})

			# x:169 y:121
			OperatableStateMachine.add('battery_check',
										self.use_behavior(battery_checkSM, 'battery_check'),
										transitions={'L_B': 'battery_in', 'M_B': 'w1', 'H_B': 'w1', 'failed': 'failed'},
										autonomy={'L_B': Autonomy.Inherit, 'M_B': Autonomy.Inherit, 'H_B': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:519 y:271
			OperatableStateMachine.add('battery_check_2',
										self.use_behavior(battery_checkSM, 'battery_check_2'),
										transitions={'L_B': 'w3', 'M_B': 'battery_out', 'H_B': 'battery_out', 'failed': 'failed'},
										autonomy={'L_B': Autonomy.Inherit, 'M_B': Autonomy.Inherit, 'H_B': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:557 y:424
			OperatableStateMachine.add('w3',
										WaitState(wait_time=1),
										transitions={'done': 'battery_check_2'},
										autonomy={'done': Autonomy.Off})

			# x:518 y:138
			OperatableStateMachine.add('battery_in',
										self.use_behavior(battery_inSM, 'battery_in'),
										transitions={'finished': 'battery_check_2', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:251 y:402
			OperatableStateMachine.add('battery_out',
										self.use_behavior(battery_outSM, 'battery_out'),
										transitions={'finished': 'finished', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})


		return _state_machine
Ejemplo n.º 5
0
	def create(self):
		# x:83 y:490, x:83 y:290
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.waypoint_charging = {'coordinate':{'x':0.0, 'y':0.0, 'theta':0.0}, 'increment':{'x':'none', 'y':'none', 'theta':'none'}}
		_state_machine.userdata.curr_pose = 'none'

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


		with _state_machine:
			# x:157 y:74
			OperatableStateMachine.add('w1',
										WaitState(wait_time=1),
										transitions={'done': 'm1'},
										autonomy={'done': Autonomy.Off})

			# x:481 y:74
			OperatableStateMachine.add('m1',
										MoveBaseState(),
										transitions={'arrived': 's1', 'failed': 'failed'},
										autonomy={'arrived': Autonomy.Off, 'failed': Autonomy.Off},
										remapping={'waypoint': 'waypoint_charging', 'curr_pose': 'curr_pose'})

			# x:501 y:174
			OperatableStateMachine.add('s1',
										SubscriberState(topic='/FourWD/battery', blocking=True, clear=False),
										transitions={'received': 'd1', 'unavailable': 'failed'},
										autonomy={'received': Autonomy.Off, 'unavailable': Autonomy.Off},
										remapping={'message': 'battery_level'})

			# x:505 y:424
			OperatableStateMachine.add('d1',
										DecisionState(outcomes=['full', 'not_full'], conditions=lambda x: 'full' if x.data>99.9 else 'not_full'),
										transitions={'full': 'finished', 'not_full': 'w2'},
										autonomy={'full': Autonomy.Off, 'not_full': Autonomy.Off},
										remapping={'input_value': 'battery_level'})

			# x:357 y:324
			OperatableStateMachine.add('w2',
										WaitState(wait_time=1),
										transitions={'done': 's1'},
										autonomy={'done': Autonomy.Off})


		return _state_machine
Ejemplo n.º 6
0
	def create(self):
		# x:658 y:463, x:511 y:525
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])

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


		with _state_machine:
			# x:107 y:167
			OperatableStateMachine.add('w1',
										WaitState(wait_time=1),
										transitions={'done': 'turn_decision'},
										autonomy={'done': Autonomy.Off})

			# x:603 y:148
			OperatableStateMachine.add('go_straight',
										self.use_behavior(go_straightSM, 'go_straight'),
										transitions={'finished': 'w1', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:311 y:265
			OperatableStateMachine.add('turn_decision',
										self.use_behavior(turn_decisionSM, 'turn_decision'),
										transitions={'finished': 'go_straight', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})


		return _state_machine
Ejemplo n.º 7
0
    def create(self):
        log_msg = "Hello World!"
        # x:83 y:390
        _state_machine = OperatableStateMachine(outcomes=['finished'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:52 y:78
            OperatableStateMachine.add(
                'Print_Message',
                LogState(text=log_msg, severity=Logger.REPORT_HINT),
                transitions={'done': 'Wait_After_Logging'},
                autonomy={'done': Autonomy.Low})

            # x:40 y:228
            OperatableStateMachine.add('Wait_After_Logging',
                                       WaitState(wait_time=self.waiting_time),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        return _state_machine
Ejemplo n.º 8
0
	def create(self):
		# x:30 y:365, x:130 y:365
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.waypoint_left = {'coordinate':{'x':'none', 'y':'none', 'theta':'none'}, 'increment':{'x':2.0, 'y':-2.0, 'theta':3.1415/2}}

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


		with _state_machine:
			# x:30 y:40
			OperatableStateMachine.add('w1',
										WaitState(wait_time=1),
										transitions={'done': 's1'},
										autonomy={'done': Autonomy.Off})

			# x:651 y:124
			OperatableStateMachine.add('s1',
										SubscriberState(topic='/pose', blocking=True, clear=False),
										transitions={'received': 'm1', 'unavailable': 'failed'},
										autonomy={'received': Autonomy.Off, 'unavailable': Autonomy.Off},
										remapping={'message': 'curr_pose'})

			# x:181 y:174
			OperatableStateMachine.add('m1',
										MoveBaseState(),
										transitions={'arrived': 'finished', 'failed': 'failed'},
										autonomy={'arrived': Autonomy.Off, 'failed': Autonomy.Off},
										remapping={'waypoint': 'waypoint_left', 'curr_pose': 'curr_pose'})


		return _state_machine
	def create(self):
		# x:30 y:365, x:130 y:365
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])

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


		with _state_machine:
			# x:143 y:127
			OperatableStateMachine.add('wait',
										WaitState(wait_time=self.waiting_time),
										transitions={'done': 'initialize'},
										autonomy={'done': Autonomy.Low})

			# x:280 y:162
			OperatableStateMachine.add('initialize',
										InitializeRobotState(=1),
										transitions={'done': 'finished', 'failed': 'failed'},
										autonomy={'done': Autonomy.Off, 'failed': Autonomy.Off})


		return _state_machine
    def create(self):
        hello = "hello world"
        # x:248 y:340, x:429 y:201
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:182 y:32
            OperatableStateMachine.add('Initial_Wait',
                                       WaitState(wait_time=self.waiting_time),
                                       transitions={'done': 'Print_Greeting'},
                                       autonomy={'done': Autonomy.Off})

            # x:176 y:186
            OperatableStateMachine.add('Print_Greeting',
                                       LogState(text=hello,
                                                severity=Logger.REPORT_HINT),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.High})

        return _state_machine
Ejemplo n.º 11
0
	def create(self):
		# x:30 y:365, x:458 y:366
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.waypoint1 = [0.7081,-2.5405, 0.0]
		_state_machine.userdata.incremental1 = [0.0, 0.0, 0.0]

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


		with _state_machine:
			# x:164 y:156
			OperatableStateMachine.add('w1',
										WaitState(wait_time=3),
										transitions={'done': 'go_to_battery_charging_station'},
										autonomy={'done': Autonomy.Off})

			# x:398 y:156
			OperatableStateMachine.add('go_to_battery_charging_station',
										self.use_behavior(go_to_battery_charging_stationSM, 'go_to_battery_charging_station'),
										transitions={'finished': 'finished', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})


		return _state_machine
    def create(self):
        hello = "Hello World!"
        # x:30 y:365, x:130 y:365
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:129 y:81
            OperatableStateMachine.add('Initial_Wait',
                                       WaitState(wait_time=self.waiting_time),
                                       transitions={'done': 'Hello_Greeting'},
                                       autonomy={'done': Autonomy.Off})

            # x:130 y:215
            OperatableStateMachine.add('Hello_Greeting',
                                       LogState(text=hello,
                                                severity=Logger.REPORT_HINT),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.High})

        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
Ejemplo n.º 14
0
    def create(self):
        # x:541 y:178, x:142 y:179
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['agv_id'])
        _state_machine.userdata.agv_id = ''
        _state_machine.userdata.inspection_result = ''
        _state_machine.userdata.succes = 0
        _state_machine.userdata.agv_state = ''
        _state_machine.userdata.agv_ready_state = 'ready_to_deliver'

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:354 y:27
            OperatableStateMachine.add('AgvState',
                                       GetAgvStatusState(),
                                       transitions={
                                           'continue': 'AGVReady',
                                           'fail': 'failed'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={
                                           'agv_id': 'agv_id',
                                           'agv_state': 'agv_state'
                                       })

            # x:340 y:232
            OperatableStateMachine.add('AGVReady',
                                       EqualState(),
                                       transitions={
                                           'true': 'finished',
                                           'false': 'Wait'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'value_a': 'agv_state',
                                           'value_b': 'agv_ready_state'
                                       })

            # x:266 y:130
            OperatableStateMachine.add('Wait',
                                       WaitState(wait_time=0.2),
                                       transitions={'done': 'AgvState'},
                                       autonomy={'done': Autonomy.Off})

        return _state_machine
Ejemplo n.º 15
0
    def create(self):
        # x:67 y:463, x:336 y:160
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['data'])
        _state_machine.userdata.data = 0

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add('Wait',
                                       WaitState(wait_time=0.5),
                                       transitions={'done': 'Calculate'},
                                       autonomy={'done': Autonomy.Off})

            # x:36 y:240
            OperatableStateMachine.add('Log Param',
                                       flexbe_states__LogState(text=self.param,
                                                               severity=2),
                                       transitions={'done': 'Verify Input'},
                                       autonomy={'done': Autonomy.Off})

            # x:32 y:340
            OperatableStateMachine.add('Verify Input',
                                       DecisionState(
                                           outcomes=['accepted', 'rejected'],
                                           conditions=lambda x: 'accepted'
                                           if x > 3 else 'rejected'),
                                       transitions={
                                           'accepted': 'finished',
                                           'rejected': 'failed'
                                       },
                                       autonomy={
                                           'accepted': Autonomy.Off,
                                           'rejected': Autonomy.Off
                                       },
                                       remapping={'input_value': 'data'})

            # x:28 y:136
            OperatableStateMachine.add(
                'Calculate',
                CalculationState(calculation=self._calculate),
                transitions={'done': 'Log Param'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'data',
                    'output_value': 'data'
                })

        return _state_machine
    def create(self):
        hello = "Hello World"
        # x:30 y:365, x:332 y:473
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:131 y:60
            OperatableStateMachine.add(
                'waiter',
                WaitState(wait_time=self.waiting_time),
                transitions={'done': 'listen for input'},
                autonomy={'done': Autonomy.Off})

            # x:633 y:55
            OperatableStateMachine.add('printer',
                                       LogState(text=hello,
                                                severity=Logger.REPORT_HINT),
                                       transitions={'done': 'phototaker'},
                                       autonomy={'done': Autonomy.Off})

            # x:567 y:320
            OperatableStateMachine.add('phototaker',
                                       TakePhotoState(),
                                       transitions={
                                           'continue': 'finished',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       })

            # x:376 y:48
            OperatableStateMachine.add('listen for input',
                                       ListeningState(),
                                       transitions={
                                           'continue': 'printer',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       })

        return _state_machine
    def create(self):
        # x:599 y:55, x:321 y:144
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.agv_id = 'agv1'
        _state_machine.userdata.shipment_type = 'order_0_shipment_0'

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add(
                'StartAssignment',
                StartAssignment(),
                transitions={'continue': 'SubmitShipment'},
                autonomy={'continue': Autonomy.Off})

            # x:443 y:42
            OperatableStateMachine.add('EndAssignment',
                                       EndAssignment(),
                                       transitions={'continue': 'finished'},
                                       autonomy={'continue': Autonomy.Off})

            # x:322 y:42
            OperatableStateMachine.add('Wait',
                                       WaitState(wait_time=30),
                                       transitions={'done': 'EndAssignment'},
                                       autonomy={'done': Autonomy.Off})

            # x:167 y:42
            OperatableStateMachine.add('SubmitShipment',
                                       SubmitShipmentState(),
                                       transitions={
                                           'continue': 'Wait',
                                           'fail': 'failed'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={
                                           'agv_id': 'agv_id',
                                           'shipment_type': 'shipment_type',
                                           'inspection_result':
                                           'inspection_result'
                                       })

        return _state_machine
Ejemplo n.º 18
0
    def create(self):
        # x:83 y:390, x:33 y:190
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.Direction = 'Stop'

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:201 y:59
            OperatableStateMachine.add('s1',
                                       SubscriberState(topic='/pose',
                                                       blocking=True,
                                                       clear=False),
                                       transitions={
                                           'received': 'm1',
                                           'unavailable': 'failed'
                                       },
                                       autonomy={
                                           'received': Autonomy.Off,
                                           'unavailable': Autonomy.Off
                                       },
                                       remapping={'message': 'curr_pose'})

            # x:207 y:374
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:181 y:224
            OperatableStateMachine.add('m1',
                                       MoveBaseState(),
                                       transitions={
                                           'arrived': 'w1',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'arrived': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       },
                                       remapping={
                                           'Direction': 'Direction',
                                           'curr_pose': 'curr_pose'
                                       })

        return _state_machine
Ejemplo n.º 19
0
    def create(self):
        hello = "baka!!"
        # x:30 y:365, x:130 y:365
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.target_joint = [0, 0, 0]

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add('Initial_Wait',
                                       WaitState(wait_time=self.waiting_time),
                                       transitions={'done': 'test_moveit'},
                                       autonomy={'done': Autonomy.Off})

            # x:27 y:171
            OperatableStateMachine.add('Print_Greeting',
                                       LogState(text=hello,
                                                severity=Logger.REPORT_HINT),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.High})

            # x:172 y:148
            OperatableStateMachine.add(
                'test_moveit',
                MoveitToJointsState(move_group='Gantry',
                                    joint_names=[
                                        "small_long_joint", "torso_rail_joint",
                                        "torso_base_main_joint"
                                    ],
                                    action_topic='/ariac/gantry/move_group'),
                transitions={
                    'reached': 'Print_Greeting',
                    'planning_failed': 'failed',
                    'control_failed': 'failed'
                },
                autonomy={
                    'reached': Autonomy.Off,
                    'planning_failed': Autonomy.Off,
                    'control_failed': Autonomy.Off
                },
                remapping={'joint_config': 'target_joint'})

        return _state_machine
	def create(self):
		# x:744 y:163, x:229 y:196
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.agv_id = "agv1"
		_state_machine.userdata.shipment_type = 'order_0_shepment_0'
		_state_machine.userdata.inspection_result = ""
		_state_machine.userdata.success = 0
		_state_machine.userdata.agv_state = ""
		_state_machine.userdata.agv_ready_state = "ready_to_deliver"

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


		with _state_machine:
			# x:200 y:39
			OperatableStateMachine.add('NotifyShipmentReady',
										NotifyShipmentReadyState(),
										transitions={'continue': 'Wait', 'fail': 'failed'},
										autonomy={'continue': Autonomy.Off, 'fail': Autonomy.Off},
										remapping={'agv_id': 'agv_id', 'shipment_type': 'shipment_type', 'success': 'success', 'message': 'message'})

			# x:523 y:46
			OperatableStateMachine.add('GetAgvState',
										GetAgvStatusState(),
										transitions={'continue': 'AgvReady', 'fail': 'failed'},
										autonomy={'continue': Autonomy.Off, 'fail': Autonomy.Off},
										remapping={'agv_id': 'agv_id', 'agv_state': 'agv_state'})

			# x:503 y:161
			OperatableStateMachine.add('AgvReady',
										EqualState(),
										transitions={'true': 'finished', 'false': 'Wait'},
										autonomy={'true': Autonomy.Off, 'false': Autonomy.Off},
										remapping={'value_a': 'agv_state', 'value_b': 'agv_ready_state'})

			# x:408 y:42
			OperatableStateMachine.add('Wait',
										WaitState(wait_time=1),
										transitions={'done': 'GetAgvState'},
										autonomy={'done': Autonomy.Off})


		return _state_machine
    def create(self):
        # x:30 y:365, x:130 y:365
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add('HSR_Wait',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        return _state_machine
Ejemplo n.º 22
0
	def create(self):
		# x:27 y:469, x:242 y:360
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.powerOn = 100
		_state_machine.userdata.config_name = ''
		_state_machine.userdata.move_group = 'Gantry'
		_state_machine.userdata.move_group_prefix = '/ariac/gantry'
		_state_machine.userdata.action_topic = '/move_group'
		_state_machine.userdata.robot_name = 'gantry'
		_state_machine.userdata.part_type = 'gear_part_red'
		_state_machine.userdata.joint_values = []
		_state_machine.userdata.joint_names = []
		_state_machine.userdata.ref_frame = 'world'
		_state_machine.userdata.camera_topic = ''
		_state_machine.userdata.camera_frame = ''
		_state_machine.userdata.tool_link_r = 'right_ee_link'
		_state_machine.userdata.pose = ''
		_state_machine.userdata.rotation = 0
		_state_machine.userdata.move_groupR = 'Right_Arm'
		_state_machine.userdata.arm_id_r = 'Right_Arm'

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


		with _state_machine:
			# x:230 y:22
			OperatableStateMachine.add('move_home_belt',
										self.use_behavior(move_home_beltSM, 'move_home_belt'),
										transitions={'finished': 'finished', 'failed': 'Waitretry'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit})

			# x:810 y:40
			OperatableStateMachine.add('Waitretry',
										WaitState(wait_time=2),
										transitions={'done': 'move_home_belt'},
										autonomy={'done': Autonomy.Off})


		return _state_machine
Ejemplo n.º 23
0
    def create(self):
        # x:733 y:490, x:733 y:140
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:107 y:124
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=3),
                                       transitions={'done': 's1'},
                                       autonomy={'done': Autonomy.Off})

            # x:501 y:224
            OperatableStateMachine.add('s1',
                                       SubscriberState(
                                           topic='/darknet_ros/bounding_boxes',
                                           blocking=True,
                                           clear=True),
                                       transitions={
                                           'received': 'c1',
                                           'unavailable': 'failed'
                                       },
                                       autonomy={
                                           'received': Autonomy.Off,
                                           'unavailable': Autonomy.Off
                                       },
                                       remapping={'message': 'detection'})

            # x:343 y:474
            OperatableStateMachine.add('c1',
                                       Carbonara(),
                                       transitions={'done': 'w1'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'input_value': 'detection'})

        return _state_machine
	def create(self):
		# x:472 y:615, x:38 y:355
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])
		_state_machine.userdata.part_type = part_type
		_state_machine.userdata.agv_id = agv_id
		_state_machine.userdata.pose_on_agv = pose_on_agv

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


		with _state_machine:
			# x:427 y:22
			OperatableStateMachine.add('standby',
										WaitState(wait_time=3),
										transitions={'done': 'Get_order'},
										autonomy={'done': Autonomy.Off})

			# x:399 y:103
			OperatableStateMachine.add('Get_order',
										GetOrderState(),
										transitions={'continue': 'transport_part_form_bin_to_agv_state'},
										autonomy={'continue': Autonomy.Off},
										remapping={'order_id': 'order_id', 'shipments': 'shipments', 'number_of_shipments': 'number_of_shipments'})

			# x:368 y:302
			OperatableStateMachine.add('transport_part_form_bin_to_agv_state',
										self.use_behavior(transport_part_form_bin_to_agv_stateSM, 'transport_part_form_bin_to_agv_state'),
										transitions={'finished': 'finished', 'failed': 'failed'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'part_type': 'part_type', 'agv_id': 'agv_id', 'pose_on_agv': 'pose_on_agv'})


		return _state_machine
    def create(self):
        # x:30 y:365, x:130 y:365
        _state_machine = OperatableStateMachine(outcomes=['finished', 'failed'])

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


        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add('Log',
                                        flexbe_states__LogState(text="Test data", severity=2),
                                        transitions={'done': 'Wait'},
                                        autonomy={'done': Autonomy.Off})
            # x:30 y:90
            OperatableStateMachine.add('Wait',
                                        WaitState(wait_time=1.0),
                                        transitions={'done': 'finished'},
                                        autonomy={'done': Autonomy.Off})


        return _state_machine
Ejemplo n.º 26
0
    def create(self):
        # x:894 y:460, x:898 y:340
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'],
            input_keys=[
                'bin_id', 'camera_topic', 'camera_frame', 'part_type',
                'PreGraspGantry', 'offset'
            ])
        _state_machine.userdata.bin_id = ''
        _state_machine.userdata.home_gantry_id = 'Gantry_Home'
        _state_machine.userdata.home_rightarm_id = 'Right_PreGrasp'
        _state_machine.userdata.home_leftarm_id = 'Left_PreGrasp'
        _state_machine.userdata.move_group_right = 'Right_Arm'
        _state_machine.userdata.move_group_prefix = '/ariac/gantry'
        _state_machine.userdata.action_topic = '/move_group'
        _state_machine.userdata.robot_name = ''
        _state_machine.userdata.move_group_left = 'Left_Arm'
        _state_machine.userdata.move_group_gantry = 'Gantry'
        _state_machine.userdata.ref_frame = 'world'
        _state_machine.userdata.camera_topic = ''
        _state_machine.userdata.camera_frame = ''
        _state_machine.userdata.part_type = ''
        _state_machine.userdata.PreGraspGantry = ''
        _state_machine.userdata.SafePosition = 'Gantry_ShelfSAFE'
        _state_machine.userdata.tool_link = 'left_ee_link'
        _state_machine.userdata.rotation = 0
        _state_machine.userdata.offset = ''
        _state_machine.userdata.arm_id = 'left_arm'
        _state_machine.userdata.PreGrasp_RightArm = 'Right_Shelf'
        _state_machine.userdata.PreGrasp_LeftArm = 'Left_Shelf'
        _state_machine.userdata.SafePositionConveyor = 'Gantry_Shelf_Conveyor'

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:29 y:124
            OperatableStateMachine.add('HomepositieRightArm',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'HomepositieLeftArm',
                                           'planning_failed': 'Retry_1',
                                           'control_failed': 'Retry_1',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'home_rightarm_id',
                                           'move_group': 'move_group_right',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:213 y:119
            OperatableStateMachine.add('HomepositieLeftArm',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'DetectPart',
                                           'planning_failed': 'Retry_2',
                                           'control_failed': 'Retry_2',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'home_leftarm_id',
                                           'move_group': 'move_group_left',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:46 y:34
            OperatableStateMachine.add(
                'Retry_1',
                WaitState(wait_time=3),
                transitions={'done': 'HomepositieRightArm'},
                autonomy={'done': Autonomy.Off})

            # x:230 y:33
            OperatableStateMachine.add(
                'Retry_2',
                WaitState(wait_time=3),
                transitions={'done': 'HomepositieLeftArm'},
                autonomy={'done': Autonomy.Off})

            # x:392 y:114
            OperatableStateMachine.add(
                'DetectPart',
                DetectPartCameraAriacState(time_out=0.5),
                transitions={
                    'continue': 'SafePosition_Conveyor',
                    'failed': 'failed',
                    'not_found': 'failed'
                },
                autonomy={
                    'continue': Autonomy.Off,
                    'failed': Autonomy.Off,
                    'not_found': Autonomy.Off
                },
                remapping={
                    'ref_frame': 'ref_frame',
                    'camera_topic': 'camera_topic',
                    'camera_frame': 'camera_frame',
                    'part': 'part_type',
                    'pose': 'part_pose'
                })

            # x:1279 y:116
            OperatableStateMachine.add('PreGraspGantry',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'ComputePick',
                                           'planning_failed': 'Retry_6',
                                           'control_failed': 'Retry_6',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'PreGraspGantry',
                                           'move_group': 'move_group_gantry',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1304 y:30
            OperatableStateMachine.add('Retry_6',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'PreGraspGantry'},
                                       autonomy={'done': Autonomy.Off})

            # x:736 y:114
            OperatableStateMachine.add('SafePosition',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'PreGrasp_RightArm',
                                           'planning_failed': 'Retry_3',
                                           'control_failed': 'Retry_3',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'SafePosition',
                                           'move_group': 'move_group_gantry',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:763 y:21
            OperatableStateMachine.add('Retry_3',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'SafePosition'},
                                       autonomy={'done': Autonomy.Off})

            # x:1463 y:117
            OperatableStateMachine.add(
                'ComputePick',
                ComputeGraspAriacState(joint_names=[
                    'left_shoulder_pan_joint', 'left_shoulder_lift_joint',
                    'left_elbow_joint', 'left_wrist_1_joint',
                    'left_wrist_2_joint', 'left_wrist_3_joint'
                ]),
                transitions={
                    'continue': 'MoveToPick',
                    'failed': 'failed'
                },
                autonomy={
                    'continue': Autonomy.Off,
                    'failed': Autonomy.Off
                },
                remapping={
                    'move_group': 'move_group_left',
                    'move_group_prefix': 'move_group_prefix',
                    'tool_link': 'tool_link',
                    'pose': 'part_pose',
                    'offset': 'offset',
                    'rotation': 'rotation',
                    'joint_values': 'joint_values',
                    'joint_names': 'joint_names'
                })

            # x:1645 y:117
            OperatableStateMachine.add('MoveToPick',
                                       MoveitToJointsDynAriacState(),
                                       transitions={
                                           'reached': 'GripperOn',
                                           'planning_failed': 'Retry_7',
                                           'control_failed': 'GripperOn'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off
                                       },
                                       remapping={
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'move_group': 'move_group_left',
                                           'action_topic': 'action_topic',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1679 y:35
            OperatableStateMachine.add('Retry_7',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'MoveToPick'},
                                       autonomy={'done': Autonomy.Off})

            # x:1465 y:242
            OperatableStateMachine.add('GripperOn',
                                       VacuumGripperControlState(enable=True),
                                       transitions={
                                           'continue': 'PreGraspLeftArm',
                                           'failed': 'ComputePick',
                                           'invalid_arm_id': 'failed'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'failed': Autonomy.Off,
                                           'invalid_arm_id': Autonomy.Off
                                       },
                                       remapping={'arm_id': 'arm_id'})

            # x:1480 y:333
            OperatableStateMachine.add('PreGraspLeftArm',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'SafePosition_2',
                                           'planning_failed': 'Retry_8',
                                           'control_failed': 'Retry_8',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'PreGrasp_LeftArm',
                                           'move_group': 'move_group_left',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1697 y:328
            OperatableStateMachine.add('Retry_8',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'PreGraspLeftArm'},
                                       autonomy={'done': Autonomy.Off})

            # x:1479 y:426
            OperatableStateMachine.add('SafePosition_2',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached':
                                           'SafePosition_Conveyor_2',
                                           'planning_failed': 'Retry_9',
                                           'control_failed': 'Retry_9',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'SafePosition',
                                           'move_group': 'move_group_gantry',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1700 y:427
            OperatableStateMachine.add('Retry_9',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'SafePosition_2'},
                                       autonomy={'done': Autonomy.Off})

            # x:924 y:115
            OperatableStateMachine.add('PreGrasp_RightArm',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'PreGrasp_LeftArm',
                                           'planning_failed': 'Retry_4',
                                           'control_failed': 'Retry_4',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'PreGrasp_RightArm',
                                           'move_group': 'move_group_right',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1103 y:113
            OperatableStateMachine.add('PreGrasp_LeftArm',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'PreGraspGantry',
                                           'planning_failed': 'Retry_5',
                                           'control_failed': 'Retry_5',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name': 'PreGrasp_LeftArm',
                                           'move_group': 'move_group_left',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:948 y:23
            OperatableStateMachine.add(
                'Retry_4',
                WaitState(wait_time=3),
                transitions={'done': 'PreGrasp_RightArm'},
                autonomy={'done': Autonomy.Off})

            # x:1126 y:21
            OperatableStateMachine.add(
                'Retry_5',
                WaitState(wait_time=3),
                transitions={'done': 'PreGrasp_LeftArm'},
                autonomy={'done': Autonomy.Off})

            # x:1479 y:517
            OperatableStateMachine.add('SafePosition_Conveyor_2',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'finished',
                                           'planning_failed': 'Retry_10',
                                           'control_failed': 'Retry_10',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name':
                                           'SafePositionConveyor',
                                           'move_group': 'move_group_gantry',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:1700 y:541
            OperatableStateMachine.add(
                'Retry_10',
                WaitState(wait_time=3),
                transitions={'done': 'SafePosition_Conveyor_2'},
                autonomy={'done': Autonomy.Off})

            # x:576 y:110
            OperatableStateMachine.add('SafePosition_Conveyor',
                                       SrdfStateToMoveitAriac(),
                                       transitions={
                                           'reached': 'SafePosition',
                                           'planning_failed': 'Retry_3_2',
                                           'control_failed': 'Retry_3_2',
                                           'param_error': 'failed'
                                       },
                                       autonomy={
                                           'reached': Autonomy.Off,
                                           'planning_failed': Autonomy.Off,
                                           'control_failed': Autonomy.Off,
                                           'param_error': Autonomy.Off
                                       },
                                       remapping={
                                           'config_name':
                                           'SafePositionConveyor',
                                           'move_group': 'move_group_gantry',
                                           'move_group_prefix':
                                           'move_group_prefix',
                                           'action_topic': 'action_topic',
                                           'robot_name': 'robot_name',
                                           'config_name_out':
                                           'config_name_out',
                                           'move_group_out': 'move_group_out',
                                           'robot_name_out': 'robot_name_out',
                                           'action_topic_out':
                                           'action_topic_out',
                                           'joint_values': 'joint_values',
                                           'joint_names': 'joint_names'
                                       })

            # x:588 y:23
            OperatableStateMachine.add(
                'Retry_3_2',
                WaitState(wait_time=3),
                transitions={'done': 'SafePosition_Conveyor'},
                autonomy={'done': Autonomy.Off})

        return _state_machine
Ejemplo n.º 27
0
    def create(self):
        # x:1474 y:331, x:56 y:575
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.half_turn = 3.1416
        _state_machine.userdata.person = "person"
        _state_machine.userdata.operator_param = "behavior/Operaror/Id"
        _state_machine.userdata.join = ["Move", "spr/initialpose"]
        _state_machine.userdata.leave = ["Move", "door2/exit"]

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

        # [/MANUAL_CREATE]

        # x:1182 y:163
        _sm_rotate_0 = OperatableStateMachine(outcomes=['finished'])

        with _sm_rotate_0:
            # x:103 y:61
            OperatableStateMachine.add('Look Left',
                                       SaraSetHeadAngle(pitch=-0.35, yaw=0.5),
                                       transitions={'done': 'Rotate Left'},
                                       autonomy={'done': Autonomy.Off})

            # x:794 y:54
            OperatableStateMachine.add('Look Right',
                                       SaraSetHeadAngle(pitch=-0.35, yaw=-0.5),
                                       transitions={'done': 'Rotate Right'},
                                       autonomy={'done': Autonomy.Off})

            # x:325 y:61
            OperatableStateMachine.add('Rotate Left',
                                       WaitState(wait_time=8),
                                       transitions={'done': 'Look Center'},
                                       autonomy={'done': Autonomy.Off})

            # x:961 y:65
            OperatableStateMachine.add('Rotate Right',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'Look Center 2'},
                                       autonomy={'done': Autonomy.Off})

            # x:1115 y:62
            OperatableStateMachine.add('Look Center 2',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:484 y:54
            OperatableStateMachine.add('Look Center',
                                       SaraSetHeadAngle(pitch=-0.35, yaw=0),
                                       transitions={'done': 'Rotate Center'},
                                       autonomy={'done': Autonomy.Off})

            # x:657 y:49
            OperatableStateMachine.add('Rotate Center',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'Look Right'},
                                       autonomy={'done': Autonomy.Off})

        # x:30 y:458
        _sm_follow_head_1 = OperatableStateMachine(outcomes=['end'],
                                                   input_keys=['person'])

        with _sm_follow_head_1:
            # x:214 y:48
            OperatableStateMachine.add('list all entities',
                                       list_entities_by_name(
                                           frontality_level=0.5,
                                           distance_max=10),
                                       transitions={
                                           'found': 'Get Nearest',
                                           'none_found': 'list all entities'
                                       },
                                       autonomy={
                                           'found': Autonomy.Off,
                                           'none_found': Autonomy.Off
                                       },
                                       remapping={
                                           'name': 'person',
                                           'entity_list': 'entity_list',
                                           'number': 'number'
                                       })

            # x:456 y:51
            OperatableStateMachine.add(
                'Get Nearest',
                CalculationState(calculation=lambda x: x[0].ID),
                transitions={'done': 'look'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'entity_list',
                    'output_value': 'ID'
                })

            # x:291 y:177
            OperatableStateMachine.add(
                'look',
                KeepLookingAt(),
                transitions={'failed': 'list all entities'},
                autonomy={'failed': Autonomy.Off},
                remapping={'ID': 'ID'})

        # x:12 y:125, x:1130 y:515
        _sm_nlu_2 = OperatableStateMachine(outcomes=['finished', 'failed'])

        with _sm_nlu_2:
            # x:156 y:37
            OperatableStateMachine.add(
                'say ask',
                SaraSay(sentence="You can ask me your questions.",
                        input_keys=[],
                        emotion=1,
                        block=True),
                transitions={'done': 'Loop Questions'},
                autonomy={'done': Autonomy.Off})

            # x:1091 y:84
            OperatableStateMachine.add('Listen',
                                       GetSpeech(watchdog=10),
                                       transitions={
                                           'done': 'Engine',
                                           'nothing': 'Listen',
                                           'fail': 'Listen'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'nothing': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={'words': 'sentence'})

            # x:1324 y:110
            OperatableStateMachine.add('Engine',
                                       SaraNLUspr(),
                                       transitions={
                                           'understood': 'Say_Answer',
                                           'not_understood': 'Listen',
                                           'fail': 'Listen'
                                       },
                                       autonomy={
                                           'understood': Autonomy.Off,
                                           'not_understood': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={
                                           'sentence': 'sentence',
                                           'answer': 'answer'
                                       })

            # x:632 y:77
            OperatableStateMachine.add(
                'Select Story',
                CalculationState(calculation=lambda x: x + 6),
                transitions={'done': 'Set_a_step'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'index',
                    'output_value': 'story'
                })

            # x:874 y:78
            OperatableStateMachine.add('Set_a_step',
                                       Set_a_step(step=1),
                                       transitions={'done': 'Listen'},
                                       autonomy={'done': Autonomy.Off})

            # x:398 y:81
            OperatableStateMachine.add('Loop Questions',
                                       ForLoop(repeat=5),
                                       transitions={
                                           'do': 'Select Story',
                                           'end': 'loop step'
                                       },
                                       autonomy={
                                           'do': Autonomy.Off,
                                           'end': Autonomy.Off
                                       },
                                       remapping={'index': 'index'})

            # x:439 y:252
            OperatableStateMachine.add(
                'Say Blind Game',
                SaraSay(sentence="Let's play the blind game !",
                        input_keys=[],
                        emotion=1,
                        block=True),
                transitions={'done': 'Loop Questions'},
                autonomy={'done': Autonomy.Off})

            # x:189 y:193
            OperatableStateMachine.add('loop step',
                                       ForLoop(repeat=1),
                                       transitions={
                                           'do': 'Say Blind Game',
                                           'end': 'finished'
                                       },
                                       autonomy={
                                           'do': Autonomy.Off,
                                           'end': Autonomy.Off
                                       },
                                       remapping={'index': 'index'})

            # x:721 y:205
            OperatableStateMachine.add('Say_Answer',
                                       SaraSay(sentence=lambda x: str(x),
                                               input_keys=[],
                                               emotion=0,
                                               block=True),
                                       transitions={'done': 'Loop Questions'},
                                       autonomy={'done': Autonomy.Off})

        # x:817 y:123, x:130 y:458
        _sm_analyse_crowd_3 = OperatableStateMachine(
            outcomes=['finished', 'error'])

        with _sm_analyse_crowd_3:
            # x:87 y:97
            OperatableStateMachine.add('clear database',
                                       WonderlandClearPeoples(),
                                       transitions={
                                           'done': 'Rotate',
                                           'error': 'error'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'error': Autonomy.Off
                                       })

            # x:531 y:112
            OperatableStateMachine.add('Add Update Persons',
                                       WonderlandAddUpdatePeople(),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:311 y:97
            OperatableStateMachine.add(
                'Rotate',
                _sm_rotate_0,
                transitions={'finished': 'Add Update Persons'},
                autonomy={'finished': Autonomy.Inherit})

        # x:1203 y:11, x:1006 y:366
        _sm_init_scenario_4 = OperatableStateMachine(
            outcomes=['done', 'error'])

        with _sm_init_scenario_4:
            # x:30 y:42
            OperatableStateMachine.add(
                'Generate Vizbox Story',
                Set_Story(titre="Speech and Person Recognition",
                          storyline=[
                              "Waiting Begining", "Join Game Room",
                              "Waiting Crowd Placement", "Analysing Crowd",
                              "Begin Game", "Find Operator", "Question 1",
                              "Question 2", "Question 3", "Question 4",
                              "Question 5", "Leave Arena"
                          ]),
                transitions={'done': 'Set Story Step'},
                autonomy={'done': Autonomy.Off})

            # x:559 y:44
            OperatableStateMachine.add('WaitForBegining',
                                       ContinueButton(),
                                       transitions={
                                           'true': 'Reset Persons',
                                           'false': 'Reset Persons'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       })

            # x:807 y:61
            OperatableStateMachine.add('Reset Persons',
                                       WonderlandClearPeoples(),
                                       transitions={
                                           'done': 'done',
                                           'error': 'error'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'error': Autonomy.Off
                                       })

            # x:247 y:49
            OperatableStateMachine.add('Set Story Step',
                                       Set_a_step(step=0),
                                       transitions={'done': 'setIDLE'},
                                       autonomy={'done': Autonomy.Off})

            # x:388 y:208
            OperatableStateMachine.add('Reset Arm',
                                       MoveitMove(move=True,
                                                  waitForExecution=True,
                                                  group="RightArm"),
                                       transitions={
                                           'done': 'Reset Persons',
                                           'failed': 'error'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'failed': Autonomy.Off
                                       },
                                       remapping={'target': 'target'})

            # x:427 y:40
            OperatableStateMachine.add('setIDLE',
                                       SetKey(Value="IdlePose"),
                                       transitions={'done': 'Reset Arm'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'Key': 'target'})

        # x:30 y:458, x:230 y:458
        _sm_join_area_5 = OperatableStateMachine(
            outcomes=['failed', 'finished'], input_keys=['join'])

        with _sm_join_area_5:
            # x:95 y:40
            OperatableStateMachine.add(
                'Say Join Area',
                SaraSay(sentence="I will join the playing room !",
                        input_keys=[],
                        emotion=1,
                        block=True),
                transitions={'done': 'Join Arena'},
                autonomy={'done': Autonomy.Off})

            # x:92 y:134
            OperatableStateMachine.add(
                'Join Arena',
                self.use_behavior(sara_flexbe_behaviors__ActionWrapper_MoveSM,
                                  'Join Area/Join Arena'),
                transitions={
                    'finished': 'finished',
                    'failed': 'failed',
                    'critical_fail': 'failed'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit,
                    'critical_fail': Autonomy.Inherit
                },
                remapping={'Action': 'join'})

        # x:489 y:56, x:604 y:278
        _sm_waiting_and_turn_6 = OperatableStateMachine(
            outcomes=['finished', 'failed'], input_keys=['half_turn'])

        with _sm_waiting_and_turn_6:
            # x:50 y:51
            OperatableStateMachine.add(
                'Want Play',
                SaraSay(sentence="Hum, I want to play riddles !",
                        input_keys=[],
                        emotion=1,
                        block=True),
                transitions={'done': 'Wait 10s'},
                autonomy={'done': Autonomy.Off})

            # x:272 y:121
            OperatableStateMachine.add(
                'action_turn',
                self.use_behavior(sara_flexbe_behaviors__action_turnSM,
                                  'Waiting And Turn/action_turn'),
                transitions={
                    'finished': 'finished',
                    'failed': 'Cant turn'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                },
                remapping={'rotation': 'half_turn'})

            # x:437 y:240
            OperatableStateMachine.add('Cant turn',
                                       SaraSay(sentence="I can't turn !",
                                               input_keys=[],
                                               emotion=1,
                                               block=True),
                                       transitions={'done': 'failed'},
                                       autonomy={'done': Autonomy.Off})

            # x:63 y:178
            OperatableStateMachine.add(
                'Wait 10s',
                WaitState(wait_time=10),
                transitions={'done': 'Look In Front Of'},
                autonomy={'done': Autonomy.Off})

            # x:61 y:260
            OperatableStateMachine.add('Look In Front Of',
                                       SaraSetHeadAngle(pitch=0, yaw=0),
                                       transitions={'done': 'action_turn'},
                                       autonomy={'done': Autonomy.Off})

        # x:472 y:69, x:476 y:113, x:470 y:196, x:330 y:458, x:430 y:458
        _sm_questions_7 = ConcurrencyContainer(
            outcomes=['finished', 'failed'],
            input_keys=['person'],
            conditions=[('finished', [('NLU', 'finished')]),
                        ('failed', [('NLU', 'failed')]),
                        ('finished', [('Follow Head', 'end')])])

        with _sm_questions_7:
            # x:85 y:58
            OperatableStateMachine.add('NLU',
                                       _sm_nlu_2,
                                       transitions={
                                           'finished': 'finished',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       })

            # x:84 y:185
            OperatableStateMachine.add('Follow Head',
                                       _sm_follow_head_1,
                                       transitions={'end': 'finished'},
                                       autonomy={'end': Autonomy.Inherit},
                                       remapping={'person': 'person'})

        # x:283 y:294, x:60 y:571
        _sm_find_operator_8 = OperatableStateMachine(
            outcomes=['not_found', 'done'],
            input_keys=['person', 'operator_param'])

        with _sm_find_operator_8:
            # x:51 y:40
            OperatableStateMachine.add(
                'Ask Player',
                SaraSay(sentence="Who wan't to play with me ?",
                        input_keys=[],
                        emotion=1,
                        block=True),
                transitions={'done': 'Wait Operator'},
                autonomy={'done': Autonomy.Off})

            # x:39 y:297
            OperatableStateMachine.add(
                'Get operator id',
                CalculationState(calculation=lambda x: x.entities[0].face.id),
                transitions={'done': 'Set Operator Id'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'entity_list',
                    'output_value': 'operator'
                })

            # x:33 y:384
            OperatableStateMachine.add('Set Operator Id',
                                       SetRosParamKey(),
                                       transitions={'done': 'Operator Id'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={
                                           'Value': 'operator_param',
                                           'ParamName': 'operator'
                                       })

            # x:46 y:117
            OperatableStateMachine.add('Wait Operator',
                                       WaitState(wait_time=6),
                                       transitions={'done': 'Find Operator'},
                                       autonomy={'done': Autonomy.Off})

            # x:35 y:495
            OperatableStateMachine.add('Operator Id',
                                       LogKeyState(
                                           text="Operator find. Id: {}",
                                           severity=Logger.REPORT_HINT),
                                       transitions={'done': 'done'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'data': 'operator'})

            # x:30 y:205
            OperatableStateMachine.add('Find Operator',
                                       list_entities_by_name(
                                           frontality_level=0.5,
                                           distance_max=10),
                                       transitions={
                                           'found': 'Get operator id',
                                           'none_found': 'Find Operator'
                                       },
                                       autonomy={
                                           'found': Autonomy.Off,
                                           'none_found': Autonomy.Off
                                       },
                                       remapping={
                                           'name': 'person',
                                           'entity_list': 'entity_list',
                                           'number': 'number'
                                       })

        # x:703 y:198, x:88 y:199
        _sm_tell_basic_stats_9 = OperatableStateMachine(
            outcomes=['finished', 'failed'])

        with _sm_tell_basic_stats_9:
            # x:50 y:40
            OperatableStateMachine.add('wait',
                                       WaitState(wait_time=0),
                                       transitions={'done': 'GetPeopleStats'},
                                       autonomy={'done': Autonomy.Off})

            # x:218 y:43
            OperatableStateMachine.add('GetPeopleStats',
                                       WonderlandGetPersonStat(),
                                       transitions={
                                           'done': 'GenerateSentence',
                                           'none': 'Nobody',
                                           'error': 'failed'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'none': Autonomy.Off,
                                           'error': Autonomy.Off
                                       },
                                       remapping={
                                           'women': 'women',
                                           'men': 'men',
                                           'others': 'others'
                                       })

            # x:466 y:46
            OperatableStateMachine.add('Nobody',
                                       SaraSay(
                                           sentence="There is nobody here !",
                                           input_keys=[],
                                           emotion=1,
                                           block=True),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:162 y:243
            OperatableStateMachine.add(
                'GenerateSentence',
                FlexibleCalculationState(calculation=lambda x: "There is " +
                                         str(x[0] + x[1] + x[2]) + " persons.",
                                         input_keys=['men', 'women',
                                                     'others']),
                transitions={'done': 'Tell_Stats'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'men': 'men',
                    'women': 'women',
                    'others': 'others',
                    'output_value': 'sentence'
                })

            # x:151 y:345
            OperatableStateMachine.add(
                'Generate Sentence 2',
                FlexibleCalculationState(
                    calculation=lambda x: "I recognize " + str(x[
                        1]) + " women and " + str(x[0]) + " men.",
                    input_keys=['men', 'women', 'others']),
                transitions={'done': 'Tell_Stats 2'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'men': 'men',
                    'women': 'women',
                    'others': 'others',
                    'output_value': 'sentence'
                })

            # x:380 y:172
            OperatableStateMachine.add(
                'Tell_Stats',
                SaraSay(sentence=lambda x: x,
                        input_keys=[],
                        emotion=0,
                        block=True),
                transitions={'done': 'Generate Sentence 2'},
                autonomy={'done': Autonomy.Off})

            # x:409 y:276
            OperatableStateMachine.add('Tell_Stats 2',
                                       SaraSay(sentence=lambda x: x,
                                               input_keys=[],
                                               emotion=0,
                                               block=True),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        with _state_machine:
            # x:30 y:40
            OperatableStateMachine.add('continue',
                                       ContinueButton(),
                                       transitions={
                                           'true': 'Init Scenario',
                                           'false': 'Init Scenario'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       })

            # x:715 y:127
            OperatableStateMachine.add('Tell basic stats',
                                       _sm_tell_basic_stats_9,
                                       transitions={
                                           'finished': 'Set Find Operator',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       })

            # x:899 y:126
            OperatableStateMachine.add('Find Operator',
                                       _sm_find_operator_8,
                                       transitions={
                                           'not_found': 'Find Operator',
                                           'done': 'Questions'
                                       },
                                       autonomy={
                                           'not_found': Autonomy.Inherit,
                                           'done': Autonomy.Inherit
                                       },
                                       remapping={
                                           'person': 'person',
                                           'operator_param': 'operator_param'
                                       })

            # x:1120 y:126
            OperatableStateMachine.add('Questions',
                                       _sm_questions_7,
                                       transitions={
                                           'finished': 'set head',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       },
                                       remapping={'person': 'person'})

            # x:343 y:49
            OperatableStateMachine.add(
                'Set Story Waiting',
                Set_a_step(step=2),
                transitions={'done': 'Waiting And Turn'},
                autonomy={'done': Autonomy.Off})

            # x:532 y:48
            OperatableStateMachine.add('Set Analyse',
                                       Set_a_step(step=3),
                                       transitions={'done': 'Analyse Crowd'},
                                       autonomy={'done': Autonomy.Off})

            # x:696 y:47
            OperatableStateMachine.add(
                'Set Begin Game',
                Set_a_step(step=4),
                transitions={'done': 'Tell basic stats'},
                autonomy={'done': Autonomy.Off})

            # x:899 y:49
            OperatableStateMachine.add('Set Find Operator',
                                       Set_a_step(step=5),
                                       transitions={'done': 'Find Operator'},
                                       autonomy={'done': Autonomy.Off})

            # x:332 y:127
            OperatableStateMachine.add('Waiting And Turn',
                                       _sm_waiting_and_turn_6,
                                       transitions={
                                           'finished': 'Set Analyse',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       },
                                       remapping={'half_turn': 'half_turn'})

            # x:1333 y:232
            OperatableStateMachine.add('Set Go Out',
                                       Set_a_step(step=11),
                                       transitions={'done': 'Say And Of Game'},
                                       autonomy={'done': Autonomy.Off})

            # x:1517 y:148
            OperatableStateMachine.add(
                'Leave Arena',
                self.use_behavior(sara_flexbe_behaviors__ActionWrapper_MoveSM,
                                  'Leave Arena'),
                transitions={
                    'finished': 'finished',
                    'failed': 'finished',
                    'critical_fail': 'finished'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit,
                    'critical_fail': Autonomy.Inherit
                },
                remapping={'Action': 'leave'})

            # x:176 y:42
            OperatableStateMachine.add(
                'Set Join',
                Set_a_step(step=1),
                transitions={'done': 'Set Story Waiting'},
                autonomy={'done': Autonomy.Off})

            # x:177 y:120
            OperatableStateMachine.add('Join Area',
                                       _sm_join_area_5,
                                       transitions={
                                           'failed': 'failed',
                                           'finished': 'Set Story Waiting'
                                       },
                                       autonomy={
                                           'failed': Autonomy.Inherit,
                                           'finished': Autonomy.Inherit
                                       },
                                       remapping={'join': 'join'})

            # x:1302 y:140
            OperatableStateMachine.add(
                'Say And Of Game',
                SaraSay(
                    sentence=
                    "The game is finished. I will leave the arena. Thank you for playing with me.",
                    input_keys=[],
                    emotion=1,
                    block=True),
                transitions={'done': 'Leave Arena'},
                autonomy={'done': Autonomy.Off})

            # x:1120 y:237
            OperatableStateMachine.add('set head',
                                       SaraSetHeadAngle(pitch=-0.2, yaw=0),
                                       transitions={'done': 'Set Go Out'},
                                       autonomy={'done': Autonomy.Off})

            # x:34 y:130
            OperatableStateMachine.add('Init Scenario',
                                       _sm_init_scenario_4,
                                       transitions={
                                           'done': 'Set Join',
                                           'error': 'failed'
                                       },
                                       autonomy={
                                           'done': Autonomy.Inherit,
                                           'error': Autonomy.Inherit
                                       })

            # x:517 y:124
            OperatableStateMachine.add('Analyse Crowd',
                                       _sm_analyse_crowd_3,
                                       transitions={
                                           'finished': 'Set Begin Game',
                                           'error': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'error': Autonomy.Inherit
                                       })

        return _state_machine
	def create(self):
		# x:93 y:313, x:514 y:143
		_state_machine = OperatableStateMachine(outcomes=['found', 'not_found'], input_keys=['className', 'personID'], output_keys=['personEntity'])
		_state_machine.userdata.className = "person"
		_state_machine.userdata.personID = 0
		_state_machine.userdata.personEntity = ""

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

		# [/MANUAL_CREATE]

		# x:707 y:760
		_sm_rotation_0 = OperatableStateMachine(outcomes=['end'], output_keys=['personEntity'])

		with _sm_rotation_0:
			# x:51 y:38
			OperatableStateMachine.add('Set 180 degres',
										SetKey(Value=3.1416),
										transitions={'done': 'set cpt to 0'},
										autonomy={'done': Autonomy.Off},
										remapping={'Key': 'rotation'})

			# x:613 y:470
			OperatableStateMachine.add('action_turn',
										self.use_behavior(sara_flexbe_behaviors__action_turnSM, 'Container/Rotation/action_turn'),
										transitions={'finished': 'check is cpt is 1', 'failed': 'check is cpt is 1'},
										autonomy={'finished': Autonomy.Inherit, 'failed': Autonomy.Inherit},
										remapping={'rotation': 'rotation'})

			# x:421 y:54
			OperatableStateMachine.add('Look Right',
										SaraSetHeadAngle(pitch=0.1, yaw=-1.5),
										transitions={'done': 'w2'},
										autonomy={'done': Autonomy.Off})

			# x:265 y:56
			OperatableStateMachine.add('w1',
										WaitState(wait_time=4),
										transitions={'done': 'Look Right'},
										autonomy={'done': Autonomy.Off})

			# x:630 y:56
			OperatableStateMachine.add('w2',
										WaitState(wait_time=4),
										transitions={'done': 'center'},
										autonomy={'done': Autonomy.Off})

			# x:250 y:177
			OperatableStateMachine.add('Look Center',
										SaraSetHeadAngle(pitch=0.1, yaw=0),
										transitions={'done': 'w1'},
										autonomy={'done': Autonomy.Off})

			# x:618 y:304
			OperatableStateMachine.add('Look Left 2',
										SaraSetHeadAngle(pitch=0.1, yaw=1.5),
										transitions={'done': 'w4'},
										autonomy={'done': Autonomy.Off})

			# x:612 y:138
			OperatableStateMachine.add('center',
										SaraSetHeadAngle(pitch=0.1, yaw=0),
										transitions={'done': 'w3'},
										autonomy={'done': Autonomy.Off})

			# x:635 y:214
			OperatableStateMachine.add('w3',
										WaitState(wait_time=4),
										transitions={'done': 'Look Left 2'},
										autonomy={'done': Autonomy.Off})

			# x:636 y:394
			OperatableStateMachine.add('w4',
										WaitState(wait_time=4),
										transitions={'done': 'action_turn'},
										autonomy={'done': Autonomy.Off})

			# x:59 y:128
			OperatableStateMachine.add('set cpt to 0',
										SetKey(Value=0),
										transitions={'done': 'Look Center'},
										autonomy={'done': Autonomy.Off},
										remapping={'Key': 'cpt'})

			# x:400 y:499
			OperatableStateMachine.add('check is cpt is 1',
										CheckConditionState(predicate=lambda x: x==1),
										transitions={'true': 'set entity to unknown', 'false': 'set cpt to 1'},
										autonomy={'true': Autonomy.Off, 'false': Autonomy.Off},
										remapping={'input_value': 'cpt'})

			# x:414 y:210
			OperatableStateMachine.add('set cpt to 1',
										SetKey(Value=1),
										transitions={'done': 'Look Right'},
										autonomy={'done': Autonomy.Off},
										remapping={'Key': 'cpt'})

			# x:605 y:659
			OperatableStateMachine.add('set entity to unknown',
										SetKey(Value="unknown"),
										transitions={'done': 'end'},
										autonomy={'done': Autonomy.Off},
										remapping={'Key': 'personEntity'})


		# x:683 y:188
		_sm_find_entity_1 = OperatableStateMachine(outcomes=['found'], input_keys=['personID'], output_keys=['personEntity'])

		with _sm_find_entity_1:
			# x:226 y:188
			OperatableStateMachine.add('get person',
										GetEntityByID(),
										transitions={'found': 'found', 'not_found': 'WaitState'},
										autonomy={'found': Autonomy.Off, 'not_found': Autonomy.Off},
										remapping={'ID': 'personID', 'Entity': 'personEntity'})

			# x:194 y:40
			OperatableStateMachine.add('WaitState',
										WaitState(wait_time=1),
										transitions={'done': 'get person'},
										autonomy={'done': Autonomy.Off})


		# x:372 y:27, x:392 y:217, x:400 y:139, x:330 y:458
		_sm_container_2 = ConcurrencyContainer(outcomes=['found', 'not_found'], input_keys=['className', 'personID'], output_keys=['personEntity'], conditions=[
										('not_found', [('Rotation', 'end')]),
										('found', [('Find Entity', 'found')])
										])

		with _sm_container_2:
			# x:131 y:44
			OperatableStateMachine.add('Find Entity',
										_sm_find_entity_1,
										transitions={'found': 'found'},
										autonomy={'found': Autonomy.Inherit},
										remapping={'personID': 'personID', 'personEntity': 'personEntity'})

			# x:135 y:199
			OperatableStateMachine.add('Rotation',
										_sm_rotation_0,
										transitions={'end': 'not_found'},
										autonomy={'end': Autonomy.Inherit},
										remapping={'personEntity': 'personEntity'})



		with _state_machine:
			# x:67 y:42
			OperatableStateMachine.add('Look Center',
										SaraSetHeadAngle(pitch=0.1, yaw=0),
										transitions={'done': 'Container'},
										autonomy={'done': Autonomy.Off})

			# x:278 y:138
			OperatableStateMachine.add('Look Center Not Found',
										SaraSetHeadAngle(pitch=0.1, yaw=0),
										transitions={'done': 'not_found'},
										autonomy={'done': Autonomy.Off})

			# x:63 y:126
			OperatableStateMachine.add('Container',
										_sm_container_2,
										transitions={'found': 'WaitState', 'not_found': 'Look Center Not Found'},
										autonomy={'found': Autonomy.Inherit, 'not_found': Autonomy.Inherit},
										remapping={'className': 'className', 'personID': 'personID', 'personEntity': 'personEntity'})

			# x:67 y:222
			OperatableStateMachine.add('WaitState',
										WaitState(wait_time=1),
										transitions={'done': 'found'},
										autonomy={'done': Autonomy.Off})


		return _state_machine
    def create(self):
        # x:712 y:612, x:820 y:97
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'failed'])
        _state_machine.userdata.name = "person"
        _state_machine.userdata.distance = 1.05
        _state_machine.userdata.taxi = "taxi"
        _state_machine.userdata.umbrella = "umbrella"

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

        # [/MANUAL_CREATE]

        # x:30 y:365, x:130 y:365, x:230 y:365
        _sm_get_closer_0 = ConcurrencyContainer(
            outcomes=['finished'],
            input_keys=['ID'],
            conditions=[('finished', [('follow', 'failed')]),
                        ('finished', [('wait 3', 'done')])])

        with _sm_get_closer_0:
            # x:46 y:131
            OperatableStateMachine.add('follow',
                                       SaraFollow(distance=1.15,
                                                  ReplanPeriod=0.5),
                                       transitions={'failed': 'finished'},
                                       autonomy={'failed': Autonomy.Off},
                                       remapping={'ID': 'ID'})

            # x:223 y:134
            OperatableStateMachine.add('wait 3',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        # x:571 y:592
        _sm_scan_1 = OperatableStateMachine(outcomes=['finished'])

        with _sm_scan_1:
            # x:42 y:66
            OperatableStateMachine.add(
                'Looking',
                SaraSay(
                    sentence=
                    "I am trying to find who wants to leave. Please raise your hand.",
                    input_keys=[],
                    emotion=0,
                    block=False),
                transitions={'done': 'center'},
                autonomy={'done': Autonomy.Off})

            # x:394 y:262
            OperatableStateMachine.add('right',
                                       SaraSetHeadAngle(pitch=0.1, yaw=-0.3),
                                       transitions={'done': 'w3'},
                                       autonomy={'done': Autonomy.Off})

            # x:206 y:372
            OperatableStateMachine.add('center2',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'w4'},
                                       autonomy={'done': Autonomy.Off})

            # x:34 y:589
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'center3'},
                                       autonomy={'done': Autonomy.Off})

            # x:413 y:159
            OperatableStateMachine.add('w2',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'right'},
                                       autonomy={'done': Autonomy.Off})

            # x:415 y:370
            OperatableStateMachine.add('w3',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'center2'},
                                       autonomy={'done': Autonomy.Off})

            # x:39 y:371
            OperatableStateMachine.add('w4',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'left'},
                                       autonomy={'done': Autonomy.Off})

            # x:16 y:475
            OperatableStateMachine.add('left',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0.3),
                                       transitions={'done': 'w1'},
                                       autonomy={'done': Autonomy.Off})

            # x:215 y:156
            OperatableStateMachine.add('center',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'w2'},
                                       autonomy={'done': Autonomy.Off})

            # x:213 y:579
            OperatableStateMachine.add('center3',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'wait'},
                                       autonomy={'done': Autonomy.Off})

            # x:393 y:576
            OperatableStateMachine.add('wait',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        # x:32 y:494, x:627 y:411
        _sm_filtregender_2 = OperatableStateMachine(
            outcomes=['none_found', 'found person'],
            input_keys=['name'],
            output_keys=['pronoun', 'person'])

        with _sm_filtregender_2:
            # x:109 y:51
            OperatableStateMachine.add('List',
                                       list_entities_by_name(
                                           frontality_level=0.5,
                                           distance_max=10),
                                       transitions={
                                           'found': 'FiltreWave',
                                           'none_found': 'none_found'
                                       },
                                       autonomy={
                                           'found': Autonomy.Off,
                                           'none_found': Autonomy.Off
                                       },
                                       remapping={
                                           'name': 'name',
                                           'entity_list': 'entity_list',
                                           'number': 'number'
                                       })

            # x:180 y:301
            OperatableStateMachine.add(
                'FiltreExitingwomen',
                Filter(filter=lambda x: x.face.gender == "female"),
                transitions={'done': 'no female?'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_list': 'persons',
                    'output_list': 'female'
                })

            # x:174 y:386
            OperatableStateMachine.add(
                'no female?',
                CheckConditionState(predicate=lambda x: len(x) > 0),
                transitions={
                    'true': 'set pronoun female',
                    'false': 'set pronoun male'
                },
                autonomy={
                    'true': Autonomy.Off,
                    'false': Autonomy.Off
                },
                remapping={'input_value': 'female'})

            # x:374 y:312
            OperatableStateMachine.add(
                'set pronoun female',
                SetKey(Value="miss"),
                transitions={'done': 'get first female'},
                autonomy={'done': Autonomy.Off},
                remapping={'Key': 'pronoun'})

            # x:181 y:476
            OperatableStateMachine.add('set pronoun male',
                                       SetKey(Value=""),
                                       transitions={'done': 'get first male'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'Key': 'pronoun'})

            # x:599 y:290
            OperatableStateMachine.add(
                'get first female',
                CalculationState(calculation=lambda x: x[0]),
                transitions={'done': 'found person'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'female',
                    'output_value': 'person'
                })

            # x:381 y:408
            OperatableStateMachine.add(
                'get first male',
                CalculationState(calculation=lambda x: x[0]),
                transitions={'done': 'found person'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'persons',
                    'output_value': 'person'
                })

            # x:151 y:135
            OperatableStateMachine.add(
                'FiltreWave',
                Filter(filter=lambda x: x.pose.right_arm_up or x.pose.
                       left_arm_up),
                transitions={'done': 'if more than 0'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_list': 'entity_list',
                    'output_list': 'persons'
                })

            # x:157 y:217
            OperatableStateMachine.add(
                'if more than 0',
                CheckConditionState(predicate=lambda x: len(x) > 0),
                transitions={
                    'true': 'FiltreExitingwomen',
                    'false': 'none_found'
                },
                autonomy={
                    'true': Autonomy.Off,
                    'false': Autonomy.Off
                },
                remapping={'input_value': 'persons'})

        # x:772 y:208, x:360 y:516
        _sm_confirm_3 = OperatableStateMachine(
            outcomes=['false', 'done'], input_keys=['Person', 'pronoun'])

        with _sm_confirm_3:
            # x:66 y:83
            OperatableStateMachine.add(
                'Confirm',
                SaraSay(sentence=lambda x: "would you like to leave, " + x[0] +
                        "?",
                        input_keys=["pronoun"],
                        emotion=0,
                        block=True),
                transitions={'done': 'GetSpeech'},
                autonomy={'done': Autonomy.Off},
                remapping={'pronoun': 'pronoun'})

            # x:82 y:504
            OperatableStateMachine.add('GetID',
                                       SetRosParam(ParamName="OpeID"),
                                       transitions={'done': 'done'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'Value': 'ID'})

            # x:67 y:298
            OperatableStateMachine.add('if yes',
                                       RegexTester(regex=".*((yes)|(I do)).*"),
                                       transitions={
                                           'true': 'get id',
                                           'false': 'test no'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'text': 'text',
                                           'result': 'result'
                                       })

            # x:84 y:409
            OperatableStateMachine.add('get id',
                                       GetAttribute(attributes=["ID"]),
                                       transitions={'done': 'GetID'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={
                                           'object': 'Person',
                                           'ID': 'ID'
                                       })

            # x:87 y:188
            OperatableStateMachine.add('GetSpeech',
                                       GetSpeech(watchdog=10),
                                       transitions={
                                           'done': 'if yes',
                                           'nothing': 'sayno',
                                           'fail': 'if yes'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'nothing': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={'words': 'text'})

            # x:259 y:193
            OperatableStateMachine.add(
                'sayno',
                SaraSay(
                    sentence="Sorry, did you say that you wanted to leave?",
                    input_keys=[],
                    emotion=0,
                    block=True),
                transitions={'done': 'getno'},
                autonomy={'done': Autonomy.Off})

            # x:439 y:179
            OperatableStateMachine.add('getno',
                                       GetSpeech(watchdog=10),
                                       transitions={
                                           'done': 'getNO',
                                           'nothing': 'false',
                                           'fail': 'false'
                                       },
                                       autonomy={
                                           'done': Autonomy.Off,
                                           'nothing': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={'words': 'text'})

            # x:603 y:337
            OperatableStateMachine.add('getNO',
                                       RegexTester(regex=".*((yes)|(I do)).*"),
                                       transitions={
                                           'true': 'get id',
                                           'false': 'false'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'text': 'text',
                                           'result': 'result'
                                       })

            # x:246 y:298
            OperatableStateMachine.add('test no',
                                       RegexTester(regex=".*((no)|(not)).*"),
                                       transitions={
                                           'true': 'false',
                                           'false': 'sayno'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'text': 'text',
                                           'result': 'result'
                                       })

        # x:228 y:419
        _sm_find_raising_arm_4 = OperatableStateMachine(
            outcomes=['finished'], output_keys=['umbrella'])

        with _sm_find_raising_arm_4:
            # x:33 y:48
            OperatableStateMachine.add('setperson',
                                       SetKey(Value="person"),
                                       transitions={'done': 'gettaxiperson'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'Key': 'person'})

            # x:183 y:120
            OperatableStateMachine.add('gettaxiperson',
                                       list_entities_by_name(
                                           frontality_level=0.5,
                                           distance_max=10),
                                       transitions={
                                           'found': 'taxi',
                                           'none_found': 'gettaxiperson'
                                       },
                                       autonomy={
                                           'found': Autonomy.Off,
                                           'none_found': Autonomy.Off
                                       },
                                       remapping={
                                           'name': 'person',
                                           'entity_list': 'entity_list',
                                           'number': 'number'
                                       })

            # x:408 y:270
            OperatableStateMachine.add(
                'if',
                CheckConditionState(predicate=lambda x: len(x) > 0),
                transitions={
                    'true': 'get first',
                    'false': 'gettaxiperson'
                },
                autonomy={
                    'true': Autonomy.Off,
                    'false': Autonomy.Off
                },
                remapping={'input_value': 'output_list'})

            # x:344 y:184
            OperatableStateMachine.add(
                'taxi',
                Filter(filter=lambda x: x.pose.right_arm_up or x.pose.
                       left_arm_up),
                transitions={'done': 'if'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_list': 'entity_list',
                    'output_list': 'output_list'
                })

            # x:405 y:359
            OperatableStateMachine.add(
                'get first',
                CalculationState(calculation=lambda x: x[0]),
                transitions={'done': 'finished'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'output_list',
                    'output_value': 'umbrella'
                })

        # x:30 y:365
        _sm_rotation_5 = OperatableStateMachine(outcomes=['end'])

        with _sm_rotation_5:
            # x:51 y:38
            OperatableStateMachine.add('Set 180 degres',
                                       SetKey(Value=3.1416),
                                       transitions={'done': 'Look Center'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'Key': 'rotation'})

            # x:613 y:470
            OperatableStateMachine.add(
                'action_turn',
                self.use_behavior(
                    sara_flexbe_behaviors__action_turnSM,
                    'GetTaxi/Find umbrella/gettaxihuman/Rotation/action_turn'),
                transitions={
                    'finished': 'Look Right',
                    'failed': 'Look Right'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                },
                remapping={'rotation': 'rotation'})

            # x:421 y:54
            OperatableStateMachine.add('Look Right',
                                       SaraSetHeadAngle(pitch=0, yaw=-1.5),
                                       transitions={'done': 'w2'},
                                       autonomy={'done': Autonomy.Off})

            # x:265 y:56
            OperatableStateMachine.add('w1',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'Look Right'},
                                       autonomy={'done': Autonomy.Off})

            # x:630 y:56
            OperatableStateMachine.add('w2',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'center'},
                                       autonomy={'done': Autonomy.Off})

            # x:250 y:177
            OperatableStateMachine.add('Look Center',
                                       SaraSetHeadAngle(pitch=0, yaw=0),
                                       transitions={'done': 'w1'},
                                       autonomy={'done': Autonomy.Off})

            # x:618 y:304
            OperatableStateMachine.add('Look Left 2',
                                       SaraSetHeadAngle(pitch=0, yaw=1.5),
                                       transitions={'done': 'w4'},
                                       autonomy={'done': Autonomy.Off})

            # x:612 y:138
            OperatableStateMachine.add('center',
                                       SaraSetHeadAngle(pitch=0, yaw=0),
                                       transitions={'done': 'w3'},
                                       autonomy={'done': Autonomy.Off})

            # x:635 y:214
            OperatableStateMachine.add('w3',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'Look Left 2'},
                                       autonomy={'done': Autonomy.Off})

            # x:636 y:394
            OperatableStateMachine.add('w4',
                                       WaitState(wait_time=4),
                                       transitions={'done': 'action_turn'},
                                       autonomy={'done': Autonomy.Off})

        # x:30 y:365
        _sm_find_entity_6 = OperatableStateMachine(outcomes=['found'],
                                                   input_keys=['className'],
                                                   output_keys=['entity'])

        with _sm_find_entity_6:
            # x:181 y:178
            OperatableStateMachine.add('find_entity',
                                       list_entities_by_name(
                                           frontality_level=0.5,
                                           distance_max=4),
                                       transitions={
                                           'found': 'Get Entity',
                                           'none_found': 'find_entity'
                                       },
                                       autonomy={
                                           'found': Autonomy.Off,
                                           'none_found': Autonomy.Off
                                       },
                                       remapping={
                                           'name': 'className',
                                           'entity_list': 'entity_list',
                                           'number': 'number'
                                       })

            # x:454 y:178
            OperatableStateMachine.add(
                'Get Entity',
                CalculationState(calculation=lambda x: x[0]),
                transitions={'done': 'found'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'input_value': 'entity_list',
                    'output_value': 'entity'
                })

            # x:194 y:40
            OperatableStateMachine.add('WaitState',
                                       WaitState(wait_time=1),
                                       transitions={'done': 'find_entity'},
                                       autonomy={'done': Autonomy.Off})

        # x:34 y:496, x:130 y:365, x:475 y:291, x:330 y:365, x:430 y:365
        _sm_gettaxihuman_7 = ConcurrencyContainer(
            outcomes=['found', 'not_found'],
            input_keys=['umbrella'],
            output_keys=['umbrella'],
            conditions=[('not_found', [('Rotation', 'end')]),
                        ('found', [('Find Entity', 'found')]),
                        ('found', [('FInd raising arm', 'finished')])])

        with _sm_gettaxihuman_7:
            # x:127 y:67
            OperatableStateMachine.add('Find Entity',
                                       _sm_find_entity_6,
                                       transitions={'found': 'found'},
                                       autonomy={'found': Autonomy.Inherit},
                                       remapping={
                                           'className': 'umbrella',
                                           'entity': 'umbrella'
                                       })

            # x:129 y:180
            OperatableStateMachine.add('Rotation',
                                       _sm_rotation_5,
                                       transitions={'end': 'not_found'},
                                       autonomy={'end': Autonomy.Inherit})

            # x:377 y:127
            OperatableStateMachine.add('FInd raising arm',
                                       _sm_find_raising_arm_4,
                                       transitions={'finished': 'found'},
                                       autonomy={'finished': Autonomy.Inherit},
                                       remapping={'umbrella': 'umbrella'})

        # x:73 y:441, x:586 y:51
        _sm_find_umbrella_8 = OperatableStateMachine(
            outcomes=['finished', 'failed'],
            input_keys=['umbrella'],
            output_keys=['umbrella'])

        with _sm_find_umbrella_8:
            # x:67 y:42
            OperatableStateMachine.add('Look Center',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'gettaxihuman'},
                                       autonomy={'done': Autonomy.Off})

            # x:278 y:138
            OperatableStateMachine.add('Look Center Not Found',
                                       SaraSetHeadAngle(pitch=0.1, yaw=0),
                                       transitions={'done': 'failed'},
                                       autonomy={'done': Autonomy.Off})

            # x:58 y:326
            OperatableStateMachine.add('Log Entity',
                                       LogKeyState(
                                           text="Found entity: {}",
                                           severity=Logger.REPORT_HINT),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'data': 'umbrella'})

            # x:63 y:126
            OperatableStateMachine.add('gettaxihuman',
                                       _sm_gettaxihuman_7,
                                       transitions={
                                           'found': 'WaitState',
                                           'not_found': 'Look Center Not Found'
                                       },
                                       autonomy={
                                           'found': Autonomy.Inherit,
                                           'not_found': Autonomy.Inherit
                                       },
                                       remapping={'umbrella': 'umbrella'})

            # x:67 y:222
            OperatableStateMachine.add('WaitState',
                                       WaitState(wait_time=1),
                                       transitions={'done': 'Log Entity'},
                                       autonomy={'done': Autonomy.Off})

        # x:83 y:284
        _sm_lift_head_9 = OperatableStateMachine(outcomes=['finished'])

        with _sm_lift_head_9:
            # x:53 y:42
            OperatableStateMachine.add('lift head',
                                       SaraSetHeadAngle(pitch=0, yaw=0),
                                       transitions={'done': 'wait 2'},
                                       autonomy={'done': Autonomy.Off})

            # x:57 y:152
            OperatableStateMachine.add('wait 2',
                                       WaitState(wait_time=3),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

        # x:30 y:365
        _sm_get_closer_10 = OperatableStateMachine(outcomes=['finished'],
                                                   input_keys=['person'])

        with _sm_get_closer_10:
            # x:151 y:63
            OperatableStateMachine.add('get ID',
                                       GetAttribute(attributes=["ID"]),
                                       transitions={'done': 'Get closer'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={
                                           'object': 'person',
                                           'ID': 'ID'
                                       })

            # x:135 y:194
            OperatableStateMachine.add('Get closer',
                                       _sm_get_closer_0,
                                       transitions={'finished': 'finished'},
                                       autonomy={'finished': Autonomy.Inherit},
                                       remapping={'ID': 'ID'})

        # x:607 y:98, x:558 y:330
        _sm_get_gender_11 = OperatableStateMachine(
            outcomes=['none_found', 'done'],
            input_keys=['name', 'distance'],
            output_keys=['person', 'pronoun'])

        with _sm_get_gender_11:
            # x:30 y:40
            OperatableStateMachine.add('set head',
                                       SaraSetHeadAngle(pitch=0, yaw=0),
                                       transitions={'done': 'Scan'},
                                       autonomy={'done': Autonomy.Off})

            # x:441 y:109
            OperatableStateMachine.add('FiltreGender',
                                       _sm_filtregender_2,
                                       transitions={
                                           'none_found': 'none_found',
                                           'found person': 'done'
                                       },
                                       autonomy={
                                           'none_found': Autonomy.Inherit,
                                           'found person': Autonomy.Inherit
                                       },
                                       remapping={
                                           'name': 'name',
                                           'pronoun': 'pronoun',
                                           'person': 'person'
                                       })

            # x:211 y:93
            OperatableStateMachine.add(
                'Scan',
                _sm_scan_1,
                transitions={'finished': 'FiltreGender'},
                autonomy={'finished': Autonomy.Inherit})

        # x:30 y:373, x:130 y:373
        _sm_nevermind_12 = OperatableStateMachine(outcomes=['done', 'failed'],
                                                  input_keys=['poseOrigin'])

        with _sm_nevermind_12:
            # x:30 y:40
            OperatableStateMachine.add('say ok',
                                       SaraSay(sentence="I will try again",
                                               input_keys=[],
                                               emotion=0,
                                               block=False),
                                       transitions={'done': 'Action_Move'},
                                       autonomy={'done': Autonomy.Off})

            # x:26 y:192
            OperatableStateMachine.add(
                'Action_Move',
                self.use_behavior(sara_flexbe_behaviors__Action_MoveSM,
                                  'nevermind/Action_Move'),
                transitions={
                    'finished': 'done',
                    'failed': 'failed'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                },
                remapping={'pose': 'poseOrigin'})

        # x:30 y:458, x:130 y:458, x:230 y:458, x:330 y:458, x:430 y:458
        _sm_confirm_13 = ConcurrencyContainer(
            outcomes=['false', 'done'],
            input_keys=['person', 'pronoun'],
            conditions=[('false', [('Confirm', 'false')]),
                        ('done', [('Confirm', 'done')]),
                        ('false', [('LookAtClosest', 'failed')])])

        with _sm_confirm_13:
            # x:95 y:163
            OperatableStateMachine.add('Confirm',
                                       _sm_confirm_3,
                                       transitions={
                                           'false': 'false',
                                           'done': 'done'
                                       },
                                       autonomy={
                                           'false': Autonomy.Inherit,
                                           'done': Autonomy.Inherit
                                       },
                                       remapping={
                                           'Person': 'person',
                                           'pronoun': 'pronoun'
                                       })

            # x:309 y:162
            OperatableStateMachine.add(
                'LookAtClosest',
                self.use_behavior(sara_flexbe_behaviors__LookAtClosestSM,
                                  'confirm/LookAtClosest'),
                transitions={'failed': 'false'},
                autonomy={'failed': Autonomy.Inherit})

        # x:65 y:581, x:688 y:449
        _sm_gettaxi_14 = OperatableStateMachine(
            outcomes=['finished', 'failed'],
            input_keys=['distance', 'taxi', 'umbrella'])

        with _sm_gettaxi_14:
            # x:103 y:28
            OperatableStateMachine.add(
                'Action_Move_to taxi',
                self.use_behavior(sara_flexbe_behaviors__Action_MoveSM,
                                  'GetTaxi/Action_Move_to taxi'),
                transitions={
                    'finished': 'Lift head',
                    'failed': 'failed'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                },
                remapping={'pose': 'taxi'})

            # x:220 y:546
            OperatableStateMachine.add(
                'Action_Move',
                self.use_behavior(sara_flexbe_behaviors__Action_MoveSM,
                                  'GetTaxi/Action_Move'),
                transitions={
                    'finished': 'finished',
                    'failed': 'failed'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                },
                remapping={'pose': 'pose_out'})

            # x:80 y:475
            OperatableStateMachine.add('NotTooClose',
                                       Get_Reacheable_Waypoint(),
                                       transitions={'done': 'Action_Move'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={
                                           'pose_in': 'position',
                                           'distance': 'distance',
                                           'pose_out': 'pose_out'
                                       })

            # x:81 y:400
            OperatableStateMachine.add('GEtUmbrellaPosition',
                                       GetAttribute(attributes=["position"]),
                                       transitions={'done': 'NotTooClose'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={
                                           'object': 'umbrella',
                                           'position': 'position'
                                       })

            # x:108 y:131
            OperatableStateMachine.add(
                'Lift head',
                _sm_lift_head_9,
                transitions={'finished': 'Find umbrella'},
                autonomy={'finished': Autonomy.Inherit})

            # x:150 y:315
            OperatableStateMachine.add(
                'log',
                LogKeyState(text="found umbrella: {}",
                            severity=Logger.REPORT_HINT),
                transitions={'done': 'GEtUmbrellaPosition'},
                autonomy={'done': Autonomy.Off},
                remapping={'data': 'umbrella'})

            # x:267 y:312
            OperatableStateMachine.add(
                'say see taxy',
                SaraSay(
                    sentence=
                    "I see the taxi. Over there. The person with the umbrella.",
                    input_keys=[],
                    emotion=0,
                    block=True),
                transitions={'done': 'log'},
                autonomy={'done': Autonomy.Off})

            # x:111 y:204
            OperatableStateMachine.add('Find umbrella',
                                       _sm_find_umbrella_8,
                                       transitions={
                                           'finished': 'say see taxy',
                                           'failed': 'failed'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       },
                                       remapping={'umbrella': 'umbrella'})

        with _state_machine:
            # x:46 y:16
            OperatableStateMachine.add('GetOrigin',
                                       Get_Robot_Pose(),
                                       transitions={'done': 'Init_Sequence'},
                                       autonomy={'done': Autonomy.Off},
                                       remapping={'pose': 'poseOrigin'})

            # x:63 y:574
            OperatableStateMachine.add('GetTaxi',
                                       _sm_gettaxi_14,
                                       transitions={
                                           'finished': 'say succeed',
                                           'failed': 'say fail'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       },
                                       remapping={
                                           'distance': 'distance',
                                           'taxi': 'taxi',
                                           'umbrella': 'umbrella'
                                       })

            # x:103 y:369
            OperatableStateMachine.add('confirm',
                                       _sm_confirm_13,
                                       transitions={
                                           'false': 'nevermind',
                                           'done': 'say taxi'
                                       },
                                       autonomy={
                                           'false': Autonomy.Inherit,
                                           'done': Autonomy.Inherit
                                       },
                                       remapping={
                                           'person': 'person',
                                           'pronoun': 'pronoun'
                                       })

            # x:289 y:142
            OperatableStateMachine.add(
                'say nobody',
                SaraSay(sentence="I don't see any raised hand.",
                        input_keys=[],
                        emotion=0,
                        block=True),
                transitions={'done': 'Get Gender'},
                autonomy={'done': Autonomy.Off})

            # x:571 y:104
            OperatableStateMachine.add(
                'say fail',
                SaraSay(sentence="I failed this scenario. Sorry.",
                        input_keys=[],
                        emotion=3,
                        block=True),
                transitions={'done': 'failed'},
                autonomy={'done': Autonomy.Off})

            # x:245 y:595
            OperatableStateMachine.add('say succeed',
                                       SaraSay(
                                           sentence="here is the taxy driver.",
                                           input_keys=[],
                                           emotion=5,
                                           block=True),
                                       transitions={'done': 'finished'},
                                       autonomy={'done': Autonomy.Off})

            # x:103 y:483
            OperatableStateMachine.add(
                'say taxi',
                SaraSay(sentence="Ok, follow me to the taxi then.",
                        input_keys=[],
                        emotion=0,
                        block=True),
                transitions={'done': 'GetTaxi'},
                autonomy={'done': Autonomy.Off})

            # x:49 y:101
            OperatableStateMachine.add(
                'Init_Sequence',
                self.use_behavior(sara_flexbe_behaviors__Init_SequenceSM,
                                  'Init_Sequence'),
                transitions={
                    'finished': 'Get Gender',
                    'failed': 'say fail'
                },
                autonomy={
                    'finished': Autonomy.Inherit,
                    'failed': Autonomy.Inherit
                })

            # x:17 y:288
            OperatableStateMachine.add('nevermind',
                                       _sm_nevermind_12,
                                       transitions={
                                           'done': 'Get Gender',
                                           'failed': 'say fail'
                                       },
                                       autonomy={
                                           'done': Autonomy.Inherit,
                                           'failed': Autonomy.Inherit
                                       },
                                       remapping={'poseOrigin': 'poseOrigin'})

            # x:30 y:192
            OperatableStateMachine.add('Get Gender',
                                       _sm_get_gender_11,
                                       transitions={
                                           'none_found': 'say nobody',
                                           'done': 'get closer'
                                       },
                                       autonomy={
                                           'none_found': Autonomy.Inherit,
                                           'done': Autonomy.Inherit
                                       },
                                       remapping={
                                           'name': 'name',
                                           'distance': 'distance',
                                           'person': 'person',
                                           'pronoun': 'pronoun'
                                       })

            # x:259 y:310
            OperatableStateMachine.add('get closer',
                                       _sm_get_closer_10,
                                       transitions={'finished': 'confirm'},
                                       autonomy={'finished': Autonomy.Inherit},
                                       remapping={'person': 'person'})

        return _state_machine
Ejemplo n.º 30
0
    def create(self):
        # x:1428 y:298, x:1110 y:127
        _state_machine = OperatableStateMachine(
            outcomes=['finished', 'fail'],
            input_keys=['Shipments', 'NumberOfShipments'])
        _state_machine.userdata.Shipments = []
        _state_machine.userdata.NumberOfShipments = 0
        _state_machine.userdata.Products = []
        _state_machine.userdata.NumberOfProducts = 0
        _state_machine.userdata.AgvID = ''
        _state_machine.userdata.ShipmentIndex = 1
        _state_machine.userdata.ShipmentType = ''
        _state_machine.userdata.ShipmentIterator = 0
        _state_machine.userdata.OneValue = 1
        _state_machine.userdata.agv_id = ''
        _state_machine.userdata.agv_ready_state = ''

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

        # [/MANUAL_CREATE]

        with _state_machine:
            # x:43 y:24
            OperatableStateMachine.add('GetProducts',
                                       GetProductsFromShipmentState(),
                                       transitions={
                                           'continue': 'get_products',
                                           'invalid_index': 'fail'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'invalid_index': Autonomy.Off
                                       },
                                       remapping={
                                           'shipments': 'Shipments',
                                           'index': 'ShipmentIterator',
                                           'shipment_type': 'ShipmentType',
                                           'agv_id': 'agv_id',
                                           'products': 'Products',
                                           'number_of_products':
                                           'NumberOfProducts'
                                       })

            # x:1475 y:229
            OperatableStateMachine.add(
                'IncrementShipmentsIterator',
                AddNumericState(),
                transitions={'done': 'CompareShepmentsIterator'},
                autonomy={'done': Autonomy.Off},
                remapping={
                    'value_a': 'ShipmentIterator',
                    'value_b': 'OneValue',
                    'result': 'ShipmentIterator'
                })

            # x:1218 y:234
            OperatableStateMachine.add('CompareShepmentsIterator',
                                       EqualState(),
                                       transitions={
                                           'true': 'finished',
                                           'false': 'GetProducts'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'value_a': 'ShipmentIterator',
                                           'value_b': 'NumberOfShipments'
                                       })

            # x:730 y:26
            OperatableStateMachine.add('get_products',
                                       self.use_behavior(
                                           get_productsSM, 'get_products'),
                                       transitions={
                                           'finished': 'NotifyShipmentReady',
                                           'fail': 'fail'
                                       },
                                       autonomy={
                                           'finished': Autonomy.Inherit,
                                           'fail': Autonomy.Inherit
                                       },
                                       remapping={
                                           'Products': 'Products',
                                           'NumberOfProducts':
                                           'NumberOfProducts',
                                           'agv_id': 'agv_id'
                                       })

            # x:1354 y:16
            OperatableStateMachine.add('GetAgvState',
                                       GetAgvStatusState(),
                                       transitions={
                                           'continue': 'AgvReady',
                                           'fail': 'fail'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={
                                           'agv_id': 'agv_id',
                                           'agv_state': 'agv_state'
                                       })

            # x:1228 y:125
            OperatableStateMachine.add('AgvReady',
                                       EqualState(),
                                       transitions={
                                           'true':
                                           'IncrementShipmentsIterator',
                                           'false': 'Wait'
                                       },
                                       autonomy={
                                           'true': Autonomy.Off,
                                           'false': Autonomy.Off
                                       },
                                       remapping={
                                           'value_a': 'agv_state',
                                           'value_b': 'agv_ready_state'
                                       })

            # x:1177 y:23
            OperatableStateMachine.add('Wait',
                                       WaitState(wait_time=1),
                                       transitions={'done': 'GetAgvState'},
                                       autonomy={'done': Autonomy.Off})

            # x:959 y:20
            OperatableStateMachine.add('NotifyShipmentReady',
                                       NotifyShipmentReadyState(),
                                       transitions={
                                           'continue': 'Wait',
                                           'fail': 'fail'
                                       },
                                       autonomy={
                                           'continue': Autonomy.Off,
                                           'fail': Autonomy.Off
                                       },
                                       remapping={
                                           'agv_id': 'agv_id',
                                           'shipment_type': 'ShipmentType',
                                           'success': 'success',
                                           'message': 'message'
                                       })

        return _state_machine