3 from __future__
import print_function
5 from robocup_knowledge
import knowledge_loader
6 common = knowledge_loader.load_knowledge(
"common")
9 Local knowledge info needed:
10 The room to search has to have enough (way)points to cover the complete area.
11 This means waypoints on the floor, and known (furniture) object points.
12 Exact coordinates of the locations are in ed_object_models.
16 starting_point =
"initial_pose"
17 waiting_point =
"cleanup_initial"
19 cleaning_locations = [
20 {
'name':
'bedroom_chest',
'room':
'bedroom',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
21 {
'name':
'bed',
'room':
'bedroom',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
22 {
'name':
'sidetable',
'room':
'bedroom',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
23 {
'name':
'shelf',
'room':
'bedroom',
'navigation_area':
'in_front_of',
'segment_areas': [
'shelf2',
'shelf3',
'shelf4',
'shelf5']},
26 {
'name':
'kitchen_cabinet',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'shelf1',
'shelf2',
'shelf3']},
27 {
'name':
'kitchen_table',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
28 {
'name':
'island',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
29 {
'name':
'sink',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
30 {
'name':
'dishwasher',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
31 {
'name':
'fridge',
'room':
'kitchen',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
33 {
'name':
'shoe_rack',
'room':
'office',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
34 {
'name':
'safe',
'room':
'office',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
35 {
'name':
'desk',
'room':
'office',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
38 {
'name':
'coffee_table',
'room':
'living_room',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
39 {
'name':
'couch',
'room':
'living_room',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
40 {
'name':
'armchair',
'room':
'living_room',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
41 {
'name':
'display_cabinet',
'room':
'living_room',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']},
43 {
'name':
'sideboard',
'room':
'living_room',
'navigation_area':
'in_front_of',
'segment_areas': [
'on_top_of']}
46 trashbin_id =
"trash_bin"
51 for room
in common.location_rooms:
52 grammar +=
"\nT[{0}] -> {0}".format(room)
54 category_grammar =
"""
55 T[P] -> CATEGORY[P] | it is a CATEGORY[P] | the category is CATEGORY[P]
57 for l
in common.category_locations:
58 category_grammar +=
"\nCATEGORY[{}] -> {}".format(l, l.replace(
'_',
' '))
60 category_grammar +=
"\nCATEGORY[{}] -> {}".format(
"trash",
"trash".replace(
'_',
' '))
63 if __name__ ==
"__main__":
64 print(
"Clean-up Grammar:\n\n{}\n\n".format(category_grammar))
66 from grammar_parser.cfgparser
import CFGParser
69 grammar_parser = CFGParser.fromstring(category_grammar)
72 sentence =
" ".join(sys.argv[2:])
74 sentence = grammar_parser.get_random_sentence(
"T")
76 print(
"Parsing sentence:\n\n{}\n\n".format(sentence))
78 result = grammar_parser.parse(
"T", sentence)
80 print(
"Result:\n\n{}".format(result))