<commit_before>#!/usr/bin/env python
###########################################################
#               WARNING: Generated code!                  #
#              **************************                 #
# Manual changes may get lost if file is generated again. #
# Only code inside the [MANUAL] tags will be kept.        #
###########################################################

import roslib; roslib.load_manifest('behavior_action_look_at')
from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger
from sara_flexbe_states.Get_Entity_By_ID import GetEntityByID
from flexbe_states.calculation_state import CalculationState
from sara_flexbe_states.Get_direction_to_point import Get_direction_to_point
from sara_flexbe_states.sara_set_head_angle_key import SaraSetHeadAngleKey
# Additional imports can be added inside the following tags
# [MANUAL_IMPORT]

# [/MANUAL_IMPORT]


'''
Created on Wed Apr 25 2018
@author: Veronica
'''
class action_look_atSM(Behavior):
    '''
    Makes sara look at a given point
    '''


    def __init__(self):
        super(action_look_atSM, self).__init__()
        self.name = 'action_look_at'

        # parameters of this behavior

        # references to used behaviors

        # Additional initialization code can be added inside the following tags
        # [MANUAL_INIT]
        
        # [/MANUAL_INIT]

        # Behavior comments:



    def create(self):
        # x:873 y:200, x:801 y:120
        _state_machine = OperatableStateMachine(outcomes=['finished', 'failed'], input_keys=['Position', 'ID'])
        _state_machine.userdata.Position = None
        _state_machine.userdata.ID = 0

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


        with _state_machine:
            # x:47 y:53
            OperatableStateMachine.add('entity',
                                        GetEntityByID(),
                                        transitions={'found': 'ExtractPos', 'not_found': 'failed'},
                                        autonomy={'found': Autonomy.Off, 'not_found': Autonomy.Off},
                                        remapping={'ID': 'ID', 'Entity': 'Entity'})

            # x:187 y:84
            OperatableStateMachine.add('ExtractPos',
                                        CalculationState(calculation=lambda x: x.position),
                                        transitions={'done': 'Direction'},
                                        autonomy={'done': Autonomy.Off},
                                        remapping={'input_value': 'Entity', 'output_value': 'Position'})

            # x:352 y:107
            OperatableStateMachine.add('Direction',
                                        Get_direction_to_point(frame_origin="base_link", frame_reference="head_link"),
                                        transitions={'done': 'invertPitch', 'fail': 'failed'},
                                        autonomy={'done': Autonomy.Off, 'fail': Autonomy.Off},
                                        remapping={'targetPoint': 'Position', 'yaw': 'yaw', 'pitch': 'pitch'})

            # x:676 y:191
            OperatableStateMachine.add('Tete',
                                        SaraSetHeadAngleKey(),
                                        transitions={'done': 'finished'},
                                        autonomy={'done': Autonomy.Off},
                                        remapping={'yaw': 'yaw', 'pitch': 'pitch'})

            # x:529 y:141
            OperatableStateMachine.add('invertPitch',
                                        CalculationState(calculation=lambda x: -x),
                                        transitions={'done': 'Tete'},
                                        autonomy={'done': Autonomy.Off},
                                        remapping={'input_value': 'pitch', 'output_value': 'pitch'})


        return _state_machine


    # Private functions can be added inside the following tags
    # [MANUAL_FUNC]
    
    # [/MANUAL_FUNC]<commit_msg>enleve le ID des inputs keys de action_look_at<commit_after>#!/usr/bin/env python
###########################################################
#               WARNING: Generated code!                  #
#              **************************                 #
# Manual changes may get lost if file is generated again. #
# Only code inside the [MANUAL] tags will be kept.        #
###########################################################

import roslib; roslib.load_manifest('behavior_action_look_at')
from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger
from sara_flexbe_states.Get_direction_to_point import Get_direction_to_point
from sara_flexbe_states.sara_set_head_angle_key import SaraSetHeadAngleKey
from flexbe_states.calculation_state import CalculationState
# Additional imports can be added inside the following tags
# [MANUAL_IMPORT]

# [/MANUAL_IMPORT]


'''
Created on Wed Apr 25 2018
@author: Veronica
'''
class action_look_atSM(Behavior):
	'''
	Makes sara look at a given point
	'''


	def __init__(self):
		super(action_look_atSM, self).__init__()
		self.name = 'action_look_at'

		# parameters of this behavior

		# references to used behaviors

		# Additional initialization code can be added inside the following tags
		# [MANUAL_INIT]
        
        # [/MANUAL_INIT]

		# Behavior comments:



	def create(self):
		# x:873 y:200, x:801 y:120
		_state_machine = OperatableStateMachine(outcomes=['finished', 'failed'], input_keys=['Position'])
		_state_machine.userdata.Position = None

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


		with _state_machine:
			# x:352 y:107
			OperatableStateMachine.add('Direction',
										Get_direction_to_point(frame_origin="base_link", frame_reference="head_link"),
										transitions={'done': 'invertPitch', 'fail': 'failed'},
										autonomy={'done': Autonomy.Off, 'fail': Autonomy.Off},
										remapping={'targetPoint': 'Position', 'yaw': 'yaw', 'pitch': 'pitch'})

			# x:676 y:191
			OperatableStateMachine.add('Tete',
										SaraSetHeadAngleKey(),
										transitions={'done': 'finished'},
										autonomy={'done': Autonomy.Off},
										remapping={'yaw': 'yaw', 'pitch': 'pitch'})

			# x:529 y:141
			OperatableStateMachine.add('invertPitch',
										CalculationState(calculation=lambda x: -x),
										transitions={'done': 'Tete'},
										autonomy={'done': Autonomy.Off},
										remapping={'input_value': 'pitch', 'output_value': 'pitch'})


		return _state_machine


	# Private functions can be added inside the following tags
	# [MANUAL_FUNC]
    
    # [/MANUAL_FUNC]
{'fraction_non_alphanumeric': 0.14148331633396474, 'fraction_numerical': 0.011948127640973335, 'mean_word_length': 2.328806983511154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7491135', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1744, 'n_words': 419}