2 from __future__
import print_function
5 female_names = [
"amelia",
"angel",
"ava",
"charlie",
"charlotte",
"hunter",
"max",
"mia",
"olivia",
"parker",
"sam"]
6 male_names = [
"angel",
"charlie",
"hunter",
"jack",
"max",
"noah",
"oliver",
"parker",
"sam",
"thomas",
"william"]
8 names = list(set(female_names + male_names))
12 {
'name':
'desk',
'room':
'office',
'category':
'table',
'manipulation':
'yes'},
13 {
'name':
'side_table',
'room':
'office',
'category':
'table',
'manipulation':
'yes'},
15 {
'name':
'cabinet',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
16 {
'name':
'dishwasher',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
17 {
'name':
'fridge',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
18 {
'name':
'kitchen_table',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes'},
19 {
'name':
'side_board',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes'},
20 {
'name':
'sink',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
21 {
'name':
'workstation',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes'},
23 {
'name':
'arm_chair',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
24 {
'name':
'easy_chair',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
25 {
'name':
'sofa',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
26 {
'name':
'tv_stand',
'room':
'living_room',
'category':
'shelf',
'manipulation':
'no'},
27 {
'name':
'tv_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
29 {
'name':
'bed',
'room':
'bed_room',
'category':
'utility',
'manipulation':
'yes'},
30 {
'name':
'closet',
'room':
'bed_room',
'category':
'shelf',
'manipulation':
'no'},
31 {
'name':
'night_stand',
'room':
'bed_room',
'category':
'table',
'manipulation':
'yes'},
34 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
35 location_categories = list(set([ o[
"category"]
for o
in locations ]))
36 location_names = list(set([ o[
"name"]
for o
in locations ]))
37 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
40 {
'category':
'fruit',
'name':
'apple',
'color':
'red',
'volume': 301,
'weight': 100},
41 {
'category':
'fruit',
'name':
'banana',
'color':
'yellow',
'volume': 450,
'weight': 100},
42 {
'category':
'fruit',
'name':
'lemon',
'color':
'yellow',
'volume': 254,
'weight': 100},
43 {
'category':
'fruit',
'name':
'orange',
'color':
'orange',
'volume': 352,
'weight': 100},
44 {
'category':
'fruit',
'name':
'peach',
'color':
'green',
'volume': 400,
'weight': 100},
45 {
'category':
'fruit',
'name':
'pear',
'color':
'yellow',
'volume': 240,
'weight': 100},
46 {
'category':
'fruit',
'name':
'plum',
'color':
'yellowish',
'volume': 300,
'weight': 100},
47 {
'category':
'fruit',
'name':
'strawberry',
'color':
'red',
'volume': 80,
'weight': 100},
48 {
'category':
'pantry_item',
'name':
'coffee',
'color':
'blue',
'volume': 800,
'weight': 100},
49 {
'category':
'pantry_item',
'name':
'spam',
'color':
'blue',
'volume': 360,
'weight': 100},
50 {
'category':
'pantry_item',
'name':
'sugar',
'color':
'yellow',
'volume': 380,
'weight': 100},
51 {
'category':
'pantry_item',
'name':
'tomato_soup',
'color':
'rood',
'volume': 500,
'weight': 100},
52 {
'category':
'pantry_item',
'name':
'tuna',
'color':
'blue',
'volume': 120,
'weight': 100},
54 {
'category':
'drink',
'name':
'iced_tea',
'color':
'yellow',
'volume': 376,
'weight': 100},
55 {
'category':
'drink',
'name':
'seven_up',
'color':
'green',
'volume': 378,
'weight': 100},
56 {
'category':
'snack',
'name':
'chips',
'color':
'red',
'volume': 1125,
'weight': 100},
57 {
'category':
'snack',
'name':
'chocolate_jello',
'color':
'brown',
'volume': 550,
'weight': 100},
58 {
'category':
'snack',
'name':
'strawberry_jello',
'color':
'red',
'volume': 550,
'weight': 100},
61 {
'category':
'food',
'name':
'mango',
'color':
'red',
'volume': 254,
'weight': 100},
62 {
'category':
'food',
'name':
'cereal',
'color':
'green',
'volume': 1485,
'weight': 100},
63 {
'category':
'food',
'name':
'corn',
'color':
'yellow',
'volume': 240,
'weight': 100},
64 {
'category':
'food',
'name':
'crackers',
'color':
'blueish',
'volume': 300,
'weight': 100},
65 {
'category':
'food',
'name':
'peas',
'color':
'green',
'volume': 239,
'weight': 100},
66 {
'category':
'food',
'name':
'pepper',
'color':
'black',
'volume': 110,
'weight': 100},
67 {
'category':
'food',
'name':
'salt',
'color':
'white',
'volume': 110,
'weight': 100},
68 {
'category':
'container',
'name':
'basket',
'color':
'green',
'volume': 3487,
'weight': 100},
69 {
'category':
'container',
'name':
'bowl',
'color':
'blue',
'volume': 617,
'weight': 100},
70 {
'category':
'container',
'name':
'cup',
'color':
'orangish',
'volume': 427,
'weight': 100},
71 {
'category':
'container',
'name':
'plate',
'color':
'grey',
'volume': 147,
'weight': 100},
72 {
'category':
'drink',
'name':
'beer',
'color':
'brown',
'volume': 388,
'weight': 100},
73 {
'category':
'drink',
'name':
'bifrutas',
'color':
'blue',
'volume': 378,
'weight': 100},
74 {
'category':
'drink',
'name':
'coke',
'color':
'red',
'volume': 376,
'weight': 335},
75 {
'category':
'drink',
'name':
'fanta',
'color':
'orange',
'volume': 376,
'weight': 335},
76 {
'category':
'drink',
'name':
'ice_tea',
'color':
'yellow',
'volume': 376,
'weight': 335},
77 {
'category':
'drink',
'name':
'tea',
'color':
'green',
'volume': 877,
'weight': 100},
78 {
'category':
'drink',
'name':
'water',
'color':
'transparent',
'volume': 400,
'weight': 100},
79 {
'category':
'snack',
'name':
'cookies',
'color':
'brownish',
'volume': 442,
'weight': 100},
80 {
'category':
'snack',
'name':
'mentos',
'color':
'blue',
'volume': 235,
'weight': 100},
81 {
'category':
'snack',
'name':
'pringles',
'color':
'orange',
'volume': 1125,
'weight': 100},
82 {
'category':
'cleaning_stuff',
'name':
'brush',
'color':
'brown',
'volume': 315,
'weight': 100},
83 {
'category':
'cleaning_stuff',
'name':
'cloth',
'color':
'yellow',
'volume': 161,
'weight': 100},
84 {
'category':
'cleaning_stuff',
'name':
'deodorant',
'color':
'pink',
'volume': 314,
'weight': 100},
85 {
'category':
'cleaning_stuff',
'name':
'hair_gel',
'color':
'transparent',
'volume': 238,
'weight': 100},
86 {
'category':
'cleaning_stuff',
'name':
'hairspray',
'color':
'blue',
'volume': 490,
'weight': 100},
87 {
'category':
'cleaning_stuff',
'name':
'sponge',
'color':
'yellow',
'volume': 234,
'weight': 100},
88 {
'category':
'cleaning_stuff',
'name':
'toothpaste',
'color':
'blue',
'volume': 106,
'weight': 100},
89 {
'category':
'cleaning_stuff',
'name':
'towel',
'color':
'pink',
'volume': 243,
'weight': 100},
90 {
'category':
'cutlery',
'name':
'fork',
'color':
'brownish',
'volume': 4,
'weight': 100},
91 {
'category':
'cutlery',
'name':
'spoon',
'color':
'brownish',
'volume': 4,
'weight': 100},
92 {
'category':
'cutlery',
'name':
'knife',
'color':
'brownish',
'volume': 5,
'weight': 100},
93 {
'category':
'cutlery',
'name':
'chopsticks',
'color':
'brownish',
'volume': 20,
'weight': 100}
96 object_names = list(set([ o[
"name"]
for o
in objects ]))
97 object_categories = list(set([ o[
"category"]
for o
in objects ]))
98 object_color = list(set([ o[
"color"]
for o
in objects ]))
99 object_size = list(set([ o[
"volume"]
for o
in objects ]))
100 object_weight = list(set([ o[
"weight"]
for o
in objects ]))
104 category_locations = {
105 "food": {
"closet":
"on_top_of"},
106 "snack": {
"closet":
"on_top_of"},
107 "container": {
"cabinet":
"on_top_of"},
108 "drink": {
"dinner_table":
"on_top_of"},
109 "cleaning_stuff": {
"cabinet":
"on_top_of"},
110 "cutlery": {
"cabinet":
"on_top_of"}
114 "cabinet": [
"shelf1",
"shelf2",
"shelf3",
"shelf4",
"shelf5"],
115 "bookcase": [
"shelf1",
"shelf2",
"shelf3",
"shelf4"]
118 inspect_positions = {
121 default_target_radius = 0.2
125 most_probable_location_in_room_map = {
126 'dining_room':
'dinner_table',
127 'office':
'work_bench2',
128 'living_room':
'salon_table'
133 if room_id
in most_probable_location_in_room_map:
134 return most_probable_location_in_room_map[room_id]
139 return [obj[
'name']
for obj
in objects
if obj[
'category'] == category]
143 drink_spec =
"T['drink': O] -> OPTIONS[O]\n\n"
144 for dn
in drink_names:
145 drink_spec +=
"OPTIONS['{drink}'] -> {drink}\n".format(drink=dn)
147 ''' colors from printing on screen '''
156 UNDERLINE =
'\033[4m'
160 General function for printing shortcuts
161 name: name of the program that instantiates make_prints
162 sentence: sentence to be displayed
164 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
170 prefix = bcolors.HEADER + name + bcolors.ENDC
173 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
176 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
179 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
181 return printOk, printError, printWarning
186 for loc
in locations:
187 if loc[
"name"] == location:
193 for loc
in locations:
194 if loc[
"name"] == location:
200 return entity_id
in location_rooms
204 if location
in inspect_areas:
205 return inspect_areas[location]
211 if location
in inspect_positions
and area
in inspect_positions[location]:
212 return inspect_positions[location][area]
218 for loc
in locations:
219 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
225 for loc
in locations:
226 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
231 def get_locations(room=None, pick_location=None, place_location=None):
232 return [loc[
"name"]
for loc
in locations
233 if (room ==
None or loc[
"room"] == room)
and \
234 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
244 return [obj[
"name"]
for obj
in objects
245 if category ==
None or category == obj[
"category"]]
274 location, area_name = next(iter(category_locations[obj_cat].items()))
275 return location, area_name
280 if __name__ ==
"__main__":
281 print(
"\n-----------------------------------------------------------------------------")
285 print(
"object '{}'".format(obj))
286 print(
" category: '{}'".format(cat))
287 print(
" found '{} {}'".format(area_name, location))
289 print(
"\n-----------------------------------------------------------------------------")
291 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
293 print(
"\n-----------------------------------------------------------------------------")
294 print(
"Pick locations:")
296 print(
" {}".format(loc))
298 print(
"\n-----------------------------------------------------------------------------")
299 print(
"Place locations:")
301 print(
" {}".format(loc))
303 print(
"\n-----------------------------------------------------------------------------")
304 print(
"None-manipulation locations:")
305 for loc
in get_locations(pick_location=
False, place_location=
False):
306 print(
" {}".format(loc))