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':
'couch_table',
'room':
'livingroom',
'category':
'table',
'manipulation':
'yes'},
12 {
'name':
'dinner_table',
'room':
'livingroom',
'category':
'table',
'manipulation':
'yes'},
13 {
'name':
'bookcase',
'room':
'livingroom',
'category':
'shelf',
'manipulation':
'yes'},
14 {
'name':
'panda_table',
'room':
'livingroom',
'category':
'table',
'manipulation':
'yes'},
16 {
'name':
'cabinet',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
17 {
'name':
'trashbin',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
18 {
'name':
'couch',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
20 {
'name':
'workbench',
'room':
'workshop',
'category':
'table',
'manipulation':
'yes'},
22 {
'name':
'hallway_table',
'room':
'hallway',
'category':
'table',
'manipulation':
'yes'},
23 {
'name':
'bar',
'room':
'hallway',
'category':
'table',
'manipulation':
'yes'},
24 {
'name':
'paperbin',
'room':
'hallway',
'category':
'utility',
'manipulation':
'no'}
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" ]))
32 rooms = location_rooms + [
"workshop"]
35 {
'category':
'food',
'name':
'apple',
'color':
'green',
'volume': 301,
'weight': 100},
36 {
'category':
'food',
'name':
'banana',
'color':
'yellow',
'volume': 320,
'weight': 100},
37 {
'category':
'food',
'name':
'mango',
'color':
'red',
'volume': 254,
'weight': 100},
38 {
'category':
'food',
'name':
'orange',
'color':
'orange',
'volume': 352,
'weight': 100},
39 {
'category':
'food',
'name':
'cereal',
'color':
'green',
'volume': 1485,
'weight': 100},
40 {
'category':
'food',
'name':
'corn',
'color':
'yellow',
'volume': 240,
'weight': 100},
41 {
'category':
'food',
'name':
'crackers',
'color':
'blueish',
'volume': 300,
'weight': 100},
42 {
'category':
'food',
'name':
'peas',
'color':
'green',
'volume': 239,
'weight': 100},
43 {
'category':
'food',
'name':
'pepper',
'color':
'black',
'volume': 110,
'weight': 100},
44 {
'category':
'food',
'name':
'salt',
'color':
'white',
'volume': 110,
'weight': 100},
45 {
'category':
'container',
'name':
'basket',
'color':
'green',
'volume': 3487,
'weight': 100},
46 {
'category':
'container',
'name':
'bowl',
'color':
'blue',
'volume': 617,
'weight': 100},
47 {
'category':
'container',
'name':
'cup',
'color':
'orangish',
'volume': 427,
'weight': 100},
48 {
'category':
'container',
'name':
'plate',
'color':
'grey',
'volume': 147,
'weight': 100},
49 {
'category':
'drink',
'name':
'beer',
'color':
'brown',
'volume': 388,
'weight': 100},
50 {
'category':
'drink',
'name':
'bifrutas',
'color':
'blue',
'volume': 378,
'weight': 100},
51 {
'category':
'drink',
'name':
'coke',
'color':
'red',
'volume': 376,
'weight': 335},
52 {
'category':
'drink',
'name':
'fanta',
'color':
'orange',
'volume': 376,
'weight': 335},
53 {
'category':
'drink',
'name':
'ice_tea',
'color':
'yellow',
'volume': 376,
'weight': 335},
54 {
'category':
'drink',
'name':
'tea',
'color':
'green',
'volume': 877,
'weight': 100},
55 {
'category':
'drink',
'name':
'water',
'color':
'transparent',
'volume': 400,
'weight': 100},
56 {
'category':
'snack',
'name':
'cookies',
'color':
'brownish',
'volume': 442,
'weight': 100},
57 {
'category':
'snack',
'name':
'mentos',
'color':
'blue',
'volume': 235,
'weight': 100},
58 {
'category':
'snack',
'name':
'pringles',
'color':
'orange',
'volume': 1125,
'weight': 100},
59 {
'category':
'cleaning_stuff',
'name':
'brush',
'color':
'brown',
'volume': 315,
'weight': 100},
60 {
'category':
'cleaning_stuff',
'name':
'cloth',
'color':
'yellow',
'volume': 161,
'weight': 100},
61 {
'category':
'cleaning_stuff',
'name':
'deodorant',
'color':
'pink',
'volume': 314,
'weight': 100},
62 {
'category':
'cleaning_stuff',
'name':
'hair_gel',
'color':
'transparent',
'volume': 238,
'weight': 100},
63 {
'category':
'cleaning_stuff',
'name':
'hairspray',
'color':
'blue',
'volume': 490,
'weight': 100},
64 {
'category':
'cleaning_stuff',
'name':
'sponge',
'color':
'yellow',
'volume': 234,
'weight': 100},
65 {
'category':
'cleaning_stuff',
'name':
'toothpaste',
'color':
'blue',
'volume': 106,
'weight': 100},
66 {
'category':
'cleaning_stuff',
'name':
'towel',
'color':
'pink',
'volume': 243,
'weight': 100},
67 {
'category':
'cutlery',
'name':
'fork',
'color':
'brownish',
'volume': 4,
'weight': 100},
68 {
'category':
'cutlery',
'name':
'spoon',
'color':
'brownish',
'volume': 4,
'weight': 100},
69 {
'category':
'cutlery',
'name':
'knife',
'color':
'brownish',
'volume': 5,
'weight': 100},
70 {
'category':
'cutlery',
'name':
'chopsticks',
'color':
'brownish',
'volume': 20,
'weight': 100}
73 object_names = list(set([ o[
"name"]
for o
in objects ]))
74 object_categories = list(set([ o[
"category"]
for o
in objects ]))
75 object_color = list(set([ o[
"color"]
for o
in objects ]))
76 object_size = list(set([ o[
"volume"]
for o
in objects ]))
77 object_weight = list(set([ o[
"weight"]
for o
in objects ]))
81 category_locations = {
82 "food": {
"bookcase":
"on_top_of"},
83 "snack": {
"bookcase":
"on_top_of"},
84 "container": {
"flight_case":
"in"},
85 "drink": {
"dinner_table":
"on_top_of"},
86 "cleaning_stuff": {
"cabinet":
"on_top_of"},
87 "cutlery": {
"bar":
"on_top_of"}
91 "bookcase": [
"shelf1",
"shelf2",
"shelf3",
"shelf4",
"shelf5"]
97 default_target_radius = 0.2
101 most_probable_location_in_room_map = {
102 'livingroom':
'dinner_table',
103 'bedroom':
'nightstand',
104 'workshop':
'workbench',
105 'kitchen':
'cabinet',
106 'hallway':
'hallway_table'
111 if room_id
in most_probable_location_in_room_map:
112 return most_probable_location_in_room_map[room_id]
118 return [obj[
'name']
for obj
in objects
if obj[
'category'] == category]
121 drink_spec =
"T['drink': O] -> OPTIONS[O]\n\n"
122 for dn
in drink_names:
123 drink_spec +=
"OPTIONS['{drink}'] -> {drink}\n".format(drink=dn)
125 ''' colors from printing on screen '''
134 UNDERLINE =
'\033[4m'
138 General function for printing shortcuts
139 name: name of the program that instantiates make_prints
140 sentence: sentence to be displayed
142 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
148 prefix = bcolors.HEADER + name + bcolors.ENDC
151 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
154 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
157 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
159 return printOk, printError, printWarning
164 for loc
in locations:
165 if loc[
"name"] == location:
171 for loc
in locations:
172 if loc[
"name"] == location:
178 return (entity_id
in rooms)
182 if location
in inspect_areas:
183 return inspect_areas[location]
189 if location
in inspect_positions
and area
in inspect_positions[location]:
190 return inspect_positions[location][area]
196 for loc
in locations:
197 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
203 for loc
in locations:
204 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
209 def get_locations(room=None, pick_location=None, place_location=None):
210 return [loc[
"name"]
for loc
in locations
211 if (room ==
None or loc[
"room"] == room)
and \
212 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
222 return [obj[
"name"]
for obj
in objects
223 if category ==
None or category == obj[
"category"]]
252 location, area_name = next(iter(category_locations[obj_cat].items()))
253 return location, area_name
258 if __name__ ==
"__main__":
259 print(
"\n-----------------------------------------------------------------------------")
263 print(
"object '{}'".format(obj))
264 print(
" category: '{}'".format(cat))
265 print(
" found '{} {}'".format(area_name, location))
267 print(
"\n-----------------------------------------------------------------------------")
269 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
271 print(
"\n-----------------------------------------------------------------------------")
272 print(
"Pick locations:")
274 print(
" {}".format(loc))
276 print(
"\n-----------------------------------------------------------------------------")
277 print(
"Place locations:")
279 print(
" {}".format(loc))
281 print(
"\n-----------------------------------------------------------------------------")
282 print(
"None-manipulation locations:")
283 for loc
in get_locations(pick_location=
False, place_location=
False):
284 print(
" {}".format(loc))