robocup_knowledge
siza_demo/challenge_demo.py
Go to the documentation of this file.
1 from __future__ import print_function
2 
3 from robocup_knowledge import knowledge_loader
4 common = knowledge_loader.load_knowledge("common")
5 
6 not_understood_sentences = [
7  "I'm so sorry! Can you please speak louder and slower? And wait for the ping!",
8  "I am deeply sorry. Please try again, but wait for the ping!",
9  "You and I have communication issues. Speak up!",
10  "All this noise is messing with my audio. Try again"
11  ]
12 
13 initial_pose = "hero_home"
14 
15 grammar_target = "T"
16 
17 
22 
23 grammar = """
24 T[A] -> C[A] | COURTESY C[A]
25 
26 COURTESY -> please | robot please | could you | would you | hero | hero please
27 C[{"actions": <A1>}] -> VP[A1]
28 C[{"actions": <A1, A2>}] -> VP[A1] and VP[A2]
29 C[{"actions": <A1, A2, A3>}] -> VP[A1] VP[A2] and VP[A3]
30 """
31 
32 
37 
38 grammar += """
39 
40 DET -> the | a | an | some
41 NUMBER -> one | two | three
42 MANIPULATION_AREA_DESCRIPTION -> on top of | at | in | on | from
43 """
44 
45 for room in common.location_rooms:
46  grammar += "\nROOM[{'type': 'room', 'id': '%s'}] -> %s" % (room, room)
47 
48 for loc in common.get_locations():
49  grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
50 
51 grammar += '\n ROOM_OR_LOCATION[X] -> ROOM[X] | LOCATION[X]'
52 
53 for obj in common.object_names:
54  grammar += '\nNAMED_OBJECT[%s] -> %s' % (obj, obj)
55 
56 for loc in common.get_locations(pick_location=True, place_location=True):
57  grammar += '\nMANIPULATION_AREA_LOCATION[%s] -> MANIPULATION_AREA_DESCRIPTION the %s' % (loc, loc)
58 
59 for cat in common.object_categories:
60  grammar += '\nOBJECT_CATEGORY[%s] -> %s' % (cat, cat)
61 
62 for name in common.names:
63  grammar += '\nNAMED_PERSON[%s] -> %s' % (name, name)
64 
65 
70 
71 grammar += """
72 V_PRESENT -> introduce yourself | present yourself | perform a demonstration | give a presentation
73 ENGLISH['en'] -> english
74 DUTCH['nl'] -> dutch
75 LANGUAGE[X] -> ENGLISH[X] | DUTCH[X]
76 VP["action": "demo-presentation", 'language': 'en'] -> V_PRESENT
77 VP["action": "demo-presentation", "language": X] -> V_PRESENT in LANGUAGE[X]
78 """
79 
80 
85 grammar += """
86 V_SEND_PICTURE -> check what is on | show me what is on
87 VP[{"action": "send-picture", "target-location": X}] -> V_SEND_PICTURE the ROOM_OR_LOCATION[X]
88 """
89 
90 
95 
96 grammar += """
97 V_CLEAR -> clear | clean up | clean-up | empty
98 
99 VP[{"action": "clear", "source-location": X, "target-location": {"id":"trashbin"}}] -> V_CLEAR the ROOM_OR_LOCATION[X]
100 VP[{"action": "clear", "source-location": X, "target-location": Y}] -> V_CLEAR the ROOM_OR_LOCATION[X] to the ROOM_OR_LOCATION[Y]
101 """
102 
103 
108 
109 grammar += """
110 V_RETURN -> bye | no thank you | no bye | go away
111 
112 VP[{"action": "navigate-to", "target-location": {"type":"waypoint", "id":"hero_home"}}] -> V_RETURN
113 """
114 
115 
120 
121 grammar += """
122 V_FIND -> find | locate | look for | pinpoint | spot
123 V_FIND_PERSON -> meet | V_FIND
124 
125 OBJECT_TO_BE_FOUND -> NAMED_OBJECT | OBJECT_CATEGORY
126 PERSON_TO_BE_FOUND -> DET person | DET woman | DET man | someone | me
127 
128 VP["action": "find", "object": {"type": X}, "location": {"id": Y}] -> V_FIND DET OBJECT_TO_BE_FOUND[X] MANIPULATION_AREA_LOCATION[Y]
129 VP[{"action": "find", "object": X, "source-location": Y}] -> V_FIND DET OBJECT_TO_BE_FOUND[X] in the ROOM[Y]
130 VP["action": "find", "object": {"type": X}] -> V_FIND DET OBJECT_TO_BE_FOUND[X]
131 
132 VP[{"action": "find", "object": X, "source-location": Y}] -> V_FIND PERSON_TO_BE_FOUND[X] in the ROOM[Y]
133 VP[{"action": "find", "object": X, "source-location": Y}] -> V_FIND PERSON_TO_BE_FOUND[X] near the LOCATION[Y]
134 VP[{"action": "find", "object": X}] -> V_FIND DET PERSON_TO_BE_FOUND[X]
135 """
136 
137 
142 
143 grammar += """
144 V_GOPL -> go to | navigate to | drive to
145 
146 VP["action": "navigate-to", "object": {"id": X}] -> V_GOPL the LOCATION[X]
147 """
148 
149 
154 
155 grammar += """
156 
157 VP["action": "inspect", "entity": {"id": X}] -> inspect the LOCATION[X]
158 """
159 
160 
165 
166 grammar += """
167 OBJECT_TO_BE_BROUGHT -> NAMED_OBJECT | DET NAMED_OBJECT
168 
169 V_BRING -> bring | deliver | take | carry | transport | give | hand | hand over
170 
171 VP["action": "place", "source-location": {"id": X}, "target-location": {"id": Y}, "object": {"type": Z}] -> V_BRING OBJECT_TO_BE_BROUGHT[Z] from the LOCATION[X] to the LOCATION[Y]
172 VP["action": "hand-over", "source-location": {"id": X}, "target-location": {"id": "operator"}, "object": {"type": Z}] -> V_BRING me OBJECT_TO_BE_BROUGHT[Z] from the LOCATION[X] | V_BRING OBJECT_TO_BE_BROUGHT[Z] from the LOCATION[X] to me
173 """
174 
175 
180 
181 grammar += """
182 V_SAY -> tell | say
183 
184 VP["action": "say", "sentence": X] -> V_SAY SAY_SENTENCE[X]
185 """
186 
187 grammar += '\nSAY_SENTENCE["ROBOT_NAME"] -> your name'
188 grammar += '\nSAY_SENTENCE["TIME"] -> the time | what time it is | what time is it'
189 grammar += '\nSAY_SENTENCE["my team is tech united"] -> the name of your team'
190 grammar += '\nSAY_SENTENCE["DAY_OF_MONTH"] -> the day of the month'
191 grammar += '\nSAY_SENTENCE["DAY_OF_WEEK"] -> the day of the week'
192 grammar += '\nSAY_SENTENCE["TODAY"] -> what day is today | me what day it is | the date'
193 grammar += '\nSAY_SENTENCE["JOKE"] -> a joke'
194 
195 
200 
201 
202 if __name__ == "__main__":
203  print("GPSR Grammar:\n\n{}\n\n".format(grammar))
204 
205  from grammar_parser.cfgparser import CFGParser
206 
207  import sys
208  if sys.argv[1] == "object":
209  grammar_parser = CFGParser.fromstring(obj_grammar)
210  elif sys.argv[1] == "location":
211  grammar_parser = CFGParser.fromstring(loc_grammar)
212  elif sys.argv[1] == "full":
213  grammar_parser = CFGParser.fromstring(grammar)
214 
215  if len(sys.argv) > 2:
216  sentence = " ".join(sys.argv[2:])
217  else:
218  sentence = grammar_parser.get_random_sentence("T")
219 
220  print("Parsing sentence:\n\n{}\n\n".format(sentence))
221 
222  result = grammar_parser.parse("T", sentence)
223 
224  print("Result:\n\n{}".format(result))
common.get_locations
def get_locations(room=None, manipulation_location=None)
Definition: rwc2023/common.py:156