Skip to content

Commit

Permalink
domain file fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzuo committed Sep 1, 2024
1 parent 2a7972a commit 793ace6
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 4 deletions.
6 changes: 3 additions & 3 deletions planetarium/domains/rover-single.pddl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
(:action sample_soil
:parameters (?s - store ?p - waypoint)
:precondition (and (at_rover ?p) (at_soil_sample ?p) (empty ?s))
:effect (and (not (empty ?s)) (full ?s) (have_soil_analysis ?x ?p)
:effect (and (not (empty ?s)) (full ?s) (have_soil_analysis ?p)
(not (at_soil_sample ?p)))
)

(:action sample_rock
:parameters (?s - store ?p - waypoint)
:precondition (and (at_rover ?p) (at_rock_sample ?p) (empty ?s))
:effect (and (not (empty ?s)) (full ?s) (have_rock_analysis ?x ?p)
:effect (and (not (empty ?s)) (full ?s) (have_rock_analysis ?p)
(not (at_rock_sample ?p)))
)

Expand All @@ -61,7 +61,7 @@
(:action communicate_soil_data
:parameters (?p - waypoint ?x - waypoint ?y - waypoint)
:precondition (and (at_rover ?x)
(at_lander ?y)(have_soil_analysis ?r ?p)
(at_lander ?y)(have_soil_analysis ?p)
(visible ?x ?y)(available)(channel_free))
:effect (and (not (available))
(not (channel_free))(channel_free)
Expand Down
1 change: 1 addition & 0 deletions planetarium/oracles/rover_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def rover_subgraph(scene: ReducedSceneGraph) -> ReducedSceneGraph:

return subgraph


def all_endpoints(
scene: ReducedSceneGraph,
path_map: rx.AllPairsMultiplePathMapping,
Expand Down
124 changes: 123 additions & 1 deletion tests/problem_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,4 +1793,126 @@ def rover_single_line_fully_specified_3():
(communicated_image_data objective1 rgb)
)
)
)"""
)"""


@pytest.fixture
def rover_single_line_fully_specified_4():
# rock and soil samples after lander
return """
(define (problem rover)
(:domain rover-single)
(:objects
site1 site2 site3 site4 site5 site6 - waypoint
store1 store2 - store
rgb - mode
camera1 camera2 camera3 - camera
objective1 objective2 objective3 - objective
)
(:init
(can_traverse site1 site2)
(can_traverse site2 site3)
(can_traverse site3 site4)
(can_traverse site4 site5)
(can_traverse site5 site6)
(visible site1 site2)
(visible site2 site3)
(visible site3 site4)
(visible site4 site5)
(visible site5 site6)
(at_rover site1)
(available)
(at_lander site6)
(empty store1)
(full store2)
(supports camera1 rgb)
(supports camera2 rgb)
(supports camera3 rgb)
(visible_from objective1 site5)
(channel_free)
(at_rock_sample site6)
(at_soil_sample site6)
)
(:goal
(and
(can_traverse site1 site2)
(can_traverse site2 site3)
(can_traverse site3 site4)
(can_traverse site4 site5)
(can_traverse site5 site6)
(visible site1 site2)
(visible site2 site3)
(visible site3 site4)
(visible site4 site5)
(visible site5 site6)
(available)
(at_rover site6)
(at_lander site6)
(empty store1)
(full store2)
(supports camera1 rgb)
(supports camera2 rgb)
(supports camera3 rgb)
(visible_from objective1 site5)
(channel_free)
(have_image objective1 rgb)
(communicated_image_data objective1 rgb)
(have_rock_analysis site6)
(communicated_rock_data site6)
(have_soil_analysis site6)
(communicated_soil_data site6)
(at_rock_sample site6)
(at_soil_sample site6)
)
)
)"""


@pytest.fixture
def rover_single_line_fully_specified_4a():
# rock and soil samples after lander
return """
(define (problem rover)
(:domain rover-single)
(:objects
site1 site2 site3 site4 site5 site6 - waypoint
store1 store2 - store
rgb - mode
camera1 camera2 camera3 - camera
objective1 objective2 objective3 - objective
)
(:init
(can_traverse site1 site2)
(can_traverse site2 site3)
(can_traverse site3 site4)
(can_traverse site4 site5)
(can_traverse site5 site6)
(visible site1 site2)
(visible site2 site3)
(visible site3 site4)
(visible site4 site5)
(visible site5 site6)
(at_rover site1)
(available)
(at_lander site6)
(empty store1)
(full store2)
(supports camera1 rgb)
(supports camera2 rgb)
(supports camera3 rgb)
(visible_from objective1 site5)
(channel_free)
(at_rock_sample site6)
(at_soil_sample site6)
)
(:goal
(and
(have_image objective1 rgb)
(communicated_image_data objective1 rgb)
(have_rock_analysis site6)
(communicated_rock_data site6)
(have_soil_analysis site6)
(communicated_soil_data site6)
)
)
)"""
20 changes: 20 additions & 0 deletions tests/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
blocksworld_fully_specified,
gripper_fully_specified,
gripper_no_robby,
rover_single_line_fully_specified_4,
rover_single_line_fully_specified_4a,
)


Expand Down Expand Up @@ -287,3 +289,21 @@ def test_blocksworld_equivalence(
assert not metric.equals(p1, p2, is_placeholder=False)
assert not metric.equals(p2, p1, is_placeholder=True)
assert not metric.equals(p2, p1, is_placeholder=False)

def test_rover_single_eqquivalence(self, subtests, rover_single_line_fully_specified_4, rover_single_line_fully_specified_4a,):
"""Test the equivalence of rover single line problems."""
p1 = builder.build(rover_single_line_fully_specified_4)
p2 = builder.build(rover_single_line_fully_specified_4a)

p1 = oracle.fully_specify(p1)
p2 = oracle.fully_specify(p2)

# equivalence to itself
assert metric.equals(p1, p1, is_placeholder=True)
assert metric.equals(p1, p1, is_placeholder=False)

# check invalid equivalence
assert not metric.equals(p1, p2, is_placeholder=True)
assert not metric.equals(p1, p2, is_placeholder=False)
assert not metric.equals(p2, p1, is_placeholder=True)
assert not metric.equals(p2, p1, is_placeholder=False)
3 changes: 3 additions & 0 deletions tests/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
rover_single_line_fully_specified_1,
rover_single_line_fully_specified_2,
rover_single_line_fully_specified_3,
rover_single_line_fully_specified_4,
)


Expand Down Expand Up @@ -195,6 +196,7 @@ def test_fully_specified(
rover_single_line_fully_specified_1,
rover_single_line_fully_specified_2,
rover_single_line_fully_specified_3,
rover_single_line_fully_specified_4,
):
"""
Test the fully specified rover problem.
Expand All @@ -204,6 +206,7 @@ def test_fully_specified(
("rover_single_line_fully_specified_1", rover_single_line_fully_specified_1),
("rover_single_line_fully_specified_2", rover_single_line_fully_specified_2),
("rover_single_line_fully_specified_3", rover_single_line_fully_specified_3),
("rover_single_line_fully_specified_4", rover_single_line_fully_specified_4),
]
for name, desc in descs:
with subtests.test(name):
Expand Down

0 comments on commit 793ace6

Please sign in to comment.