3 from __future__
import print_function
5 names = [
'peter',
'josja']
8 {
'name':
'dinner_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
10 {
'name':
'cabinet',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
11 {
'name':
'trashbin',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'yes'},
12 {
'name':
'couch',
'room':
'hallway',
'category':
'table',
'manipulation':
'yes'},
14 {
'name':
'counter',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
15 {
'name':
'tray_table',
'room':
'living_room',
'category':
'shelf',
'manipulation':
'yes'}
18 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
19 location_categories = list(set([ o[
"category"]
for o
in locations ]))
20 location_names = list(set([ o[
"name"]
for o
in locations ]))
21 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
23 location_rooms += [
"workshop"]
24 rooms = location_rooms
27 {
'category':
'container',
'name':
'cup',
'color':
'green'},
28 {
'category':
'drink',
'name':
'coke',
'color':
'red'},
29 {
'category':
'drink',
'name':
'fanta_bottle',
'color':
'red'},
30 {
'category':
'drink',
'name':
'coke_zero',
'color':
'black'},
31 {
'category':
'drink',
'name':
'fanta',
'color':
'orange'},
32 {
'category':
'snack',
'name':
'pringles',
'color':
'orange'},
33 {
'category':
'snack',
'name':
'apple',
'color':
'green'},
36 object_names = list(set([ o[
"name"]
for o
in objects ]))
37 object_categories = list(set([ o[
"category"]
for o
in objects ]))
38 object_color = list(set([ o[
"color"]
for o
in objects ]))
40 category_locations = {
41 "container": {
"cabinet":
"on_top_of"},
42 "drink": {
"dinner_table":
"on_top_of"},
43 "snack": {
"cabinet":
"on_top_of"},
44 "cleaning_stuff": {
"cabinet":
"on_top_of"},
53 most_probable_location_in_room_map = {
54 'living_room':
'dinner_table',
60 if room_id
in most_probable_location_in_room_map:
61 return most_probable_location_in_room_map[room_id]
66 ''' colors from printing on screen '''
79 General function for printing shortcuts
80 name: name of the program that instantiates make_prints
81 sentence: sentence to be displayed
83 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
89 prefix = bcolors.HEADER + name + bcolors.ENDC
91 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
94 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
97 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
99 return printOk, printError, printWarning
104 for loc
in locations:
105 if loc[
"name"] == location:
111 for loc
in locations:
112 if loc[
"name"] == location:
118 return (entity_id
in rooms)
121 if location
in inspect_positions
and area
in inspect_positions[location]:
122 return inspect_positions[location][area]
128 for loc
in locations:
129 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
134 if location
in inspect_areas:
135 return inspect_areas[location]
140 if location
in inspect_positions
and area
in inspect_positions[location]:
141 return inspect_positions[location][area]
146 for loc
in locations:
147 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
152 def get_locations(room=None, pick_location=None, place_location=None):
153 return [loc[
"name"]
for loc
in locations
154 if (room ==
None or loc[
"room"] == room)
and \
155 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
160 return [obj[
"name"]
for obj
in objects
161 if category ==
None or category == obj[
"category"]]
178 location, area_name = next(iter(category_locations[obj_cat].items()))
179 return location, area_name
184 if __name__ ==
"__main__":
185 print(
"\n-----------------------------------------------------------------------------")
189 print(
"object '{}'".format(obj))
190 print(
" category: '{}'".format(cat))
191 print(
" found '{} {}'".format(area_name, location))
193 print(
"\n-----------------------------------------------------------------------------")
195 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
197 print(
"\n-----------------------------------------------------------------------------")
198 print(
"Pick locations:")
200 print(
" {}".format(loc))
202 print(
"\n-----------------------------------------------------------------------------")
203 print(
"Place locations:")
205 print(
" {}".format(loc))
207 print(
"\n-----------------------------------------------------------------------------")
208 print(
"None-manipulation locations:")
209 for loc
in get_locations(pick_location=
False, place_location=
False):
210 print(
" {}".format(loc))