robocup_knowledge
rgo2019/challenge_eegpsr.py
Go to the documentation of this file.
1 # EEGPSR KNOWLEDGE FILE RGO2019
2 
3 from __future__ import print_function
4 
5 from robocup_knowledge import knowledge_loader
6 common = knowledge_loader.load_knowledge("common")
7 
8 not_understood_sentences = [
9  "I'm so sorry! Can you please speak clearly and fluently? And wait for the ping!",
10  "I am deeply sorry. Please try again, but wait for the ping!",
11  "You and I have communication issues. Speak clearly!",
12  "All this noise is messing with my audio. Try again."
13  ]
14 
15 initial_pose = "initial_pose"
16 starting_pose = "eegpsr_starting_point1"
17 exit_waypoint = "exit_3_rips"
18 
19 grammar_target = "T"
20 
21 
26 
27 grammar = """
28 T[A] -> COURTESY_PREFIX C[A] | C[A]
29 
30 C[{"actions": <A1, A2, A3>}] -> VP[A1] VP[A2] and VPT[A3]
31 
32 VPT -> VP | VPS
33 
34 COURTESY_PREFIX -> robot please | could you | could you please
35 """
36 
37 
42 
43 grammar += """
44 PPN_OBJECT -> it
45 PPN_PERSON -> him | her
46 
47 DET -> the | a
48 NUMBER -> one | two | three
49 MEETING_PP -> at | in
50 MANIPULATION_PP -> on | to
51 """
52 
53 for room in common.location_rooms:
54  grammar += "\nROOM[{'type': 'room', 'id': '%s'}] -> %s" % (room, room)
55 
56 for loc in common.get_locations():
57  grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
58 
59 grammar += '\n ROOM_OR_LOCATION[X] -> ROOM[X] | LOCATION[X]'
60 
61 for obj in common.object_names:
62  grammar += "\nNAMED_OBJECT[{'type': '%s'}] -> %s" % (obj, obj)
63 
64 for loc in common.get_locations(pick_location=True, place_location=True):
65  grammar += '\nMANIPULATION_AREA_LOCATION[{"id": "%s"}] -> MANIPULATION_PP the %s' % (loc, loc)
66 
67 for cat in common.object_categories:
68  grammar += "\nOBJECT_CATEGORY[{'category': '%s'}] -> %s" % (cat, cat)
69 
70 for name in common.names:
71  grammar += "\nNAMED_PERSON[{'type': 'person', 'id': '%s'}] -> %s" % (name, name)
72  grammar += "\nPERSON_AT_LOCATION[{'type': 'person', 'id': '%s', 'location': {'id': 'gpsr_entrance', 'type': 'waypoint'}}] -> %s at the entrance" % (
73  name, name)
74  for loc in common.get_locations():
75  grammar += "\nPERSON_AT_LOCATION[{'type': 'person', 'id': '%s', 'location': {'id': %s}}] -> %s at the %s" % (name, loc, name, loc)
76 
77 grammar += '\nLOCATION[{"id": "gpsr_entrance", "type": "waypoint"}] -> entrance'
78 
79 
84 
85 grammar += """
86 V_FIND -> find | locate | look for | pinpoint | spot
87 
88 TYPE_OR_CATEGORY -> NAMED_OBJECT | OBJECT_CATEGORY
89 UNNAMED_PERSON -> a person | someone
90 
91 VP[{"action": "find", "object": {'type': 'person'}}] -> V_FIND UNNAMED_PERSON
92 VP[{"action": "find", "object": X}] -> V_FIND NAMED_PERSON[X]
93 VP[{"action": "find", "object": X, "source-location": Y}] -> V_FIND NAMED_PERSON[X] MEETING_PP the ROOM_OR_LOCATION[Y]
94 
95 VP[{"action": "find", "object": X, "source-location": Y}] -> V_FIND DET TYPE_OR_CATEGORY[X] in the ROOM[Y]
96 
97 VP[{"action": "find"}] -> V_FIND DET object
98 VP[{"action": "find", "source-location": Y}] -> V_FIND DET object in the ROOM[Y]
99 
100 VP[{"action": "find", "object": X}] -> V_FIND DET TYPE_OR_CATEGORY[X]
101 """
102 
103 
104 # ##############################################################################
105 #
106 # Follow
107 #
108 # ##############################################################################
109 
110 grammar += """
111 V_FOLLOW -> come behind | come after | follow | go after | go behind
112 
113 VP[{"action": "follow", "target": {"type": "reference"}}] -> V_FOLLOW PPN_PERSON
114 """
115 
116 
121 
122 grammar += """
123 V_GUIDE -> guide | escort | take | lead | accompany | conduct
124 
125 VPS[{"action": "guide", "object": {"type": "reference"}}] -> V_GUIDE PPN_PERSON
126 VP[{"action": "guide", "target-location": Y, "object": {"type": "reference"}}] -> V_GUIDE PPN_PERSON to the ROOM_OR_LOCATION[Y]
127 """
128 
129 
130 
135 
136 grammar += """
137 V_GOTO -> go to | navigate to | enter to
138 
139 VP[{"action": "navigate-to", "target-location": X}] -> V_GOTO the ROOM_OR_LOCATION[X]
140 """
141 
142 
143 
148 
149 grammar += """
150 V_PICKUP -> get | grasp | take | pick up | grab | retrieve
151 
152 VP[{"action": "pick-up", "object": X}] -> V_PICKUP DET TYPE_OR_CATEGORY[X]
153 VP[{"action": "pick-up", "object": X, "source-location": Y}] -> V_PICKUP DET TYPE_OR_CATEGORY[X] from the LOCATION[Y]
154 """
155 
156 
161 
162 grammar += """
163 OPERATOR[{"type": "person", "id": "operator"}] -> me
164 BRING_NAME -> OPERATOR | NAMED_PERSON
165 
166 OBJECT_TO_BE_BROUGHT -> NAMED_OBJECT | DET NAMED_OBJECT
167 
168 V_BRING -> bring | deliver | give | hand over | hand
169 """
170 
171 grammar += """
172 VP[{"action": "hand-over", "target-location": Y, "object": Z}] -> V_BRING OPERATOR[Y] DET NAMED_OBJECT[Z]
173 VP[{"action": "hand-over", "source-location": X, "target-location": Y, "object": Z}] -> V_BRING OPERATOR[Y] DET NAMED_OBJECT[Z] from the LOCATION[X]
174 VP[{"action": "hand-over", "source-location": X, "target-location": Y, "object": Z}] -> V_BRING to PERSON_AT_LOCATION[Y] DET NAMED_OBJECT[Z] from the LOCATION[X]
175 
176 VP[{"action": "hand-over", "target-location": Y, "object": Z}] -> V_BRING DET NAMED_OBJECT[Z] to PERSON_AT_LOCATION[Y]
177 VP[{"action": "hand-over", "target-location": Y, "object": Z}] -> V_BRING DET NAMED_OBJECT[Z] to OPERATOR[Y]
178 
179 VPS[{"action": "hand-over", "target-location": X, "object": {"type": "reference"}}] -> V_BRING PPN_OBJECT to PERSON_AT_LOCATION[X]
180 VPS[{"action": "hand-over", "target-location": X, "object": {"type": "reference"}}] -> V_BRING PPN_OBJECT to OPERATOR[X]
181 """
182 
183 
188 
189 grammar += """
190 V_PLACE -> put | place | leave | set
191 
192 VP[{"action": "place", "object": X, "target-location": Y}] -> V_PLACE NAMED_OBJECT[X] MANIPULATION_AREA_LOCATION[Y]
193 VP[{"action": "place", "object": X, "target-location": Y}] -> V_PLACE DET NAMED_OBJECT[X] MANIPULATION_AREA_LOCATION[Y]
194 
195 VP[{"action": "place", "target-location": X, "object": {"type": "reference"}}] -> V_PLACE PPN_OBJECT on the LOCATION[X]
196 VP[{"action": "place", "object": {"type": "reference"}}] -> V_PLACE PPN_OBJECT to the ROOM
197 """
198 
199 
204 
205 grammar += """
206 V_SAY -> tell | say
207 V_SAY_UNDEFINED -> speak | say something
208 
209 VPS[{"action": "say"}] -> V_SAY_UNDEFINED
210 VPS[{"action": "say", "sentence": X}] -> V_SAY SAY_SENTENCE[X]
211 """
212 
213 grammar += '\nSAY_SENTENCE["time"] -> the time'
214 grammar += '\nSAY_SENTENCE["team_name"] -> your teams name'
215 grammar += '\nSAY_SENTENCE["country"] -> your teams country'
216 grammar += '\nSAY_SENTENCE["team_affiliation"] -> your teams affiliation'
217 grammar += '\nSAY_SENTENCE["day_of_month"] -> the day of the month'
218 grammar += '\nSAY_SENTENCE["day_of_week"] -> the day of the week'
219 grammar += '\nSAY_SENTENCE["today"] -> what day is today'
220 grammar += '\nSAY_SENTENCE["tomorrow"] -> what day is tomorrow'
221 grammar += '\nSAY_SENTENCE["joke"] -> a joke'
222 grammar += '\nSAY_SENTENCE["something_about_self"] -> something about yourself'
223 grammar += '\nSAY_SENTENCE["electric_sheep"] -> whether you dream or not on electric sheep'
224 
225 
230 
231 grammar += """
232 V_ANSWER_QUESTION -> answer a question
233 VPS[{"action": "answer-question"}] -> V_ANSWER_QUESTION
234 """
235 
236 
237 if __name__ == "__main__":
238  print("GPSR Grammar:\n\n{}\n\n".format(grammar))
239 
240  from grammar_parser.cfgparser import CFGParser
241 
242  import sys
243  grammar_parser = CFGParser.fromstring(grammar)
244 
245  if len(sys.argv) > 2:
246  sentence = " ".join(sys.argv[2:])
247  else:
248  sentence = grammar_parser.get_random_sentence("T")
249 
250  print("Parsing sentence:\n\n{}\n\n".format(sentence))
251 
252  result = grammar_parser.parse("T", sentence)
253 
254  print("Result:\n\n{}".format(result))
common.get_locations
def get_locations(room=None, manipulation_location=None)
Definition: rwc2023/common.py:156