robocup_knowledge
impuls/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 grammar_target = "T"
14 
15 
20 
21 grammar = """
22 T[{actions : <A1>}] -> C[A1]
23 
24 C[{A}] -> VP[A]
25 """
26 
27 
32 
33 grammar += """
34 DET -> the | a | an | some
35 MANIPULATION_AREA_DESCRIPTION -> on top of | at | in | on | from
36 """
37 
38 for loc in common.get_locations():
39  grammar += '\nLOCATION[%s] -> %s' % (loc, loc)
40 
41 for obj in common.object_names:
42  grammar += '\nNAMED_OBJECT[%s] -> %s' % (obj, obj)
43 
44 for loc in common.get_locations(pick_location=True, place_location=True):
45  grammar += '\nMANIPULATION_AREA_LOCATION[%s] -> MANIPULATION_AREA_DESCRIPTION the %s' % (loc, loc)
46 
47 for cat in common.object_categories:
48  grammar += '\nOBJECT_CATEGORY[%s] -> %s' % (cat, cat)
49 
50 for name in common.names:
51  grammar += '\nNAMED_PERSON[%s] -> %s' % (name, name)
52 
53 
58 
59 grammar += """
60 V_PRESENT -> introduce yourself | present yourself | perform a demonstration | give a presentation
61 ENGLISH['en'] -> english
62 DUTCH['nl'] -> dutch
63 LANGUAGE[X] -> ENGLISH[X] | DUTCH[X]
64 VP["action": "demo-presentation", 'language': 'en'] -> V_PRESENT
65 VP["action": "demo-presentation", "language": X] -> V_PRESENT in LANGUAGE[X]
66 """
67 
68 
73 
74 grammar += """
75 V_POINT -> tell me what i am pointing at | watch me point at stuff | what is this
76 VP["action": "point-target"] -> V_POINT
77 """
78 
79 
84 
85 grammar += """
86 V_FIND -> find | locate | look for
87 
88 VP["action": "find", "object": {"type": X}, "location": {"id": Y}] -> V_FIND DET NAMED_OBJECT[X] MANIPULATION_AREA_LOCATION[Y]
89 VP["action": "find", "object": {"type": X}] -> V_FIND DET NAMED_OBJECT[X]
90 """
91 
92 
97 
98 grammar += """
99 V_GOPL -> go to | navigate to | drive to
100 
101 VP["action": "navigate-to", "target-location": {"id": X}] -> V_GOPL the LOCATION[X]
102 """
103 
104 
105 
110 
111 grammar += """
112 
113 VP["action": "inspect", "entity": {"id": X}] -> inspect the LOCATION[X]
114 """
115 
116 
121 
122 grammar += """
123 OBJECT_TO_BE_BROUGHT -> NAMED_OBJECT | DET NAMED_OBJECT
124 
125 V_BRING -> bring | deliver | take | carry | transport | give | hand | hand over
126 
127 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]
128 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
129 """
130 
131 
136 
137 grammar += """
138 V_SAY -> tell | say
139 
140 VP["action": "say", "sentence": X] -> V_SAY SAY_SENTENCE[X]
141 """
142 
143 grammar += '\nSAY_SENTENCE["ROBOT_NAME"] -> your name'
144 grammar += '\nSAY_SENTENCE["TIME"] -> the time | what time it is | what time is it'
145 grammar += '\nSAY_SENTENCE["my team is tech united"] -> the name of your team'
146 grammar += '\nSAY_SENTENCE["DAY_OF_MONTH"] -> the day of the month'
147 grammar += '\nSAY_SENTENCE["DAY_OF_WEEK"] -> the day of the week'
148 grammar += '\nSAY_SENTENCE["TODAY"] -> what day is today | me what day it is | the date'
149 grammar += '\nSAY_SENTENCE["JOKE"] -> a joke'
150 
151 
156 
157 grammar += """
158 VP["action": "turn-toward-sound", "duration": "30"] -> show your sound source localization | look at me when i am talking to you
159 """
160 
161 
166 
167 if __name__ == "__main__":
168  print("GPSR Grammar:\n\n{}\n\n".format(grammar))
169 
170  from grammar_parser.cfgparser import CFGParser
171 
172  import sys
173  if sys.argv[1] == "object":
174  grammar_parser = CFGParser.fromstring(obj_grammar)
175  elif sys.argv[1] == "location":
176  grammar_parser = CFGParser.fromstring(loc_grammar)
177  elif sys.argv[1] == "full":
178  grammar_parser = CFGParser.fromstring(grammar)
179 
180  if len(sys.argv) > 2:
181  sentence = " ".join(sys.argv[2:])
182  else:
183  sentence = grammar_parser.get_random_sentence("T")
184 
185  print("Parsing sentence:\n\n{}\n\n".format(sentence))
186 
187  result = grammar_parser.parse("T", sentence)
188 
189  print("Result:\n\n{}".format(result))
common.get_locations
def get_locations(room=None, manipulation_location=None)
Definition: rwc2023/common.py:156