9 from ed.entity
import Entity
11 import robot_smach_states.util.designators
as ds
12 from robot_smach_states.navigation
import NavigateToWaypoint
13 from robot_smach_states.startup
import StartChallengeRobust
14 from robot_smach_states.human_interaction
import Say, FindPerson
15 from robot_smach_states.perception
import RotateToEntity
16 from robot_smach_states.utility
import WaitTime
17 from robocup_knowledge
import load_knowledge
19 from .get_furniture_from_operator_pose
import GetFurnitureFromOperatorPose
20 from .identify_object
import IdentifyObject
21 from .inspect_furniture_entity
import InspectFurniture
23 challenge_knowledge = load_knowledge(
'challenge_hand_me_that')
25 STARTING_POINT = challenge_knowledge.starting_point
26 HOME_LOCATION = challenge_knowledge.home_location
27 POSSIBLE_FURNITURE = challenge_knowledge.all_possible_furniture
28 ROOM = challenge_knowledge.room
32 """ Main StateMachine for the challenge """
35 smach.StateMachine.__init__(self, outcomes=[
'done'])
37 furniture_designator = ds.VariableDesignator(resolve_type=Entity)
38 entity_designator = ds.VariableDesignator(resolve_type=[Entity])
39 operator_designator = ds.VariableDesignator(resolve_type=Entity).writeable
40 arm_designator = ds.UnoccupiedArmDesignator(robot).lockable()
41 room_designator = ds.EntityByIdDesignator(robot, uuid=ROOM)
48 smach.StateMachine.add(
'START_CHALLENGE_ROBUST', StartChallengeRobust(robot, STARTING_POINT),
49 transitions={
'Done':
'SAY_START',
51 'Failed':
'SAY_START'})
54 smach.StateMachine.add(
'SAY_START', Say(robot,
"Hand me that it is!", block=
False),
55 transitions={
'spoken':
'NAVIGATE_TO_START'})
58 smach.StateMachine.add(
'NAVIGATE_TO_START',
59 NavigateToWaypoint(robot, ds.EdEntityDesignator(robot, uuid=HOME_LOCATION)),
60 transitions={
'arrived':
'FIND_OPERATOR_IN_ROOM',
61 'unreachable':
'NAVIGATE_TO_START',
62 'goal_not_defined':
'done'})
65 smach.StateMachine.add(
'FIND_OPERATOR_IN_ROOM',
66 FindPerson(robot=robot,
67 found_entity_designator=operator_designator,
68 discard_other_labels=
False,
71 transitions={
'found':
'LOOK_AT_PERSON',
72 'failed':
'LOOK_AT_CENTER_OF_ROOM'})
74 smach.StateMachine.add(
'LOOK_AT_PERSON',
75 RotateToEntity(robot=robot, entity=operator_designator),
76 transitions={
'succeeded':
'ASK_TO_POINT',
77 'failed':
'LOOK_AT_CENTER_OF_ROOM'})
80 smach.StateMachine.add(
'ASK_TO_POINT', Say(robot,
"What do you need?", block=
True),
81 transitions={
'spoken':
'GET_FURNITURE_FROM_OPERATOR_POSE'})
83 smach.StateMachine.add(
'LOOK_AT_CENTER_OF_ROOM',
84 RotateToEntity(robot=robot, entity=room_designator),
85 transitions={
'succeeded':
'SAY_CANT_FIND_PERSON',
86 'failed':
'SAY_CANT_FIND_PERSON'})
88 smach.StateMachine.add(
'SAY_CANT_FIND_PERSON',
89 Say(robot,
'I did not find you, please stand in my view'),
90 transitions={
'spoken':
'WAIT_FOR_OPERATOR'})
92 smach.StateMachine.add(
'WAIT_FOR_OPERATOR', WaitTime(robot, 3),
93 transitions={
'waited':
'ASK_TO_POINT',
94 'preempted':
'ASK_TO_POINT'})
96 smach.StateMachine.add(
'GET_FURNITURE_FROM_OPERATOR_POSE',
99 transitions={
'done':
'INSPECT_FURNITURE',
100 'failed':
'SAY_TRY_NEXT'})
103 smach.StateMachine.add(
'INSPECT_FURNITURE',
105 transitions={
"succeeded":
"IDENTIFY_OBJECT",
106 "failed":
"SAY_NO_OBJECT"})
109 smach.StateMachine.add(
'SAY_NO_OBJECT', Say(robot, [
'I did not find any object object there']),
110 transitions={
'spoken':
'NAVIGATE_TO_START'})
113 smach.StateMachine.add(
'IDENTIFY_OBJECT',
115 transitions={
'done':
'NAVIGATE_TO_START',
116 'failed':
'SAY_TRY_NEXT'})
118 smach.StateMachine.add(
'SAY_TRY_NEXT', Say(robot, [
'I am sorry, lets skip this one and'
119 ' let me try another one',
120 'I will go for the next item']),
121 transitions={
'spoken':
'NAVIGATE_TO_START'})