robocup_knowledge
rgo2019/challenge_where_is_this.py
Go to the documentation of this file.
1 # RIPS KNOWLEDGE FILE RGO2019
2 
3 from __future__ import print_function
4 
5 # TU/e Robotics
6 from robocup_knowledge import knowledge_loader
7 
8 # Common knowledge
9 common = knowledge_loader.load_knowledge("common")
10 
11 grammar_target = "T"
12 
13 location_grammar = """
14 T[A] -> COURTESY_PREFIX VP[A] | VP[A]
15 
16 COURTESY_PREFIX -> robot please | could you | could you please | please
17 """
18 
19 for loc in common.location_rooms:
20  location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
21 
22 for loc in common.location_names:
23  location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (loc, loc)
24 
25 for loc in common.object_names:
26  category = common.get_object_category(loc)
27  if category not in common.category_locations:
28  continue
29 
30  entity_id = common.get_object_category_location(category)[0]
31 
32  location_grammar += '\nLOCATION[{"id": "%s"}] -> %s' % (entity_id, loc)
33 
34 location_grammar += '\nDET_LOCATION[Y] -> LOCATION[Y] | the LOCATION[Y]'
35 
36 location_grammar += """
37 V_GUIDE -> guide | bring | lead
38 
39 VP[{"target-location": Y}] -> DET_LOCATION[Y] | V_GUIDE me to DET_LOCATION[Y] | i want to go to DET_LOCATION[Y] | i would like to go to DET_LOCATION[Y] | i like to go to DET_LOCATION[Y] | tell me how to go to DET_LOCATION[Y] | tell me how to reach DET_LOCATION[Y]
40 
41 """
42 
43 if __name__ == "__main__":
44  print("Where is this Grammar:\n\n{}\n\n".format(location_grammar))
45 
46  from grammar_parser.cfgparser import CFGParser
47 
48  grammar_parser = CFGParser.fromstring(location_grammar)
49  grammar_parser.verify()
50  grammar_parser.check_rules()
common.get_object_category_location
def get_object_category_location(obj_cat)
Definition: demo/common.py:143
common.get_object_category
def get_object_category(obj)
Definition: demo/common.py:136