3 from __future__
import print_function
5 female_names = [
"emma",
"olivia",
"sophia",
"ava",
"isabella",
"mia",
"abigail",
"emily",
"charlotte",
"harper"]
6 male_names = [
"noah",
"liam",
"mason",
"jacob",
"william",
"ethan",
"james",
"alexander",
"michael",
"benjamin"]
7 names = female_names + male_names
11 {
'name':
'bookshelf',
'room':
'living_room',
'category':
'shelf',
'manipulation':
'yes' },
12 {
'name':
'sofa',
'room':
'living_room',
'category':
'seat',
'manipulation':
'no' },
13 {
'name':
'couch_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes' },
14 {
'name':
'side_table',
'room':
'living_room',
'category':
'table',
'manipulation':
'yes' },
15 {
'name':
'tv_stand',
'room':
'living_room',
'category':
'beacon',
'manipulation':
'no' },
17 {
'name':
'kitchencounter',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes' },
18 {
'name':
'stove',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes' },
19 {
'name':
'desk',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes' },
20 {
'name':
'bar',
'room':
'kitchen',
'category':
'table',
'manipulation':
'yes' },
22 {
'name':
'bed',
'room':
'bedroom',
'category':
'seat',
'manipulation':
'no' },
23 {
'name':
'closet',
'room':
'bedroom',
'category':
'shelf',
'manipulation':
'yes' },
25 {
'name':
'dinner_table',
'room':
'dining_room',
'category':
'table',
'manipulation':
'yes' },
26 {
'name':
'cabinet',
'room':
'dining_room',
'category':
'shelf',
'manipulation':
'yes' }
30 location_rooms = list(set([ o[
"room"]
for o
in locations ]))
31 location_categories = list(set([ o[
"category"]
for o
in locations ]))
32 location_names = list(set([ o[
"name"]
for o
in locations ]))
33 manipulation_locations = list(set([ o[
"name"]
for o
in locations
if o[
"manipulation"] ==
"yes" ]))
36 most_probable_location_in_room_map = {
37 'dining_room':
'dinner_table',
39 'living_room':
'couch_table',
45 if room_id
in most_probable_location_in_room_map:
46 return most_probable_location_in_room_map[room_id]
52 {
'category':
'food',
'name':
'apple' },
53 {
'category':
'food',
'name':
'bread' },
54 {
'category':
'food',
'name':
'cereals' },
55 {
'category':
'food',
'name':
'cornflakes' },
56 {
'category':
'food',
'name':
'crackers' },
57 {
'category':
'food',
'name':
'lemon' },
58 {
'category':
'food',
'name':
'noodles' },
59 {
'category':
'food',
'name':
'paprika' },
60 {
'category':
'food',
'name':
'peas' },
61 {
'category':
'food',
'name':
'pepper' },
62 {
'category':
'food',
'name':
'potato' },
63 {
'category':
'food',
'name':
'potato_soup' },
64 {
'category':
'food',
'name':
'salt' },
65 {
'category':
'food',
'name':
'tomato_pasta' },
66 {
'category':
'container',
'name':
'bag' },
67 {
'category':
'container',
'name':
'basket' },
68 {
'category':
'container',
'name':
'coffecup' },
69 {
'category':
'container',
'name':
'plate' },
70 {
'category':
'container',
'name':
'red_bowl' },
71 {
'category':
'container',
'name':
'white_bowl' },
72 {
'category':
'drink',
'name':
'banana_milk' },
73 {
'category':
'drink',
'name':
'cappucino' },
74 {
'category':
'drink',
'name':
'coke' },
75 {
'category':
'drink',
'name':
'orange_drink' },
76 {
'category':
'drink',
'name':
'water' },
77 {
'category':
'snack',
'name':
'chocolate_cookies' },
78 {
'category':
'snack',
'name':
'egg' },
79 {
'category':
'snack',
'name':
'party_cracker' },
80 {
'category':
'snack',
'name':
'pringles' },
81 {
'category':
'cleaning_stuff',
'name':
'cloth' },
82 {
'category':
'cleaning_stuff',
'name':
'paper' },
83 {
'category':
'cleaning_stuff',
'name':
'sponge' },
84 {
'category':
'cleaning_stuff',
'name':
'towel' },
85 {
'category':
'cutlery',
'name':
'fork' },
86 {
'category':
'cutlery',
'name':
'spoon' },
87 {
'category':
'cutlery',
'name':
'knife' }
91 object_names = list(set([ o[
"name"]
for o
in objects ]))
92 object_categories = list(set([ o[
"category"]
for o
in objects ]))
96 category_locations = {
98 "cutlery": {
"cabinet":
"shelf2"},
99 "container": {
"bookshelf":
"shelf1"},
100 "drink": {
"kitchencounter":
"on_top_of"},
101 "snack": {
"couch_table":
"on_top_of"},
102 "food": {
"stove":
"on_top_of"},
103 "cleaning_stuff": {
"closet":
"on_top_of"},
104 "fruit": {
"desk":
"on_top_of"}
108 "cabinet": [
"shelf1",
"shelf2",
"shelf3",
"shelf4"],
109 "bookshelf": [
"shelf1",
"shelf2",
"shelf3",
"shelf4"]
112 inspect_positions = {
119 ''' colors from printing on screen '''
127 UNDERLINE =
'\033[4m'
131 General function for printing shortcuts
132 name: name of the progam that instanciates make_prints
133 sentence: sentence to be displayed
135 Ex: "[<EXECUTIVE NAME>] <SENTENCE TO BE DISPLAYED>"
141 prefix = bcolors.HEADER + name + bcolors.ENDC
143 print(prefix + bcolors.OKBLUE + sentence + bcolors.ENDC)
146 print(prefix + bcolors.FAIL + sentence + bcolors.ENDC)
149 print(prefix + bcolors.WARNING + sentence + bcolors.ENDC)
151 return printOk, printError, printWarning
157 for loc
in locations:
158 if loc[
"name"] == location:
164 if location
in location_rooms:
166 for loc
in locations:
167 if loc[
"name"] == location:
173 if location
in inspect_areas:
174 return inspect_areas[location]
180 if location
in inspect_positions
and area
in inspect_positions[location]:
181 return inspect_positions[location][area]
187 for loc
in locations:
188 if loc[
"name"] == location
and loc[
"manipulation"] ==
"yes":
194 for loc
in locations:
195 if loc[
"name"] == location
and (loc[
"manipulation"] ==
"yes" or loc[
"manipulation"] ==
"only_putting"):
200 def get_locations(room=None, pick_location=None, place_location=None):
201 return [loc[
"name"]
for loc
in locations
202 if (room ==
None or loc[
"room"] == room)
and \
203 (pick_location ==
None or pick_location ==
is_pick_location(loc[
"name"]))
and \
208 return [obj[
"name"]
for obj
in objects
209 if category ==
None or category == obj[
"category"]]
221 location, area_name = next(iter(category_locations[obj_cat].items()))
222 return location, area_name
227 if __name__ ==
"__main__":
228 print(
"\n-----------------------------------------------------------------------------")
232 print(
"object '{}'".format(obj))
233 print(
" category: '{}'".format(cat))
234 print(
" found '{} {}'".format(area_name, location))
236 print(
"\n-----------------------------------------------------------------------------")
238 print(
"location '{}', room: '{}'".format(loc,
get_room(loc)))
240 print(
"\n-----------------------------------------------------------------------------")
241 print(
"Pick locations:")
243 print(
" {}".format(loc))
245 print(
"\n-----------------------------------------------------------------------------")
246 print(
"Place locations:")
248 print(
" {}".format(loc))
250 print(
"\n-----------------------------------------------------------------------------")
251 print(
"None-manipulation locations:")
252 for loc
in get_locations(pick_location=
False, place_location=
False):
253 print(
" {}".format(loc))