Skip to content

Commit 26cf4e8

Browse files
committed
sort of works
1 parent 547591b commit 26cf4e8

32 files changed

Lines changed: 2629 additions & 29 deletions

2402.15025v2.pdf

10.4 MB
Binary file not shown.

learned_operators.txt

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
#######
2+
backward-forward
3+
lis_thesis_pickplace
4+
#######
5+
NSRT-move0:
6+
Parameters: [?x0:object]
7+
Preconditions: []
8+
Add Effects: [infront2(?x0:object)]
9+
Delete Effects: []
10+
Ignore Effects: []
11+
Option Spec: move(?x0:object)
12+
NSRT-move1:
13+
Parameters: [?x0:object]
14+
Preconditions: [IsNotHolding0(?x0:object)]
15+
Add Effects: [infront0(?x0:object)]
16+
Delete Effects: []
17+
Ignore Effects: [infront0, infront2]
18+
Option Spec: move(?x0:object)
19+
NSRT-pick0:
20+
Parameters: [?x0:ball]
21+
Preconditions: [infront0(?x0:ball)]
22+
Add Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
23+
Delete Effects: [IsNotHolding0(?x0:ball)]
24+
Ignore Effects: []
25+
Option Spec: pick(?x0:ball)
26+
NSRT-place_on0:
27+
Parameters: [?x0:ball, ?x1:table]
28+
Preconditions: [holding0(?x0:ball)]
29+
Add Effects: [OnTable(?x0:ball, ?x1:table)]
30+
Delete Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
31+
Ignore Effects: []
32+
Option Spec: place_on(?x0:ball, ?x1:table)
33+
34+
#######
35+
pnad_search
36+
lis_thesis_pickplace
37+
#######
38+
NSRT-move0:
39+
Parameters: [?x0:object]
40+
Preconditions: []
41+
Add Effects: [infront2(?x0:object)]
42+
Delete Effects: []
43+
Ignore Effects: []
44+
Option Spec: move(?x0:object)
45+
NSRT-move1:
46+
Parameters: [?x0:object]
47+
Preconditions: [IsNotHolding0(?x0:object)]
48+
Add Effects: [infront0(?x0:object)]
49+
Delete Effects: []
50+
Ignore Effects: [infront0, infront2]
51+
Option Spec: move(?x0:object)
52+
NSRT-pick0:
53+
Parameters: [?x0:ball]
54+
Preconditions: [IsNotHolding0(?x0:ball), infront0(?x0:ball)]
55+
Add Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
56+
Delete Effects: [IsNotHolding0(?x0:ball)]
57+
Ignore Effects: []
58+
Option Spec: pick(?x0:ball)
59+
NSRT-place_on0:
60+
Parameters: [?x0:ball, ?x1:table]
61+
Preconditions: [IsPickedUp0(?x0:ball), holding0(?x0:ball), infront0(?x0:ball), infront2(?x1:table)]
62+
Add Effects: [OnTable(?x0:ball, ?x1:table)]
63+
Delete Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
64+
Ignore Effects: []
65+
Option Spec: place_on(?x0:ball, ?x1:table)
66+
67+
#######
68+
cluster_and_intersect
69+
lis_thesis_pickplace
70+
#######
71+
NSRT-Op0:
72+
Parameters: [?x0:ball, ?x1:robot, ?x2:ball, ?x3:table]
73+
Preconditions: [IsNotHolding0(?x0:ball), IsNotHolding0(?x2:ball), infront0(?x0:ball), infront0(?x2:ball), infront2(?x3:table)]
74+
Add Effects: [IsClearOfObjects0(?x1:robot), IsStationary0(?x1:robot)]
75+
Delete Effects: [infront0(?x0:ball), infront2(?x3:table)]
76+
Ignore Effects: []
77+
Option Spec: move(?x2:ball)
78+
NSRT-Op1:
79+
Parameters: [?x0:ball, ?x1:table]
80+
Preconditions: [IsNotHolding0(?x0:ball), infront0(?x0:ball)]
81+
Add Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball), infront2(?x1:table)]
82+
Delete Effects: [IsNotHolding0(?x0:ball)]
83+
Ignore Effects: []
84+
Option Spec: pick(?x0:ball)
85+
NSRT-Op2:
86+
Parameters: [?x0:table]
87+
Preconditions: [infront2(?x0:table)]
88+
Add Effects: []
89+
Delete Effects: []
90+
Ignore Effects: []
91+
Option Spec: move(?x0:table)
92+
NSRT-Op3:
93+
Parameters: [?x0:ball, ?x1:table]
94+
Preconditions: [IsPickedUp0(?x0:ball), holding0(?x0:ball), infront0(?x0:ball), infront2(?x1:table)]
95+
Add Effects: [IsNotHolding0(?x0:ball), IsOnTopOf0(?x0:ball, ?x1:table), OnTable(?x0:ball, ?x1:table)]
96+
Delete Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
97+
Ignore Effects: []
98+
Option Spec: place_on(?x0:ball, ?x1:table)
99+
NSRT-Op4:
100+
Parameters: [?x0:ball, ?x1:ball, ?x2:table]
101+
Preconditions: [IsNotHolding0(?x0:ball), IsNotHolding0(?x1:ball), IsOnTopOf0(?x1:ball, ?x2:table), OnTable(?x1:ball, ?x2:table), infront0(?x1:ball), infront2(?x2:table)]
102+
Add Effects: [infront0(?x0:ball)]
103+
Delete Effects: [infront0(?x1:ball), infront2(?x2:table)]
104+
Ignore Effects: []
105+
Option Spec: move(?x0:ball)
106+
NSRT-Op5:
107+
Parameters: [?x0:ball]
108+
Preconditions: [IsNotHolding0(?x0:ball), infront0(?x0:ball)]
109+
Add Effects: [IsPickedUp0(?x0:ball), holding0(?x0:ball)]
110+
Delete Effects: [IsNotHolding0(?x0:ball)]
111+
Ignore Effects: []
112+
Option Spec: pick(?x0:ball)
113+
NSRT-Op6:
114+
Parameters: [?x0:ball, ?x1:table]
115+
Preconditions: [IsNotHolding0(?x0:ball), IsOnTopOf0(?x0:ball, ?x1:table), OnTable(?x0:ball, ?x1:table)]
116+
Add Effects: [infront0(?x0:ball), infront2(?x1:table)]
117+
Delete Effects: []
118+
Ignore Effects: []
119+
Option Spec: move(?x1:table)
120+
121+
122+
#######
123+
cluster_and_intersect
124+
lis_thesis_sweep
125+
#######
126+
127+
NSRT-Op0:
128+
Parameters: [?x0:robot, ?x1:tool]
129+
Preconditions: []
130+
Add Effects: [on1(?x1:tool, ?x0:robot)]
131+
Delete Effects: []
132+
Ignore Effects: []
133+
Option Spec: move(?x1:tool)
134+
NSRT-Op1:
135+
Parameters: [?x0:surface, ?x1:robot, ?x2:tool]
136+
Preconditions: [on0(?x2:tool, ?x0:surface), on1(?x2:tool, ?x1:robot)]
137+
Add Effects: [holding0(?x2:tool)]
138+
Delete Effects: [on0(?x2:tool, ?x0:surface), on1(?x2:tool, ?x1:robot)]
139+
Ignore Effects: []
140+
Option Spec: pick(?x2:tool)
141+
NSRT-Op2:
142+
Parameters: [?x0:surface]
143+
Preconditions: []
144+
Add Effects: []
145+
Delete Effects: []
146+
Ignore Effects: []
147+
Option Spec: move(?x0:surface)
148+
NSRT-Op3:
149+
Parameters: [?x0:container, ?x1:toy, ?x2:toy, ?x3:surface]
150+
Preconditions: []
151+
Add Effects: [InContainer(?x1:toy, ?x0:container), InContainer(?x2:toy, ?x0:container), NoObjectsOnTop0(?x3:surface), TableSwept(?x3:surface), in0(?x1:toy, ?x0:container), in0(?x2:toy, ?x0:container)]
152+
Delete Effects: []
153+
Ignore Effects: []
154+
Option Spec: sweep(?x3:surface)
155+
NSRT-Op4:
156+
Parameters: [?x0:surface, ?x1:tool]
157+
Preconditions: [holding0(?x1:tool)]
158+
Add Effects: [on0(?x1:tool, ?x0:surface)]
159+
Delete Effects: [holding0(?x1:tool)]
160+
Ignore Effects: []
161+
Option Spec: place_on(?x1:tool, ?x0:surface)
162+
NSRT-Op5:
163+
Parameters: [?x0:tool, ?x1:toy]
164+
Preconditions: []
165+
Add Effects: [not_infront2(?x0:tool)]
166+
Delete Effects: []
167+
Ignore Effects: []
168+
Option Spec: move(?x1:toy)
169+
NSRT-Op6:
170+
Parameters: [?x0:toy]
171+
Preconditions: []
172+
Add Effects: [holding1(?x0:toy)]
173+
Delete Effects: []
174+
Ignore Effects: []
175+
Option Spec: pick(?x0:toy)
176+
NSRT-Op7:
177+
Parameters: [?x0:container]
178+
Preconditions: []
179+
Add Effects: []
180+
Delete Effects: []
181+
Ignore Effects: []
182+
Option Spec: move(?x0:container)
183+
NSRT-Op8:
184+
Parameters: [?x0:container, ?x1:toy]
185+
Preconditions: [holding1(?x1:toy)]
186+
Add Effects: [InContainer(?x1:toy, ?x0:container), in0(?x1:toy, ?x0:container)]
187+
Delete Effects: [holding1(?x1:toy)]
188+
Ignore Effects: []
189+
Option Spec: place_in(?x1:toy, ?x0:container)
190+
191+
#######
192+
backward-forward
193+
lis_thesis_sweep
194+
#######
195+
196+
NSRT-move0:
197+
Parameters: [?x0:object]
198+
Preconditions: []
199+
Add Effects: []
200+
Delete Effects: []
201+
Ignore Effects: []
202+
Option Spec: move(?x0:object)
203+
NSRT-pick0:
204+
Parameters: [?x0:object]
205+
Preconditions: []
206+
Add Effects: [holding1(?x0:object)]
207+
Delete Effects: []
208+
Ignore Effects: []
209+
Option Spec: pick(?x0:object)
210+
NSRT-pick1:
211+
Parameters: [?x0:object]
212+
Preconditions: []
213+
Add Effects: []
214+
Delete Effects: []
215+
Ignore Effects: [on0, on1]
216+
Option Spec: pick(?x0:object)
217+
NSRT-place_in0:
218+
Parameters: [?x1:container, ?x0:toy]
219+
Preconditions: [holding1(?x0:toy)]
220+
Add Effects: [InContainer(?x0:toy, ?x1:container)]
221+
Delete Effects: [holding1(?x0:toy)]
222+
Ignore Effects: []
223+
Option Spec: place_in(?x0:toy, ?x1:container)
224+
NSRT-place_on0:
225+
Parameters: [?x0:object, ?x1:surface]
226+
Preconditions: []
227+
Add Effects: []
228+
Delete Effects: [holding0(?x0:object)]
229+
Ignore Effects: []
230+
Option Spec: place_on(?x0:object, ?x1:surface)
231+
NSRT-sweep0:
232+
Parameters: [?x0:surface, ?x1:container, ?x2:toy, ?x3:toy]
233+
Preconditions: []
234+
Add Effects: [InContainer(?x2:toy, ?x1:container), InContainer(?x3:toy, ?x1:container)]
235+
Delete Effects: []
236+
Ignore Effects: []
237+
Option Spec: sweep(?x0:surface)

predicators/approaches/grammar_search_invention_approach.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ def _select_predicates_by_clustering(
12911291
# that are add effects in those clusters, letting pnad_search
12921292
# downstream handle chainability.
12931293

1294-
assert CFG.segmenter == "option_changes"
1294+
assert CFG.segmenter == "option_changes" or CFG.segmenter == "every_step"
12951295
segments = [
12961296
seg for ll_traj, atom_seq in atom_dataset for seg in
12971297
segment_trajectory(ll_traj, initial_predicates, atom_seq)
@@ -1321,10 +1321,13 @@ def _select_predicates_by_clustering(
13211321
# To cluster on type, there must be types. That is, there
13221322
# must be add effects in the segment and the object
13231323
# arguments for at least one add effect must be nonempty.
1324-
assert len(types_in_effects) > 0 and len(
1325-
set.union(*types_in_effects)) > 0
1326-
types = tuple(sorted(list(set.union(*types_in_effects))))
1327-
types_to_segments.setdefault(types, []).append(seg)
1324+
try:
1325+
assert len(types_in_effects) > 0 and len(
1326+
set.union(*types_in_effects)) > 0
1327+
types = tuple(sorted(list(set.union(*types_in_effects))))
1328+
types_to_segments.setdefault(types, []).append(seg)
1329+
except AssertionError:
1330+
import ipdb; ipdb.set_trace()
13281331
logging.info(
13291332
f"STEP 2: generated {len(types_to_segments.keys())} "
13301333
f"type-based clusters for cluster {i+1} from STEP 1 "

predicators/datasets/generate_atom_trajs_with_vlm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def _generate_prompt_for_atom_proposals(
5959
str(obj.name) for obj in sorted(traj.objects)
6060
if obj.name != 'dummy_goal_obj'
6161
])
62+
# TODO
63+
prompt += "\nBe sure to include reachable, infront, holding, handempty in invented predicate set.\n"
64+
prompt += "\nAlso include atleast three invented predicates that change from True to False directly from a consequence of this action and do this for each action.\n"
65+
prompt += "\nBe sure to propose over 100 predicates.\n"
6266

6367
if CFG.grammar_search_vlm_atom_proposal_prompt_type == "naive_each_step":
6468
i = 0
@@ -87,6 +91,7 @@ def _generate_prompt_for_atom_proposals(
8791
else: # pragma: no cover.
8892
raise ValueError("Unknown VLM prompting option " +
8993
f"{CFG.grammar_search_vlm_atom_proposal_prompt_type}")
94+
9095
return ret_list
9196

9297

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
You are a vision system for a robot. You are provided with two images corresponding to the states before and after a particular skill is executed. You are given a list of predicates below, and you are given the values of these predicates in the image before the skill is executed. Your job is to output the values of the following predicates in the image after the skill is executed. Pay careful attention to the visual changes between the two images to figure out which predicates change and which predicates do not change. For the predicates that change, list these separately at the end of your response. Note that in some scenes, there might be no changes. First, output a description of what changes you expect to happen based on the skill that was just run, explicitly noting the skill that was run. Second, output a description of what visual changes you see happen between the before and after images, looking specifically at the objects involved in the skill's arguments, noting what objects these are. Next, output each predicate value in the after image as a bulleted list with each predicate and value on a different line. For each predicate value *that changes*, provide an explanation as to why you labelled this predicate as having this particular value (no explanation is necessary if you believe the value has not changed). Lastly, some predicates may not be visually apparent in the images - be sure to carry their same truth valuses over to the next state. Atleast one predicate should change to become True each step. Use the format: <predicate>: <truth_value>. <explanation>.
2+
3+
Your response should have three sections. Here is an outline of what your response should look like:
4+
[START OUTLINE]
5+
# Expected changes based on the executed skill
6+
[insert your analysis on the expected changes you will see based on the skill that was executed]
7+
8+
# Visual changes observed between the images
9+
[insert your analysis on the visual changes observed between the images]
10+
11+
# Predicate values in the after image
12+
[insert your bulleted list of `* <predicate>: <truth value>. <explanation>`]
13+
[END OUTLINE]
14+
15+
Predicates:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
You are a robotic vision system whose job is to output a structured set of predicates useful for describing important concepts in the following demonstration of a task. You will be provided with a list of actions used during the task, as well as images of states before and after every action execution. Please provide predicates in terms of the following objects: {objs}. For each predicate, output it in the following format: predicate_name(obj1, obj2, obj3...).
2+
Start by providing an overview description of the demonstration and the changes you observe in it, as well as a list of what concepts you think are relevant.
3+
For each action, generate both "dynamic" predicates (i.e., those that you expect/see to change value before and after the action invocation) and "static" predicates (i.e., those that you expect/see stay constant, but are still important preconditions of the action and need to hold for the action to be correctly executed).
4+
Finally, generate any additional predicates that might be important to describing the overall demonstration. Try to provide any synonyms and antonyms for the most important static and dynamic predicates: the more ways to describe a concept, the better!
5+
Think very carefully about what relations/conditions (in the form of predicates) might be important for each of the particular actions to be executed.
6+
When generating these predicate names, try to be as unambiguous as possible. For instance, instead of generating a predicate `Free(table)` to express the concept that there are no objects/clutter on the table, instead generate `NoObjectsOnTop(table)`, since this is far more precise.
7+
Be careful to only use the objects listed above. DO NOT introduce any additional objects or concepts; if you want to do this, just change the predicate name. For instance, if you want to express the concept `IsColor(crayon, red)`, but the allowed object set only contains `crayon`, then this would be invalid (since there is no `red` object); instead you should output `IsColorRed(crayon)`.

predicators/envs/vlm_envs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ def _get_tasks(self, num: int,
596596
wooden_table_obj = Object("wooden_table", self._surface_type)
597597
floor_obj = Object("floor", self._surface_type)
598598
toy_caterpillar_obj = Object("toy_caterpillar", self._toy_type)
599-
toy_elephant_obj = Object("toy_elephant", self._toy_type)
600-
toy_frog_obj = Object("toy_frog", self._toy_type)
599+
toy_panda_bear_obj = Object("toy_panda_bear", self._toy_type)
600+
toy_brown_bear_obj = Object("toy_brown_bear", self._toy_type)
601601
plastic_bin_obj = Object("plastic_bin", self._container_type)
602602

603603
ret_tasks = []
@@ -608,18 +608,18 @@ def _get_tasks(self, num: int,
608608
wooden_table_obj: np.array([]),
609609
floor_obj: np.array([]),
610610
toy_caterpillar_obj: np.array([]),
611-
toy_elephant_obj: np.array([]),
612-
toy_frog_obj: np.array([]),
611+
toy_panda_bear_obj: np.array([]),
612+
toy_brown_bear_obj: np.array([]),
613613
plastic_bin_obj: np.array([]),
614614
}
615615
# Goal: all three toys in the plastic bin
616616
goal = {
617617
GroundAtom(self._InContainer,
618618
[toy_caterpillar_obj, plastic_bin_obj]),
619619
GroundAtom(self._InContainer,
620-
[toy_elephant_obj, plastic_bin_obj]),
620+
[toy_panda_bear_obj, plastic_bin_obj]),
621621
GroundAtom(self._InContainer,
622-
[toy_frog_obj, plastic_bin_obj]),
622+
[toy_brown_bear_obj, plastic_bin_obj]),
623623
}
624624
ret_tasks.append(EnvironmentTask(State(init_state_dict), goal))
625625
return ret_tasks
@@ -631,11 +631,11 @@ def get_vlm_debug_atom_strs(self,
631631
atom_strs = set([
632632
"holding(squeegee)",
633633
"holding(toy_caterpillar)",
634-
"holding(toy_elephant)",
635-
"holding(toy_frog)",
634+
"holding(toy_panda_bear)",
635+
"holding(toy_brown_bear)",
636636
"InContainer(toy_caterpillar, plastic_bin)",
637-
"InContainer(toy_elephant, plastic_bin)",
638-
"InContainer(toy_frog, plastic_bin)",
637+
"InContainer(toy_panda_bear, plastic_bin)",
638+
"InContainer(toy_brown_bear, plastic_bin)",
639639
"TableSwept(wooden_table)",
640640
"OnSurface(squeegee, floor)",
641641
"OnSurface(squeegee, wooden_table)",

predicators/nsrt_learning/nsrt_learning_main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ def learn_nsrts_from_data(
138138
logging.info(nsrt)
139139
logging.info("")
140140

141+
# Save learned NSRTs to a text file.
142+
save_path = f"saved_results/{CFG.strips_learner}_{CFG.env}_learned_nsrts.txt"
143+
with open(save_path, "w") as f:
144+
for nsrt in nsrts:
145+
f.write(str(nsrt) + "\n")
146+
logging.info("Saved learned NSRTs to %s", save_path)
147+
141148
return set(nsrts), segmented_trajs, seg_to_nsrt
142149

143150

0 commit comments

Comments
 (0)