2 from __future__
import print_function
4 female_names = [
"anna",
"beth",
"carmen",
"jennifer",
"jessica",
"kimberly",
"kristina",
"laura",
"mary",
"sarah"]
5 male_names = [
"alfred",
"charles",
"daniel",
"james",
"john",
"luis",
"paul",
"richard",
"robert",
"steve"]
7 names = female_names + male_names
11 {
'name':
'dinner_table',
'room':
'dining_room',
'category':
'table',
'manipulation':
'yes'},
12 {
'name':
'cabinet',
'room':
'dining_room',
'category':
'shelf',
'manipulation':
'yes'},
13 {
'name':
'bookcase',
'room':
'dining_room',
'category':
'shelf',
'manipulation':
'yes'},
15 {
'name':
'kitchen_cabinet',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
16 {
'name':
'fridge',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
18 {
'name':
'salon_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
19 {
'name':
'couch_long',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
20 {
'name':
'couch_short',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
22 {
'name':
'work_bench1',
'room':
'office',
'category':
'table',
'manipulation':
'yes'},
23 {
'name':
'work_bench2',
'room':
'office',
'category':
'table',
'manipulation':
'yes'},
24 {
'name':
'closet',
'room':
'office',
'category':
'shelf',
'manipulation':
'yes'},
27 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
28 location_categories = list(set([ o[
"category"]
for o
in locations ]))
29 location_names = list(set([ o[
"name"]
for o
in locations ]))
30 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
33 {
'category':
'food',
'name':
'apple',
'color':
'green',
'volume': 301,
'weight': 100},
34 {
'category':
'food',
'name':
'banana',
'color':
'yellow',
'volume': 320,
'weight': 100},
35 {
'category':
'food',
'name':
'mango',
'color':
'red',
'volume': 254,
'weight': 100},
36 {
'category':
'food',
'name':
'orange',
'color':
'orange',
'volume': 352,
'weight': 100},
37 {
'category':
'food',
'name':
'cereal',
'color':
'green',
'volume': 1485,
'weight': 100},
38 {
'category':
'food',
'name':
'corn',
'color':
'yellow',
'volume': 240,
'weight': 100},
39 {
'category':
'food',
'name':
'crackers',
'color':
'blueish',
'volume': 300,
'weight': 100},
40 {
'category':
'food',
'name':
'peas',
'color':
'green',
'volume': 239,
'weight': 100},
41 {
'category':
'food',
'name':
'pepper',
'color':
'black',
'volume': 110,
'weight': 100},
42 {
'category':
'food',
'name':
'salt',
'color':
'white',
'volume': 110,
'weight': 100},
43 {
'category':
'container',
'name':
'basket',
'color':
'green',
'volume': 3487,
'weight': 100},
44 {
'category':
'container',
'name':
'bowl',
'color':
'blue',
'volume': 617,
'weight': 100},
45 {
'category':
'container',
'name':
'cup',
'color':
'orangish',
'volume': 427,
'weight': 100},
46 {
'category':
'container',
'name':
'plate',
'color':
'grey',
'volume': 147,
'weight': 100},
47 {
'category':
'drink',
'name':
'beer',
'color':
'brown',
'volume': 388,
'weight': 100},
48 {
'category':
'drink',
'name':
'bifrutas',
'color':
'blue',
'volume': 378,
'weight': 100},
49 {
'category':
'drink',
'name':
'coke',
'color':
'red',
'volume': 376,
'weight': 335},
50 {
'category':
'drink',
'name':
'fanta',
'color':
'orange',
'volume': 376,
'weight': 335},
51 {
'category':
'drink',
'name':
'ice_tea',
'color':
'yellow',
'volume': 376,
'weight': 335},
52 {
'category':
'drink',
'name':
'tea',
'color':
'green',
'volume': 877,
'weight': 100},
53 {
'category':
'drink',
'name':
'water',
'color':
'transparent',
'volume': 400,
'weight': 100},
54 {
'category':
'snack',
'name':
'cookies',
'color':
'brownish',
'volume': 442,
'weight': 100},
55 {
'category':
'snack',
'name':
'mentos',
'color':
'blue',
'volume': 235,
'weight': 100},
56 {
'category':
'snack',
'name':
'pringles',
'color':
'orange',
'volume': 1125,
'weight': 100},
57 {
'category':
'cleaning_stuff',
'name':
'brush',
'color':
'brown',
'volume': 315,
'weight': 100},
58 {
'category':
'cleaning_stuff',
'name':
'cloth',
'color':
'yellow',
'volume': 161,
'weight': 100},
59 {
'category':
'cleaning_stuff',
'name':
'deodorant',
'color':
'pink',
'volume': 314,
'weight': 100},
60 {
'category':
'cleaning_stuff',
'name':
'hair_gel',
'color':
'transparent',
'volume': 238,
'weight': 100},
61 {
'category':
'cleaning_stuff',
'name':
'hairspray',
'color':
'blue',
'volume': 490,
'weight': 100},
62 {
'category':
'cleaning_stuff',
'name':
'sponge',
'color':
'yellow',
'volume': 234,
'weight': 100},
63 {
'category':
'cleaning_stuff',
'name':
'toothpaste',
'color':
'blue',
'volume': 106,
'weight': 100},
64 {
'category':
'cleaning_stuff',
'name':
'towel',
'color':
'pink',
'volume': 243,
'weight': 100},
65 {
'category':
'cutlery',
'name':
'fork',
'color':
'brownish',
'volume': 4,
'weight': 100},
66 {
'category':
'cutlery',
'name':
'spoon',
'color':
'brownish',
'volume': 4,
'weight': 100},
67 {
'category':
'cutlery',
'name':
'knife',
'color':
'brownish',
'volume': 5,
'weight': 100},
68 {
'category':
'cutlery',
'name':
'chopsticks',
'color':
'brownish',
'volume': 20,
'weight': 100}
71 object_names = list(set([ o[
"name"]
for o
in objects ]))
72 object_categories = list(set([ o[
"category"]
for o
in objects ]))
73 object_color = list(set([ o[
"color"]
for o
in objects ]))
74 object_size = list(set([ o[
"volume"]
for o
in objects ]))
75 object_weight = list(set([ o[
"weight"]
for o
in objects ]))
79 category_locations = {
80 "food": {
"closet":
"on_top_of"},
81 "snack": {
"closet":
"on_top_of"},
82 "container": {
"cabinet":
"on_top_of"},
83 "drink": {
"dinner_table":
"on_top_of"},
84 "cleaning_stuff": {
"cabinet":
"on_top_of"},
85 "cutlery": {
"cabinet":
"on_top_of"}
89 "closet": [
"shelf1",
"shelf2",
"shelf3",
"shelf4",
"shelf5"]
95 default_target_radius = 0.2
99 most_probable_location_in_room_map = {
100 'dining_room':
'dinner_table',
101 'office':
'work_bench2',
102 'living_room':
'salon_table'
107 if room_id
in most_probable_location_in_room_map:
108 return most_probable_location_in_room_map[room_id]
113 return [obj[
'name']
for obj
in objects
if obj[
'category'] == category]
117 drink_spec =
"T['drink': O] -> OPTIONS[O]\n\n"
118 for dn
in drink_names:
119 drink_spec +=
"OPTIONS['{drink}'] -> {drink}\n".format(drink=dn)
121 ''' colors from printing on screen '''
130 UNDERLINE =
'\033[4m'
134 General function for printing shortcuts
135 name: name of the program that instantiates make_prints
136 sentence: sentence to be displayed
138 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
144 prefix = bcolors.HEADER + name + bcolors.ENDC
147 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
150 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
153 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
155 return printOk, printError, printWarning
160 for loc
in locations:
161 if loc[
"name"] == location:
167 for loc
in locations:
168 if loc[
"name"] == location:
174 return entity_id
in location_rooms
178 if location
in inspect_areas:
179 return inspect_areas[location]
185 if location
in inspect_positions
and area
in inspect_positions[location]:
186 return inspect_positions[location][area]
192 for loc
in locations:
193 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
199 for loc
in locations:
200 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
205 def get_locations(room=None, pick_location=None, place_location=None):
206 return [loc[
"name"]
for loc
in locations
207 if (room ==
None or loc[
"room"] == room)
and \
208 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
218 return [obj[
"name"]
for obj
in objects
219 if category ==
None or category == obj[
"category"]]
248 location, area_name = next(iter(category_locations[obj_cat].items()))
249 return location, area_name
254 if __name__ ==
"__main__":
255 print(
"\n-----------------------------------------------------------------------------")
259 print(
"object '{}'".format(obj))
260 print(
" category: '{}'".format(cat))
261 print(
" found '{} {}'".format(area_name, location))
263 print(
"\n-----------------------------------------------------------------------------")
265 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
267 print(
"\n-----------------------------------------------------------------------------")
268 print(
"Pick locations:")
270 print(
" {}".format(loc))
272 print(
"\n-----------------------------------------------------------------------------")
273 print(
"Place locations:")
275 print(
" {}".format(loc))
277 print(
"\n-----------------------------------------------------------------------------")
278 print(
"None-manipulation locations:")
279 for loc
in get_locations(pick_location=
False, place_location=
False):
280 print(
" {}".format(loc))