3 from __future__
import print_function
7 female_names = [
"sophia",
"isabella",
"emma",
"olivia",
"ava",
"emily",
"abigail",
"madison",
"mia",
"chloe"]
8 male_names = [
"james",
"john",
"robert",
"michael",
"william",
"david",
"richard",
"charles",
"joseph",
"thomas"]
10 names = female_names + male_names
14 {
'name':
'bed',
'room':
'bedroom',
'category':
'utility',
'manipulation':
'no'},
15 {
'name':
'desk',
'room':
'bedroom',
'category':
'table',
'manipulation':
'yes'},
16 {
'name':
'side_table',
'room':
'bedroom',
'category':
'table',
'manipulation':
'yes'},
18 {
'name':
'kitchen_table',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes'},
19 {
'name':
'kitchen_cabinet',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
20 {
'name':
'dishwasher',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'yes'},
21 {
'name':
'cabinet',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
22 {
'name':
'white_drawer',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
23 {
'name':
'trash_can',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'yes'},
25 {
'name':
'tv_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
26 {
'name':
'tv',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
27 {
'name':
'bookcase',
'room':
'living_room',
'category':
'shelf',
'manipulation':
'yes'},
28 {
'name':
'couch',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
29 {
'name':
'left_armchair',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
30 {
'name':
'right_armchair',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
31 {
'name':
'coffee_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
32 {
'name':
'sideboard',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
33 {
'name':
'high_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
34 {
'name':
'trash_bin',
'room':
'living_room',
'category':
'utility',
'manipulation':
'yes'},
35 {
'name':
'coathanger',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
38 {
'name':
'bar_table',
'room':
'bar',
'category':
'table',
'manipulation':
'yes'},
39 {
'name':
'cupboard',
'room':
'bar',
'category':
'shelf',
'manipulation':
'yes'},
40 {
'name':
'sofa',
'room':
'bar',
'category':
'utility',
'manipulation':
'no'}
43 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
44 location_categories = list(set([ o[
"category"]
for o
in locations ]))
45 location_names = list(set([ o[
"name"]
for o
in locations ]))
46 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
48 rooms = location_rooms + [
'hallway']
51 {
'category':
'other',
'name':
'trashbag',
'color':
'black',
'volume': 100,
'weight': 22},
53 {
'category':
'kitchen_stuff',
'name':
'bowl',
'color':
'green',
'volume': 458,
'weight': 65},
54 {
'category':
'kitchen_stuff',
'name':
'cup',
'color':
'yellow',
'volume': 300,
'weight': 50},
55 {
'category':
'kitchen_stuff',
'name':
'fork',
'color':
'orange',
'volume': 22,
'weight': 10},
56 {
'category':
'kitchen_stuff',
'name':
'knife',
'color':
'green',
'volume': 22,
'weight': 10},
57 {
'category':
'kitchen_stuff',
'name':
'plate',
'color':
'blue',
'volume': 672,
'weight': 70},
58 {
'category':
'kitchen_stuff',
'name':
'spoon',
'color':
'blue',
'volume': 23,
'weight': 10},
60 {
'category':
'drink',
'name':
'apple_juice',
'color':
'brown',
'volume': 216,
'weight': 200},
61 {
'category':
'drink',
'name':
'big_coke',
'color':
'brownish',
'volume': 270,
'weight': 222},
62 {
'category':
'drink',
'name':
'big_lemon_juice',
'color':
'transparent',
'volume': 270,
'weight': 222},
63 {
'category':
'drink',
'name':
'big_water',
'color':
'transparent',
'volume': 270,
'weight': 222},
64 {
'category':
'drink',
'name':
'iso_drink',
'color':
'blue',
'volume': 404,
'weight': 325},
65 {
'category':
'drink',
'name':
'milk',
'color':
'blue',
'volume': 216,
'weight': 200},
66 {
'category':
'drink',
'name':
'orange_juice',
'color':
'orange',
'volume': 216,
'weight': 200},
67 {
'category':
'drink',
'name':
'red_spritzer',
'color':
'red',
'volume': 270,
'weight': 222},
68 {
'category':
'drink',
'name':
'sparkling_water',
'color':
'transparent',
'volume': 270,
'weight': 222},
70 {
'category':
'fruit',
'name':
'lemon',
'color':
'yellow',
'volume': 360,
'weight': 85},
71 {
'category':
'fruit',
'name':
'orange',
'color':
'orange',
'volume': 380,
'weight': 140},
73 {
'category':
'care',
'name':
'shower_gel',
'color':
'blue',
'volume': 336,
'weight': 21},
74 {
'category':
'care',
'name':
'soap',
'color':
'ivory',
'volume': 297,
'weight': 85},
75 {
'category':
'care',
'name':
'toothpaste',
'color':
'whitegreen',
'volume': 223,
'weight': 113},
77 {
'category':
'food',
'name':
'bouillon',
'color':
'orange',
'volume': 336,
'weight': 21},
78 {
'category':
'food',
'name':
'corn',
'color':
'yellow',
'volume': 223,
'weight': 113},
79 {
'category':
'food',
'name':
'noodles',
'color':
'yellowish',
'volume': 297,
'weight': 85},
80 {
'category':
'food',
'name':
'pepper',
'color':
'blue',
'volume': 336,
'weight': 21},
81 {
'category':
'food',
'name':
'salt',
'color':
'whiteorange',
'volume': 297,
'weight': 85},
82 {
'category':
'food',
'name':
'sauerkraut',
'color':
'whitegreen',
'volume': 223,
'weight': 113},
83 {
'category':
'food',
'name':
'seasoning_mix',
'color':
'orange',
'volume': 297,
'weight': 85},
84 {
'category':
'food',
'name':
'tomatoes',
'color':
'blue',
'volume': 223,
'weight': 113},
86 {
'category':
'container',
'name':
'basket',
'color':
'white',
'volume': 3487,
'weight': 43},
87 {
'category':
'container',
'name':
'tray',
'color':
'gray',
'volume': 4508,
'weight': 120},
89 {
'category':
'cleaning_stuff',
'name':
'cloth',
'color':
'yellow',
'volume': 315,
'weight': 37},
90 {
'category':
'cleaning_stuff',
'name':
'dishwasher_tab',
'color':
'yellowish',
'volume': 100,
'weight': 22},
92 {
'category':
'snack',
'name':
'cereal_bar_chocolate',
'color':
'blue',
'volume': 243,
'weight': 28},
93 {
'category':
'snack',
'name':
'cereal_bar_chocolate_banana',
'color':
'yellow',
'volume': 4080,
'weight': 200},
94 {
'category':
'snack',
'name':
'cracker',
'color':
'redwhite',
'volume': 1125,
'weight': 156},
95 {
'category':
'kitchen_stuff',
'name':
'fruit_bar_apple',
'color':
'green',
'volume': 458,
'weight': 65},
96 {
'category':
'kitchen_stuff',
'name':
'fruit_bar_forest_fruit',
'color':
'blue',
'volume': 300,
'weight': 50},
97 {
'category':
'kitchen_stuff',
'name':
'get_it',
'color':
'orange',
'volume': 22,
'weight': 10},
98 {
'category':
'kitchen_stuff',
'name':
'nut_fruit_mix',
'color':
'redwhite',
'volume': 22,
'weight': 10},
99 {
'category':
'kitchen_stuff',
'name':
'peanut_bits',
'color':
'red',
'volume': 672,
'weight': 70}
102 object_names = list(set([ o[
"name"]
for o
in objects ]))
103 object_categories = list(set([ o[
"category"]
for o
in objects ]))
104 object_color = list(set([ o[
"color"]
for o
in objects ]))
105 object_size = list(set([ o[
"volume"]
for o
in objects ]))
106 object_weight = list(set([ o[
"weight"]
for o
in objects ]))
110 category_locations = {
111 "cleaning_stuff": {
"dishwasher":
"on_top_of"},
112 "snack": {
"coffee_table":
"on_top_of"},
113 "drink": {
"kitchen_table":
"on_top_of"},
114 "food": {
"bookcase":
"shelf2"},
115 "care": {
"side_table":
"on_top_of"},
116 "container": {
"end_table":
"on_top_of"},
117 "fruit": {
"bar_table":
"on_top_of"},
118 "kitchen_stuff": {
"kitchen_cabinet":
"on_top_of"},
122 "bookcase": [
"shelf1",
"shelf2"]
125 inspect_positions = {
130 most_probable_location_in_room_map = {
131 'bedroom':
'side_table',
132 'kitchen':
'kitchen_cabinet',
134 'living_room':
'bookcase'
138 if room_id
in most_probable_location_in_room_map:
139 return most_probable_location_in_room_map[room_id]
143 drink_names = [obj[
'name']
for obj
in objects
if obj[
'category'] ==
'drink']
144 drink_spec =
"T['drink': O] -> OPTIONS[O]\n\n"
145 for dn
in drink_names:
146 drink_spec +=
"OPTIONS['{drink}'] -> {drink}\n".format(drink=dn)
149 ''' colors from printing on screen '''
158 UNDERLINE =
'\033[4m'
162 General function for printing shortcuts
163 name: name of the program that instantiates make_prints
164 sentence: sentence to be displayed
166 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
171 prefix = bcolors.HEADER + name + bcolors.ENDC
174 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
177 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
180 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
182 return printOk, printError, printWarning
187 for loc
in locations:
188 if loc[
"name"] == location:
194 for loc
in locations:
195 if loc[
"name"] == location:
201 return (entity_id
in rooms)
205 if location
in inspect_areas:
206 return inspect_areas[location]
212 if location
in inspect_positions
and area
in inspect_positions[location]:
213 return inspect_positions[location][area]
219 for loc
in locations:
220 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
226 for loc
in locations:
227 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
232 def get_locations(room=None, pick_location=None, place_location=None):
233 return [loc[
"name"]
for loc
in locations
234 if (room ==
None or loc[
"room"] == room)
and \
235 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
240 return [obj[
"name"]
for obj
in objects
241 if category ==
None or category == obj[
"category"]]
270 location, area_name = next(iter(category_locations[obj_cat].items()))
271 return location, area_name
276 if __name__ ==
"__main__":
277 print(
"\n-----------------------------------------------------------------------------")
281 print(
"object '{}'".format(obj))
282 print(
" category: '{}'".format(cat))
283 print(
" found '{} {}'".format(area_name, location))
285 print(
"\n-----------------------------------------------------------------------------")
287 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
289 print(
"\n-----------------------------------------------------------------------------")
290 print(
"Pick locations:")
292 print(
" {}".format(loc))
294 print(
"\n-----------------------------------------------------------------------------")
295 print(
"Place locations:")
297 print(
" {}".format(loc))
299 print(
"\n-----------------------------------------------------------------------------")
300 print(
"None-manipulation locations:")
301 for loc
in get_locations(pick_location=
False, place_location=
False):
302 print(
" {}".format(loc))