Skip to content

Commit 154218e

Browse files
author
cobot
committed
retain implementable actions
1 parent 6668383 commit 154218e

6 files changed

Lines changed: 4 additions & 283 deletions

File tree

code_generation/openai_chat_completion_prefix.py

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
say(message)
1414
pick(object)
1515
place(object)
16-
pick_up(object)
17-
put_down(object, destination)
18-
put_into_basket(object)
19-
retrieve_from_basket(object)
20-
get_reachable_locations_around_object(object)
2116
2217
Robot tasks are defined in named functions, with docstrings describing the task.
2318
\"\"\"
@@ -52,26 +47,6 @@ def pick(obj: str) -> None:
5247
# Place an object down if you are holding one.
5348
def place(obj: str) -> None:
5449
...
55-
56-
# Pick up an object if you are not already holding one. You can only hold one object at a time.
57-
def pick_up(obj: str) -> None:
58-
...
59-
60-
# Put down an object at the specified destination location, if you are holding one.
61-
def put_down(obj: str, dest: str) -> None:
62-
...
63-
64-
# Put an object that you are holding into the basket
65-
def put_into_basket(obj: str) -> None:
66-
...
67-
68-
# Retrieve an object from the basket
69-
def retrieve_from_basket(obj: str) -> None:
70-
...
71-
72-
# Get a list of all locations from which the specified object can be reached
73-
def get_reachable_locations_around_object(obj: str) -> None:
74-
...
7550
"""
7651
},
7752

@@ -158,7 +133,7 @@ def task_program():
158133

159134
{
160135
"role": "user",
161-
"content": "Go to the kitchen and wait for someone to show up. When someone shows up, ask them to place the diet coke from the fridge in your basket, and bring it here"
136+
"content": "Go to the kitchen and wait for someone to show up. When someone shows up, ask them to bring the diet coke from the fridge here"
162137
},
163138
{
164139
"role": "assistant",
@@ -168,55 +143,11 @@ def task_program():
168143
go_to("kitchen")
169144
while True:
170145
if is_in_room("person"):
171-
response = ask("", "Could you please place the diet coke from the fridge in my basket?", ["Yes", "No"])
146+
response = ask("", "Could you please bring the diet coke from the fridge here?", ["Yes", "No"])
172147
if response == "Yes":
173148
break
174149
time.sleep(1)
175150
go_to(start_loc)
176151
"""
177152
},
178-
179-
{
180-
"role": "user",
181-
"content": "Go to the table next to the sofa and pick up the mug, and then bring it to the kitchen sink."
182-
},
183-
{
184-
"role": "assistant",
185-
"content": """
186-
def task_program():
187-
start_loc = get_current_location()
188-
go_to("table next to sofa")
189-
list_of_locations = get_reachable_locations_around_object("mug")
190-
go_to(list_of_locations[0])
191-
pick_up("mug")
192-
go_to("kitchen sink")
193-
put_down("mug", "kitchen sink")
194-
"""
195-
},
196-
197-
{
198-
"role": "user",
199-
"content": "Collect all the soda cans around the kitchen, put them in your basket, and then put them into the trashcan"
200-
},
201-
{
202-
"role": "assistant",
203-
"content": """
204-
def task_program():
205-
start_loc = get_current_location()
206-
list_of_locations = get_reachable_locations_around_object("soda can")
207-
number_of_soda_cans = 0
208-
while len(list_of_locations) > 0:
209-
go_to(list_of_locations[0])
210-
pick_up("soda can")
211-
put_into_basket("soda can")
212-
list_of_locations = get_reachable_locations_around_object("soda can")
213-
number_of_soda_cans = number_of_soda_cans + 1
214-
215-
go_to("trashcan")
216-
for n in range(number_of_soda_cans):
217-
retrieve_from_basket("soda can")
218-
put_down("soda can", "trashcan")
219-
"""
220-
},
221-
222153
]

code_generation/openai_chat_completion_prefix_minimal.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
say(message)
1414
pick(object)
1515
place(object)
16-
pick_up(object)
17-
put_down(object, destination)
18-
put_into_basket(object)
19-
retrieve_from_basket(object)
20-
get_reachable_locations_around_object(object)
2116
2217
Robot tasks are defined in named functions, with docstrings describing the task.
2318
\"\"\"

code_generation/prompt_prefix.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
say(message)
1010
pick(object)
1111
place(object)
12-
pick_up(object)
13-
put_down(object, destination)
14-
put_into_basket(object)
15-
retrieve_from_basket(object)
16-
get_reachable_locations_around_object(object)
1712
1813
Robot tasks are defined in named functions, with docstrings describing the task.
1914
"""
@@ -49,26 +44,6 @@ def pick(obj: str) -> None:
4944
# Place an object down if you are holding one.
5045
def place(obj: str) -> None:
5146
...
52-
53-
# Pick up an object if you are not already holding one. You can only hold one object at a time.
54-
def pick_up(obj: str) -> None:
55-
...
56-
57-
# Put down an object at the specified destination location, if you are holding one.
58-
def put_down(obj: str, dest: str) -> None:
59-
...
60-
61-
# Put an object that you are holding into the basket
62-
def put_into_basket(obj: str) -> None:
63-
...
64-
65-
# Retrieve an object from the basket
66-
def retrieve_from_basket(obj: str) -> None:
67-
...
68-
69-
# Get a list of all locations from which the specified object can be reached
70-
def get_reachable_locations_around_object(obj: str) -> None:
71-
...
7247

7348
# Go to Arjun's office, ask him if he is ready to head out, and come back and tell me what he said
7449
def task_program():
@@ -155,32 +130,3 @@ def task_program():
155130
go_to(room)
156131
place("bed sheet")
157132
go_to(start_loc)
158-
159-
# Go to the table next to the sofa and pick up the mug, and then bring it to the kitchen sink.
160-
def task_program():
161-
start_loc = get_current_location()
162-
go_to("table next to sofa")
163-
list_of_locations = get_reachable_locations_around_object("mug")
164-
go_to(list_of_locations[0])
165-
pick_up("mug")
166-
go_to("kitchen sink")
167-
put_down("mug", "kitchen sink")
168-
169-
# Collect all the soda cans around the kitchen, put them in your basket, and then put them into the trashcan
170-
def task_program():
171-
start_loc = get_current_location()
172-
list_of_locations = get_reachable_locations_around_object("soda can")
173-
number_of_soda_cans = 0
174-
while len(list_of_locations) > 0:
175-
go_to(list_of_locations[0])
176-
pick_up("soda can")
177-
put_into_basket("soda can")
178-
list_of_locations = get_reachable_locations_around_object("soda can")
179-
number_of_soda_cans = number_of_soda_cans + 1
180-
181-
go_to("trashcan")
182-
for n in range(number_of_soda_cans):
183-
retrieve_from_basket("soda can")
184-
put_down("soda can", "trashcan")
185-
186-
#

code_generation/prompt_prefix_minimal.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
say(message)
1010
pick(object)
1111
place(object)
12-
pick_up(object)
13-
put_down(object, destination)
14-
put_into_basket(object)
15-
retrieve_from_basket(object)
16-
get_reachable_locations_around_object(object)
1712
1813
Robot tasks are defined in named functions, with docstrings describing the task.
1914
"""
@@ -49,26 +44,6 @@ def pick(obj: str) -> None:
4944
# Place an object down if you are holding one.
5045
def place(obj: str) -> None:
5146
...
52-
53-
# Pick up an object if you are not already holding one. You can only hold one object at a time.
54-
def pick_up(obj: str) -> None:
55-
...
56-
57-
# Put down an object at the specified destination location, if you are holding one.
58-
def put_down(obj: str, dest: str) -> None:
59-
...
60-
61-
# Put an object that you are holding into the basket
62-
def put_into_basket(obj: str) -> None:
63-
...
64-
65-
# Retrieve an object from the basket
66-
def retrieve_from_basket(obj: str) -> None:
67-
...
68-
69-
# Get a list of all locations from which the specified object can be reached
70-
def get_reachable_locations_around_object(obj: str) -> None:
71-
...
7247

7348
# Go to Arjun's office, ask him if he is ready to head out, and come back and tell me what he said
7449
def task_program():

robot_interface/src/robot_client_interface.py

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
Ask,
1818
Pick,
1919
Place,
20-
PickUp,
21-
PutDown,
22-
PutIntoBasket,
23-
RetrieveFromBasket,
24-
GetReachableLocationsAroundObject,
2520
)
2621

2722

@@ -42,11 +37,6 @@ def __init__(self):
4237
self.ask_client = ActionClient(self, Ask, "/ask_server")
4338
self.pick_client = ActionClient(self, Pick, "/pick_server")
4439
self.place_client = ActionClient(self, Place, "/place_server")
45-
self.pick_up_client = ActionClient(self, PickUp, "/pick_up_server")
46-
self.put_down_client = ActionClient(self, PutDown, "/put_down_server")
47-
self.put_into_basket_client = ActionClient(self, PutIntoBasket, "/put_into_basket_server")
48-
self.retrieve_from_basket_client = ActionClient(self, RetrieveFromBasket, "/retrieve_from_basket_server")
49-
self.get_reachable_locations_around_object_client = ActionClient(self, GetReachableLocationsAroundObject, "/get_reachable_locations_around_object_server")
5040

5141
print("====== Waiting for robot action servers... ======")
5242
self.go_to_client.wait_for_server()
@@ -57,11 +47,7 @@ def __init__(self):
5747
self.ask_client.wait_for_server()
5848
self.pick_client.wait_for_server()
5949
self.place_client.wait_for_server()
60-
self.pick_up_client.wait_for_server()
61-
self.put_down_client.wait_for_server()
62-
self.put_into_basket_client.wait_for_server()
63-
self.retrieve_from_basket_client.wait_for_server()
64-
self.get_reachable_locations_around_object_client.wait_for_server()
50+
6551
print("======= Connected to robot action servers =======")
6652

6753
def _handle_client(self, client, goal, action_name):
@@ -127,38 +113,11 @@ def pick(self, obj: str) -> None:
127113
self._handle_client(self.pick_client, goal, "pick")
128114

129115
# Place an object in the current room. Make sure you are in the same room as the
130-
# object before calling this function and is currently holding an object.
116+
# object before calling this function and are currently holding an object.
131117
def place(self, obj: str) -> None:
132118
goal = Place.Goal(obj=obj)
133119
self._handle_client(self.place_client, goal, "place")
134120

135-
# Pick up an object from the environment. Make sure you can reach the object from your
136-
# current location first.
137-
def pick_up(self, obj: str) -> None:
138-
goal = PickUp.Goal(obj=obj)
139-
self._handle_client(self.pick_up_client, goal, "pick_up")
140-
141-
# Pick up an object from the environment. Make sure you can reach the object from your
142-
# current location first.
143-
def put_down(self, obj: str, dest: str) -> None:
144-
goal = PutDown.Goal(obj=obj, location=dest)
145-
self._handle_client(self.put_down_client, goal, "put_down")
146-
147-
# Place an already held object into the basket
148-
def put_into_basket(self, obj: str) -> None:
149-
goal = PutIntoBasket.Goal(obj=obj)
150-
self._handle_client(self.put_into_basket_client, goal, "put_into_basket")
151-
152-
# Retrieve an item that is in the basket from the basket, and make sure you are holding it
153-
def retrieve_from_basket(self, obj: str) -> None:
154-
goal = RetrieveFromBasket.Goal(obj=obj)
155-
self._handle_client(self.retrieve_from_basket_client, goal, "retrieve_from_basket")
156-
157-
# Given an object, returns the list of locations within a certain location around the object
158-
def get_reachable_locations_around_object(self, obj: str) -> List[str]:
159-
goal = GetReachableLocationsAroundObject.Goal(obj=obj)
160-
return self._handle_client(self.get_reachable_locations_around_object_client, goal, "get_reachable_locations_around_object").locations
161-
162121
def _cancel_goals(self):
163122
# Cancel all pending goals
164123
self.go_to_client.cancel_all_goals()
@@ -169,11 +128,6 @@ def _cancel_goals(self):
169128
self.ask_client.cancel_all_goals()
170129
self.pick_client.cancel_all_goals()
171130
self.place_client.cancel_all_goals()
172-
self.pick_up_client.cancel_all_goals()
173-
self.put_down_client.cancel_all_goals()
174-
self.put_into_basket_client.cancel_all_goals()
175-
self.retrieve_from_basket_client.cancel_all_goals()
176-
self.get_reachable_locations_around_object_client.cancel_all_goals()
177131

178132

179133
def execute_task_program(program: str, robot: RobotInterface):
@@ -190,11 +144,6 @@ def execute_task_program(program: str, robot: RobotInterface):
190144
"place": robot.place,
191145
"get_all_rooms": robot.get_all_rooms,
192146
"get_current_location": robot.get_current_location,
193-
"pick_up": robot.pick_up,
194-
"put_down": robot.put_down,
195-
"put_into_basket": robot.put_into_basket,
196-
"retrieve_from_basket": robot.retrieve_from_basket,
197-
"get_reachable_locations_around_object": robot.get_reachable_locations_around_object,
198147
"time": time,
199148
}
200149
program_with_call = program + "\n\ntask_program()\n"

0 commit comments

Comments
 (0)