00001
00002
00003 import roslib; roslib.load_manifest('tibi_dabo_smachs')
00004 import rospy
00005 import smach
00006 import smach_ros
00007 import tf
00008 import math
00009
00010 from tf.transformations import euler_from_quaternion
00011 from geometry_msgs.msg import Point, Pose, Quaternion
00012 from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
00013 from tibi_dabo_msgs.msg import sequenceAction, sequenceGoal
00014 from iri_perception_msgs.msg import peopleTrackAction
00015 from actionlib import *
00016 from actionlib.msg import *
00017 from smach_ros import SimpleActionState, ServiceState
00018
00019
00020 def hri_goal_cb(userdata, goal):
00021 rospy.loginfo('hri_goal_cb')
00022 tts_goal = sequenceGoal()
00023 tts_goal.sequence_file = [None]*5
00024 tts_goal.sequence_file[0] = userdata.tts_in
00025 tts_goal.sequence_file[1] = ""
00026 tts_goal.sequence_file[2] = userdata.head_in
00027 tts_goal.sequence_file[3] = ""
00028 tts_goal.sequence_file[4] = ""
00029 return tts_goal
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 def main():
00044 rospy.init_node('concurrent_hri_move_base')
00045
00046
00047 sm = smach.StateMachine(['succeeded','aborted','preempted'])
00048
00049
00050 sm.userdata.sm_frame_id = "/tibi/base_link"
00051 sm.userdata.sm_goal_x = 0.0
00052 sm.userdata.sm_goal_y = 0.0
00053 sm.userdata.sm_goal_theta = 0.0
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 with sm:
00087
00088 sm.userdata.sm_hri_tts_1 = "Hola a tothom. Benvinguts a l'edicio numero trenta del salo del comic de Barcelona. Jo soc la Tibi, un robot social. Estic aqui per explicar-vos curiositats sobre el salo."
00089 sm.userdata.sm_hri_head_1 = "head_random_1.xml"
00090 sm.userdata.sm_hri_left_1 = "left_arm_greeting.xml"
00091 smach.StateMachine.add('HRI_1',
00092 smach_ros.SimpleActionState('hri',
00093 sequenceAction,
00094 goal_cb=hri_goal_cb,
00095 input_keys=['tts_in', 'head_in','left_in']),
00096 transitions={'succeeded':'CC_HRI_RB_1'},
00097 remapping={'tts_in':'sm_hri_tts_1',
00098 'head_in':'sm_hri_head_1',
00099 'left_in':'sm_hri_left_1'})
00100
00101
00102 sm.userdata.sm_hri_tts_2 = "Si necessiteu qualsevol cosa no dubteu en preguntar-me, tot i que ara que hi penso millor parleu amb en Dabo, es el meu germa, ens assemblem molt, pero a ell li agrada el color blau, no el taronja"
00103 sm.userdata.sm_hri_head_2 = "head_random_2.xml"
00104 sm.userdata.sm_hri_left_2= "left_arm_random_1.xml"
00105 smach.StateMachine.add('CC_HRI_RB_1',
00106 hri_rb_cc,
00107 transitions={'succeeded':'HRI_2',
00108 'aborted':'HRI_BLOCKED'},
00109 remapping={'cc_hri_tts':'sm_hri_tts_2',
00110 'cc_hri_head':'sm_hri_head_2',
00111 'left_in':'sm_hri_left_2',
00112 'cc_frame_id':'sm_frame_id',
00113 'cc_goal_x':'sm_goal_x',
00114 'cc_goal_y':'sm_goal_y',
00115 'cc_goal_theta':'sm_goal_theta'})
00116
00117
00118 sm.userdata.sm_hri_tts_3 = "Per aqui tambe esta el meu cosi, es diu Teo, es aquest trasto de quatre rodes que nomes sap fer mapes. Semple parla de mapes, es un aborrit, despres podeu demanar-li que us fassi un mapa del recinte."
00119 sm.userdata.sm_hri_head_3 = "head_random_3.xml"
00120 sm.userdata.sm_hri_left_3 = "left_arm_random_2.xml"
00121 smach.StateMachine.add('HRI_2',
00122 smach_ros.SimpleActionState('hri',
00123 sequenceAction,
00124 goal_cb=hri_goal_cb,
00125 input_keys=['tts_in', 'head_in','left_in']),
00126 transitions={'succeeded':'CC_HRI_RB_2'},
00127 remapping={'tts_in':'sm_hri_tts_3',
00128 'head_in':'sm_hri_head_3',
00129 'left_in':'sm_hri_left_3'})
00130
00131
00132 sm.userdata.sm_hri_tts_4 = " Ah! me n'oblidava tambe ha vingut l'auron, es aquell robot aranya amb tantes potes, ara esta hivernant, aixi que no el desperteu, que s'enfada i es desperta de mal humor"
00133 sm.userdata.sm_hri_head_4 = "head_random_3.xml"
00134 sm.userdata.sm_hri_left_4 = "left_arm_random_3.xml"
00135 smach.StateMachine.add('CC_HRI_RB_2',
00136 hri_rb_cc,
00137 transitions={'succeeded':'HRI_3',
00138 'aborted':'HRI_BLOCKED'},
00139 remapping={'cc_hri_tts':'sm_hri_tts_4',
00140 'cc_hri_head':'sm_hri_head_4',
00141 'left_in':'sm_hri_left_4',
00142 'cc_frame_id':'sm_frame_id',
00143 'cc_goal_x':'sm_goal_x',
00144 'cc_goal_y':'sm_goal_y',
00145 'cc_goal_theta':'sm_goal_theta'})
00146
00147
00148 sm.userdata.sm_hri_tts_5 = "I despres esta la uait mun , es la nostra mascota, es la bola blanca. I per ultim el Darwin, el mimat, tothmo diu que es el millor de tots, pero com un nen petit. I alla al davant tenim el Rim, es de la competencia, pero a vegades ens trobem per pendre xocolata."
00149 sm.userdata.sm_hri_head_5 = "head_random_3.xml"
00150 sm.userdata.sm_hri_left_5= "left_arm_random_2.xml"
00151 smach.StateMachine.add('HRI_3',
00152 smach_ros.SimpleActionState('hri',
00153 sequenceAction,
00154 goal_cb=hri_goal_cb,
00155 input_keys=['tts_in', 'head_in','left_in']),
00156 transitions={'succeeded':'FAREWELL'},
00157 remapping={'tts_in':'sm_hri_tts_5',
00158 'head_in':'sm_hri_head_5',
00159 'left_in':'sm_hri_left_5'})
00160
00161
00162
00163
00164
00165 sm.userdata.sm_hri_tts_farewell = "Si algu vol entrar per saber mes coses es benvingut. Espero veure-us aviat. Adeu a tots"
00166 sm.userdata.sm_hri_head_farewell = "head_farewell.xml"
00167 sm.userdata.sm_hri_left_farewell= "left_arm_farewell.xml"
00168 smach.StateMachine.add('FAREWELL',
00169 smach_ros.SimpleActionState('hri',
00170 sequenceAction,
00171 goal_cb=hri_goal_cb,
00172 input_keys=['tts_in', 'head_in','left_in']),
00173 transitions={'succeeded':'succeeded'},
00174 remapping={'tts_in':'sm_hri_tts_farewell',
00175 'head_in':'sm_hri_head_farewell',
00176 'left_in':'sm_hri_left_farewell'})
00177
00178
00179
00180 sm.userdata.sm_hri_tts_blocked = "Sergi, Fernando, Anais, no em puc moure, ajudeu-me"
00181 sm.userdata.sm_hri_head_blocked = "head_farewell.xml"
00182 sm.userdata.sm_hri_left_blocked= "left_arm_random_4.xml"
00183 smach.StateMachine.add('HRI_BLOCKED',
00184 smach_ros.SimpleActionState('hri',
00185 sequenceAction,
00186 goal_cb=hri_goal_cb,
00187 input_keys=['tts_in', 'head_in','left_in']),
00188 transitions={'succeeded':'succeeded'},
00189 remapping={'tts_in':'sm_hri_tts_blocked',
00190 'head_in':'sm_hri_head_blocked',
00191 'left_in':'sm_hri_left_blocked'})
00192
00193
00194 sis = smach_ros.IntrospectionServer('server_name', sm, '/SM_ROOT')
00195 sis.start()
00196
00197
00198 outcome = sm.execute()
00199
00200
00201 rospy.spin()
00202 sis.stop()
00203
00204
00205 if __name__ == '__main__':
00206 main()
00207