3 from __future__
import print_function
5 female_names = [
"alex",
"charlie",
"elizabeth",
"francis",
"jennifer",
"linda",
"mary",
"patricia",
"robin",
"skyler"]
6 male_names = [
"alex",
"charlie",
"francis",
"james",
"john",
"michael",
"robert",
"robin",
"skyler",
"william"]
8 names = female_names + male_names
12 {
'name':
'side_table',
'room':
'bedroom',
'category':
'table',
'manipulation':
'yes'},
13 {
'name':
'bed',
'room':
'bedroom',
'category':
'utility',
'manipulation':
'no'},
14 {
'name':
'desk',
'room':
'bedroom',
'category':
'table',
'manipulation':
'yes'},
16 {
'name':
'cupboard',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
17 {
'name':
'storage_table',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes'},
18 {
'name':
'sink',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
19 {
'name':
'dishwasher',
'room':
'kitchen',
'category':
'utility',
'manipulation':
'no'},
20 {
'name':
'counter',
'room':
'kitchen',
'category':
'shelf',
'manipulation':
'yes'},
22 {
'name':
'dining_table',
'room':
'dining_room',
'category':
'table',
'manipulation':
'yes'},
24 {
'name':
'end_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes'},
25 {
'name':
'couch',
'room':
'living_room',
'category':
'utility',
'manipulation':
'no'},
26 {
'name':
'bookcase',
'room':
'living_room',
'category':
'shelf',
'manipulation':
'yes'},
27 {
'name':
'door',
'room':
'corridor',
'category':
'utility',
'manipulation':
'no'},
28 {
'name':
'gpsr_entrance',
'room':
'corridor',
'category':
'utility',
'manipulation':
'no'}
31 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
32 location_categories = list(set([ o[
"category"]
for o
in locations ]))
33 location_names = list(set([ o[
"name"]
for o
in locations ]))
34 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
36 rooms = location_rooms + [
'corridor']
39 {
'category':
'cleaning_stuff',
'name':
'cloth',
'color':
'purple',
'volume': 315,
'weight': 37},
40 {
'category':
'cleaning_stuff',
'name':
'scrubby',
'color':
'yellowish',
'volume': 100,
'weight': 22},
41 {
'category':
'cleaning_stuff',
'name':
'sponge',
'color':
'blue',
'volume': 247,
'weight': 15},
43 {
'category':
'container',
'name':
'basket',
'color':
'beige',
'volume': 3487,
'weight': 43},
44 {
'category':
'container',
'name':
'tray',
'color':
'white',
'volume': 4508,
'weight': 120},
46 {
'category':
'cutlery',
'name':
'fork',
'color':
'green',
'volume': 22,
'weight': 10},
47 {
'category':
'cutlery',
'name':
'knife',
'color':
'green',
'volume': 22,
'weight': 10},
48 {
'category':
'cutlery',
'name':
'spoon',
'color':
'green',
'volume': 23,
'weight': 10},
50 {
'category':
'drink',
'name':
'chocolate_drink',
'color':
'brownish',
'volume': 404,
'weight': 325},
51 {
'category':
'drink',
'name':
'coke',
'color':
'red',
'volume': 270,
'weight': 222},
52 {
'category':
'drink',
'name':
'grape_juice',
'color':
'purplish',
'volume': 216,
'weight': 200},
53 {
'category':
'drink',
'name':
'orange_juice',
'color':
'orange',
'volume': 216,
'weight': 200},
54 {
'category':
'drink',
'name':
'sprite',
'color':
'bluegreen',
'volume': 270,
'weight': 222},
56 {
'category':
'food',
'name':
'cereal',
'color':
'blue',
'volume': 336,
'weight': 21},
57 {
'category':
'food',
'name':
'noodles',
'color':
'yellowish',
'volume': 297,
'weight': 85},
58 {
'category':
'food',
'name':
'sausages',
'color':
'blue',
'volume': 223,
'weight': 113},
60 {
'category':
'fruit',
'name':
'apple',
'color':
'greenred',
'volume': 360,
'weight': 85},
61 {
'category':
'fruit',
'name':
'orange',
'color':
'orange',
'volume': 380,
'weight': 140},
62 {
'category':
'fruit',
'name':
'paprika',
'color':
'red',
'volume': 402,
'weight': 90},
64 {
'category':
'snack',
'name':
'crackers',
'color':
'orange',
'volume': 243,
'weight': 28},
65 {
'category':
'snack',
'name':
'potato_chips',
'color':
'black',
'volume': 4080,
'weight': 200},
66 {
'category':
'snack',
'name':
'pringles',
'color':
'green',
'volume': 1125,
'weight': 156},
68 {
'category':
'tableware',
'name':
'bowl',
'color':
'green',
'volume': 458,
'weight': 65},
69 {
'category':
'tableware',
'name':
'cup',
'color':
'green',
'volume': 300,
'weight': 50},
70 {
'category':
'tableware',
'name':
'dish',
'color':
'green',
'volume': 672,
'weight': 70}
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 "drink": {
"counter":
"on_top_of"},
83 "cleaning_stuff": {
"side_table":
"on_top_of"},
84 "cutlery": {
"storage_table":
"on_top_of"},
85 "snack": {
"bookcase":
"shelf3"},
86 "fruit": {
"bookcase":
"shelf2"},
87 "container": {
"end_table":
"on_top_of"},
88 "food": {
"cupboard":
"shelf2"},
89 "tableware": {
"storage_table":
"on_top_of"}
93 "bookcase": [
"shelf2",
"shelf3",
"shelf4"],
94 "cupboard": [
"shelf3",
"shelf4"]
102 most_probable_location_in_room_map = {
103 'bedroom':
'side_table',
104 'kitchen':
'cupboard',
105 'dining_room':
'dining_table',
106 'living_room':
'end_table'
110 if room_id
in most_probable_location_in_room_map:
111 return most_probable_location_in_room_map[room_id]
116 ''' colors from printing on screen '''
125 UNDERLINE =
'\033[4m'
129 General function for printing shortcuts
130 name: name of the program that instantiates make_prints
131 sentence: sentence to be displayed
133 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
138 prefix = bcolors.HEADER + name + bcolors.ENDC
141 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
144 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
147 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
149 return printOk, printError, printWarning
154 for loc
in locations:
155 if loc[
"name"] == location:
161 for loc
in locations:
162 if loc[
"name"] == location:
168 return (entity_id
in rooms)
172 if location
in inspect_areas:
173 return inspect_areas[location]
179 if location
in inspect_positions
and area
in inspect_positions[location]:
180 return inspect_positions[location][area]
186 for loc
in locations:
187 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
193 for loc
in locations:
194 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
199 def get_locations(room=None, pick_location=None, place_location=None):
200 return [loc[
"name"]
for loc
in locations
201 if (room ==
None or loc[
"room"] == room)
and \
202 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
207 return [obj[
"name"]
for obj
in objects
208 if category ==
None or category == obj[
"category"]]
237 location, area_name = next(iter(category_locations[obj_cat].items()))
238 return location, area_name
243 if __name__ ==
"__main__":
244 print(
"\n-----------------------------------------------------------------------------")
248 print(
"object '{}'".format(obj))
249 print(
" category: '{}'".format(cat))
250 print(
" found '{} {}'".format(area_name, location))
252 print(
"\n-----------------------------------------------------------------------------")
254 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
256 print(
"\n-----------------------------------------------------------------------------")
257 print(
"Pick locations:")
259 print(
" {}".format(loc))
261 print(
"\n-----------------------------------------------------------------------------")
262 print(
"Place locations:")
264 print(
" {}".format(loc))
266 print(
"\n-----------------------------------------------------------------------------")
267 print(
"None-manipulation locations:")
268 for loc
in get_locations(pick_location=
False, place_location=
False):
269 print(
" {}".format(loc))