robocup_knowledge
rwc2018/challenge_demo.py
Go to the documentation of this file.
1 # DEMO KNOWLEDGE FILE RWC2018
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 louder and slower? 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 up!",
12  "All this noise is messing with my audio. Try again"
13  ]
14 
15 grammar_target = "T"
16 
17 
22 
23 grammar = """
24 T[{actions : <A1>}] -> C[A1]
25 
26 C[{A}] -> VP[A]
27 """
28 
29 
34 
35 grammar += """
36 V_GUIDE -> guide | escort | take | lead | accompany
37 
38 DET -> the | a | an | some
39 NUMBER -> one | two | three
40 MANIPULATION_AREA_DESCRIPTION -> on top of | at | in | on | from
41 """
42 
43 for loc in common.get_locations():
44  grammar += '\nLOCATION[%s] -> %s' % (loc, loc)
45 
46 for obj in common.object_names:
47  grammar += '\nNAMED_OBJECT[%s] -> %s' % (obj, obj)
48 
49 for loc in common.get_locations(pick_location=True, place_location=True):
50  grammar += '\nMANIPULATION_AREA_LOCATION[%s] -> MANIPULATION_AREA_DESCRIPTION the %s' % (loc, loc)
51 
52 for cat in common.object_categories:
53  grammar += '\nOBJECT_CATEGORY[%s] -> %s' % (cat, cat)
54 
55 for name in common.names:
56  grammar += '\nNAMED_PERSON[%s] -> %s' % (name, name)
57 
58 
63 
64 grammar += """
65 V_PRESENT -> introduce yourself | present yourself | perform a demonstration | give a presentation
66 ENGLISH['en'] -> english
67 DUTCH['nl'] -> dutch
68 LANGUAGE[X] -> ENGLISH[X] | DUTCH[X]
69 VP["action": "demo-presentation", 'language': 'en'] -> V_PRESENT
70 VP["action": "demo-presentation", "language": X] -> V_PRESENT in LANGUAGE[X]
71 """
72 
73 
78 
79 grammar += """
80 V_FIND -> find | locate | look for
81 
82 VP["action": "find", "object": {"type": X}, "location": {"id": Y}] -> V_FIND DET NAMED_OBJECT[X] MANIPULATION_AREA_LOCATION[Y]
83 VP["action": "find", "object": {"type": X}] -> V_FIND DET NAMED_OBJECT[X]
84 """
85 
86 
91 
92 grammar += """
93 V_GOPL -> go to | navigate to | drive to
94 
95 VP["action": "navigate-to", "object": {"id": X}] -> V_GOPL the LOCATION[X]
96 """
97 
98 
103 
104 grammar += """
105 
106 VP["action": "inspect", "entity": {"id": X}] -> inspect the LOCATION[X]
107 """
108 
109 
114 
115 grammar += """
116 OBJECT_TO_BE_BROUGHT -> NAMED_OBJECT | DET NAMED_OBJECT
117 
118 V_BRING -> bring | deliver | take | carry | transport | give | hand | hand over
119 
120 VP["action": "bring", "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]
121 VP["action": "bring", "source-location": {"id": X}, "target-location": {"type": "person", "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
122 """
123 
124 
129 
130 grammar += """
131 V_SAY -> tell | say
132 
133 VP["action": "say", "sentence": X] -> V_SAY SAY_SENTENCE[X]
134 """
135 
136 grammar += '\nSAY_SENTENCE["ROBOT_NAME"] -> your name'
137 grammar += '\nSAY_SENTENCE["TIME"] -> the time | what time it is | what time is it'
138 grammar += '\nSAY_SENTENCE["my team is tech united"] -> the name of your team'
139 grammar += '\nSAY_SENTENCE["DAY_OF_MONTH"] -> the day of the month'
140 grammar += '\nSAY_SENTENCE["DAY_OF_WEEK"] -> the day of the week'
141 grammar += '\nSAY_SENTENCE["TODAY"] -> what day is today | me what day it is | the date'
142 grammar += '\nSAY_SENTENCE["JOKE"] -> a joke'
143 
144 
149 
150 grammar += """
151 VP["action": "turn-toward-sound", "duration": "30"] -> show your sound source localization | look at me when i am talking to you
152 """
153 
154 
159 
160 if __name__ == "__main__":
161  print("GPSR Grammar:\n\n{}\n\n".format(grammar))
162 
163  from grammar_parser.cfgparser import CFGParser
164 
165  import sys
166  if sys.argv[1] == "object":
167  grammar_parser = CFGParser.fromstring(obj_grammar)
168  elif sys.argv[1] == "location":
169  grammar_parser = CFGParser.fromstring(loc_grammar)
170  elif sys.argv[1] == "full":
171  grammar_parser = CFGParser.fromstring(grammar)
172 
173  if len(sys.argv) > 2:
174  sentence = " ".join(sys.argv[2:])
175  else:
176  sentence = grammar_parser.get_random_sentence("T")
177 
178  print("Parsing sentence:\n\n{}\n\n".format(sentence))
179 
180  result = grammar_parser.parse("T", sentence)
181 
182  print("Result:\n\n{}".format(result))
common.get_locations
def get_locations(room=None, manipulation_location=None)
Definition: rwc2023/common.py:156