Skip to content

Commit

Permalink
Merge pull request #259 from StanfordVL/object-init-placement
Browse files Browse the repository at this point in the history
fix duplicate object initial placements
  • Loading branch information
cremebrule authored Feb 16, 2024
2 parents 8e62a12 + a512917 commit bcf94c5
Show file tree
Hide file tree
Showing 26 changed files with 69 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
(ontop electric_mixer.n.01_1 countertop.n.01_1)
(attached mixing_bowl.n.01_1 electric_mixer.n.01_1)
(inroom oven.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inside bowl.n.01_1 electric_refrigerator.n.01_1)
(inroom electric_refrigerator.n.01_1 kitchen)
(ontop cookie_sheet.n.01_1 countertop.n.01_1)
Expand Down
4 changes: 2 additions & 2 deletions bddl/activity_definitions/changing_light_bulbs/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
(:init
(ontop table_lamp.n.01_2 floor.n.01_2)
(ontop light_bulb.n.01_1 breakfast_table.n.01_1)
(ontop light_bulb.n.01_2 breakfast_table.n.01_1)
(not
(ontop light_bulb.n.01_2 breakfast_table.n.01_1)
(not
(toggled_on table_lamp.n.01_1)
)
(not
Expand Down
1 change: 0 additions & 1 deletion bddl/activity_definitions/clean_a_beer_keg/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
(inroom countertop.n.01_1 kitchen)
(ontop agent.n.01_1 floor.n.01_1)
(filled disinfectant__bottle.n.01_1 disinfectant.n.01_1)
(ontop disinfectant__bottle.n.01_1 floor.n.01_1)
)

(:goal
Expand Down
8 changes: 3 additions & 5 deletions bddl/activity_definitions/cleaning_driveway/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

(:init
(covered driveway.n.01_1 bunchgrass.n.01_1)
(covered driveway.n.01_1 dust.n.01_1)
(not
(ontop broom.n.01_1 driveway.n.01_1)
)
(inroom driveway.n.01_1 garden)
(covered driveway.n.01_1 dust.n.01_1)
(ontop broom.n.01_1 driveway.n.01_1)
(inroom driveway.n.01_1 garden)
(inroom floor.n.01_1 garden)
(ontop agent.n.01_1 floor.n.01_1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
(ontop wineglass.n.01_2 bar.n.02_1)
(ontop wineglass.n.01_3 bar.n.02_1)
(ontop beer_glass.n.01_1 bar.n.02_1)
(ontop beer_glass.n.01_1 bar.n.02_1)
(ontop beer_glass.n.01_2 bar.n.02_1)
(inroom bar.n.02_1 bar)
(inroom sink.n.01_1 bar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
(ontop pitcher.n.02_1 breakfast_table.n.01_1)
(covered mug.n.04_1 chocolate_milk.n.01_1)
(filled pitcher.n.02_1 chocolate_milk.n.01_1)
(inside pitcher.n.02_1 electric_refrigerator.n.01_1)
(insource sink.n.01_1 water.n.06_1)
(insource sink.n.01_1 water.n.06_1)
(inroom shelf.n.01_1 kitchen)
(inroom sink.n.01_1 kitchen)
(inroom electric_refrigerator.n.01_1 kitchen)
Expand Down
3 changes: 1 addition & 2 deletions bddl/activity_definitions/cold_brew_coffee/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
(ontop mason_jar.n.01_1 countertop.n.01_1)
(ontop tablespoon.n.02_1 countertop.n.01_1)
(insource sink.n.01_1 water.n.06_1)
(ontop mason_jar.n.01_1 countertop.n.01_1)
(inroom countertop.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom sink.n.01_1 kitchen)
(inroom floor.n.01_1 kitchen)
(inroom electric_refrigerator.n.01_1 kitchen)
Expand Down
3 changes: 1 addition & 2 deletions bddl/activity_definitions/cook_ground_beef/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
(insource salt__shaker.n.01_1 salt.n.02_1)
(ontop salt__shaker.n.01_1 countertop.n.01_1)
(filled bowl.n.01_1 ground_beef.n.01_1)
(inside bowl.n.01_1 electric_refrigerator.n.01_1)
(inroom oven.n.01_1 kitchen)
(inroom oven.n.01_1 kitchen)
(inroom electric_refrigerator.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom floor.n.01_1 kitchen)
Expand Down
1 change: 0 additions & 1 deletion bddl/activity_definitions/cook_tofu/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
(cooked tofu.n.02_4)
)
(inside wok.n.01_1 cabinet.n.01_1)
(inside wok.n.01_1 cabinet.n.01_1)
(insource sink.n.01_1 water.n.06_1)
(inroom electric_refrigerator.n.01_1 kitchen)
(inroom floor.n.01_1 kitchen)
Expand Down
11 changes: 2 additions & 9 deletions bddl/activity_definitions/defrosting_freezer/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:domain omnigibson)

(:objects
stain.n.01_1 - stain.n.01
floor.n.01_1 - floor.n.01
electric_refrigerator.n.01_1 - electric_refrigerator.n.01
sink.n.01_1 - sink.n.01
Expand All @@ -16,17 +15,11 @@
agent.n.01_1 - agent.n.01
)

(:init
(not
(covered sink.n.01_1 stain.n.01_1)
)
(:init
(ontop dustpan.n.02_1 floor.n.01_1)
(ontop bucket.n.01_1 floor.n.01_1)
(ontop scraper.n.01_1 countertop.n.01_1)
(ontop towel.n.01_1 countertop.n.01_1)
(not
(covered towel.n.01_1 stain.n.01_1)
)
(ontop towel.n.01_1 countertop.n.01_1)
(ontop rag.n.01_1 countertop.n.01_1)
(inside crayfish.n.02_1 electric_refrigerator.n.01_1)
(inside crayfish.n.02_2 electric_refrigerator.n.01_1)
Expand Down
7 changes: 3 additions & 4 deletions bddl/activity_definitions/drape_window_scarves/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
)

(:init
(ontop curtain.n.01_1 floor.n.01_1)
(attached curtain_rod.n.01_1 wall.n.01_1)
(ontop curtain.n.01_1 floor.n.01_1)
(inroom floor.n.01_1 bedroom)
(ontop curtain.n.01_1 floor.n.01_1)
(attached curtain_rod.n.01_1 wall.n.01_1)
(inroom floor.n.01_1 bedroom)
(inroom wall.n.01_1 bedroom)
(ontop agent.n.01_1 floor.n.01_1)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
(ontop lemon_juice__bottle.n.01_1 countertop.n.01_1)
(ontop tablespoon.n.02_1 countertop.n.01_1)
(ontop erlenmeyer_flask.n.01_1 countertop.n.01_1)
(ontop vinegar__bottle.n.01_1 countertop.n.01_1)
(inroom countertop.n.01_1 kitchen)
(inroom countertop.n.01_1 kitchen)
(inroom sink.n.01_1 kitchen)
(future vinegar_cleaning_solution.n.01_1)
(inroom floor.n.01_1 kitchen)
Expand Down
2 changes: 0 additions & 2 deletions bddl/activity_definitions/make_chicken_fajitas/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@
(inside bell_pepper.n.02_1 electric_refrigerator.n.01_1)
(inside beefsteak_tomato.n.01_1 electric_refrigerator.n.01_1)
(ontop vidalia_onion.n.01_1 countertop.n.01_1)
(ontop beefsteak_tomato.n.01_1 countertop.n.01_1)
(ontop pepper__shaker.n.01_1 countertop.n.01_1)
(ontop chopping_board.n.01_1 countertop.n.01_1)
(ontop carving_knife.n.01_1 countertop.n.01_1)
(insource pepper__shaker.n.01_1 black_pepper.n.02_1)
(ontop pepper__shaker.n.01_1 countertop.n.01_1)
(insource salt__shaker.n.01_1 salt.n.02_1)
(ontop salt__shaker.n.01_1 countertop.n.01_1)
(insource marjoram__shaker.n.01_1 marjoram.n.02_1)
Expand Down
3 changes: 1 addition & 2 deletions bddl/activity_definitions/make_cookie_dough/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
(filled vanilla__bottle.n.01_1 vanilla.n.02_1)
(inside vanilla__bottle.n.01_1 electric_refrigerator.n.01_1)
(inside butter.n.01_1 bowl.n.01_1)
(inside bowl.n.01_1 electric_refrigerator.n.01_1)
(ontop bowl.n.01_1 countertop.n.01_2)
(ontop bowl.n.01_1 countertop.n.01_2)
(filled baking_powder__jar.n.01_1 baking_powder.n.01_1)
(inside baking_powder__jar.n.01_1 cabinet.n.01_1)
(insource salt__shaker.n.01_1 salt.n.02_1)
Expand Down
3 changes: 1 addition & 2 deletions bddl/activity_definitions/make_fish_and_chips/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
)

(:init
(ontop trout.n.01_1 countertop.n.01_1)
(not
(not
(cooked trout.n.01_1)
)
(frozen trout.n.01_1)
Expand Down
3 changes: 1 addition & 2 deletions bddl/activity_definitions/make_limeade/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
(inside lime_juice__bottle.n.01_1 electric_refrigerator.n.01_1)
(ontop pitcher.n.02_1 countertop.n.01_1)
(ontop wooden_spoon.n.02_1 countertop.n.01_1)
(ontop pitcher.n.02_1 countertop.n.01_1)
(inside ice_cube.n.01_1 bowl.n.01_1)
(inside ice_cube.n.01_1 bowl.n.01_1)
(inside ice_cube.n.01_2 bowl.n.01_1)
(inside ice_cube.n.01_3 bowl.n.01_1)
(inside ice_cube.n.01_4 bowl.n.01_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
(ontop clove.n.03_1 chopping_board.n.01_1)
(ontop clove.n.03_2 chopping_board.n.01_1)
(ontop clove.n.03_3 chopping_board.n.01_1)
(ontop chopping_board.n.01_1 countertop.n.01_1)
(filled mason_jar.n.01_1 kidney_bean.n.01_1)
(ontop mason_jar.n.01_1 countertop.n.01_1)
(ontop beefsteak_tomato.n.01_1 countertop.n.01_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
(attached poster.n.01_1 wall.n.01_1)
)
(inside board_game.n.01_1 carton.n.02_2)
(inside board_game.n.01_1 carton.n.02_2)
(inside coffee_maker.n.01_1 carton.n.02_1)
(ontop carton.n.02_1 floor.n.01_1)
(ontop carton.n.02_2 floor.n.01_1)
Expand Down
2 changes: 0 additions & 2 deletions bddl/activity_definitions/passing_out_drinks/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
(:init
(filled beer_bottle.n.01_1 beer.n.01_1)
(inside beer_bottle.n.01_1 cabinet.n.01_1)
(inside beer_bottle.n.01_1 cabinet.n.01_1)
(inside bottle__of__champagne.n.01_1 cabinet.n.01_1)
(filled pitcher.n.02_1 martini.n.01_1)
(inside pitcher.n.02_1 cabinet.n.01_1)
(inside wineglass.n.01_1 cabinet.n.01_1)
(inside wineglass.n.01_1 cabinet.n.01_1)
(inside beer_glass.n.01_1 cabinet.n.01_1)
(inroom floor.n.01_1 dining_room)
(inroom breakfast_table.n.01_1 dining_room)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
(:init
(ontop cheddar.n.02_1 plate.n.04_1)
(ontop feta.n.01_1 plate.n.04_1)
(inside plate.n.04_1 electric_refrigerator.n.01_1)
(filled wine_bottle.n.01_1 white_wine.n.01_1)
(filled wine_bottle.n.01_1 white_wine.n.01_1)
(filled wine_bottle.n.01_2 champagne.n.01_1)
(inside wine_bottle.n.01_1 electric_refrigerator.n.01_1)
(inside wine_bottle.n.01_2 electric_refrigerator.n.01_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
(inroom wall.n.01_1 garden)
(inroom floor.n.01_2 living_room)
(inroom rail_fence.n.01_1 garden)
(ontop pot_plant.n.01_1 floor.n.01_1)
(ontop agent.n.01_1 floor.n.01_2)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
(ontop shovel.n.01_1 driveway.n.01_1)
(filled bucket.n.01_1 water.n.06_1)
(filled bucket.n.01_1 rubbing_alcohol.n.01_1)
(ontop shovel.n.01_1 wall.n.01_1)
(ontop bucket.n.01_1 driveway.n.01_1)
(ontop bucket.n.01_1 driveway.n.01_1)
(inroom driveway.n.01_1 garden)
(inroom wall.n.01_1 garden)
(inroom floor.n.01_1 garden)
Expand Down
1 change: 0 additions & 1 deletion bddl/activity_definitions/set_a_fancy_table/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
(ontop table_knife.n.01_1 console_table.n.01_1)
(ontop tablefork.n.01_1 console_table.n.01_1)
(ontop wine_bottle.n.01_1 console_table.n.01_1)
(ontop tablespoon.n.02_1 console_table.n.01_1)
(ontop saucer.n.02_1 console_table.n.01_1)
(ontop plate.n.04_1 console_table.n.01_1)
(ontop bouquet.n.01_1 console_table.n.01_1)
Expand Down
7 changes: 3 additions & 4 deletions bddl/activity_definitions/store_silver_coins/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:domain omnigibson)

(:objects
silver.n.02_1 silver.n.02_3 - silver.n.02
silver.n.02_1 silver.n.02_2 - silver.n.02
hand_towel.n.01_1 - hand_towel.n.01
breakfast_table.n.01_1 - breakfast_table.n.01
cup.n.01_1 - cup.n.01
Expand All @@ -13,9 +13,8 @@

(:init
(ontop silver.n.02_1 breakfast_table.n.01_1)
(ontop silver.n.02_1 breakfast_table.n.01_1)
(ontop silver.n.02_3 breakfast_table.n.01_1)
(ontop hand_towel.n.01_1 breakfast_table.n.01_1)
(ontop silver.n.02_2 breakfast_table.n.01_1)
(ontop hand_towel.n.01_1 breakfast_table.n.01_1)
(ontop cup.n.01_1 breakfast_table.n.01_1)
(inroom cabinet.n.01_1 private_office)
(inroom breakfast_table.n.01_1 private_office)
Expand Down
1 change: 0 additions & 1 deletion bddl/activity_definitions/wash_towels/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
(ontop bath_towel.n.01_2 washer.n.03_1)
(ontop bath_towel.n.01_1 floor.n.01_1)
(covered bath_towel.n.01_1 dirt.n.02_1)
(ontop bath_towel.n.01_2 floor.n.01_1)
(covered bath_towel.n.01_2 dirt.n.02_1)
(ontop detergent__bottle.n.01_1 floor.n.01_1)
(filled detergent__bottle.n.01_1 detergent.n.02_1)
Expand Down
72 changes: 46 additions & 26 deletions bddl/bddl_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,13 @@
"lobby"
])
PLACEMENTS = set([
# "connected",
"ontop",
"ontop",
"inside",
"under",
"filled",
"covered",
"overlaid",
"saturated",
"inroom",
"insource",
# "hung",
"overlaid",
"future",
"attached",
"draped",
"contains"
])
SUBSTANCE_PLACEMENTS = set(["saturated", "filled", "covered", "insource", "contains"])
FUTURE_PREDICATE = "future"
Expand Down Expand Up @@ -482,24 +474,52 @@ def all_objects_placed(init):
insts = _get_instances_in_init(init)
insts = set([inst for inst in insts if ["future", inst] not in init])

# Make sure everything not set to `future` is placed relative to a ROOM
placed_insts = set()
old_placed_insts = set()
saturated = False
while not saturated:
for inst in insts:
if inst in placed_insts:
in_room_check = True
last_placed = None
while True:
newly_placed = set()
for literal in init:
# Skip not literals
if literal[0] == "not":
continue
for literal in init:
formula = literal[1] if literal[0] == "not" else literal
# NOTE only uncomment below line suffix when dealing with situations where substance and object have been flipped
if (formula[0] == FUTURE_PREDICATE and formula[1] == inst) or ((formula[0] in PLACEMENTS) and (formula[1] == inst) and ((formula[2] in ROOMS) or (formula[2] in placed_insts))) or ((formula[0] in SUBSTANCE_PLACEMENTS) and (formula[1] in placed_insts) and (formula[2] == inst)):
placed_insts.add(inst)
saturated = old_placed_insts == placed_insts
old_placed_insts = copy.deepcopy(placed_insts)
assert not placed_insts.difference(insts), "There are somehow placed insts that are not in the overall set of insts."
assert placed_insts == insts, f"Unplaced object instances: {insts.difference(placed_insts)}"
formula = literal
# Skip future literals
if formula[0] == "future":
continue
inst = None
substance_placement = False
if in_room_check:
# For the first round, check for inroom
if (formula[0] == "inroom") and (formula[2] in ROOMS):
inst = formula[1]
else:
# For the following rounds, check for placements w.r.t last placed objects
if (formula[0] in PLACEMENTS) and (formula[2] in last_placed):
inst = formula[1]
# Or substasnce placements w.r.t last placed objects
elif (formula[0] in SUBSTANCE_PLACEMENTS) and (formula[1] in last_placed):
inst = formula[2]
substance_placement = True

if inst is not None:
# If it's not a substance placement, we make sure it's only placed once (e.g. we should not place the
# same eapple on table1 and on table2). If it's a substance placement, it's fine (e.g. we can do stain
# covering table1 and table2)
if not substance_placement:
assert inst not in newly_placed, f"Object {inst} is placed twice"
newly_placed.add(inst)

# If no new objects were placed, we're done
if len(newly_placed) == 0:
break

# Otherwise, we remove the newly placed objects from the list of objects to place and continue
insts -= newly_placed
last_placed = newly_placed
in_room_check = False

# If there are any objects left, they are unplaced
assert len(insts) == 0, f"Unplaced object instances: {insts}"

def no_invalid_synsets(objects, init, goal, syns_to_props):
instances, categories = _get_objects_from_object_list(objects)
Expand Down

0 comments on commit bcf94c5

Please sign in to comment.