Skip to content

Commit

Permalink
Merge pull request #71 from StanfordVL/transition-map-contentfixes
Browse files Browse the repository at this point in the history
Transition map contentfixes
  • Loading branch information
cgokmen authored Sep 2, 2023
2 parents 3ab6c73 + cd11c0d commit 0421a04
Show file tree
Hide file tree
Showing 16 changed files with 26,593 additions and 118 deletions.
4 changes: 4 additions & 0 deletions bddl/activity_definitions/baking_sugar_cookies/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
mason_jar.n.01_1 - mason_jar.n.01
countertop.n.01_1 countertop.n.01_2 - countertop.n.01
vanilla__bottle.n.01_1 - vanilla__bottle.n.01
salt.n.02_1 - salt.n.02
salt__shaker.n.01_1 - salt__shaker.n.01
bowl.n.01_1 - bowl.n.01
electric_refrigerator.n.01_1 - electric_refrigerator.n.01
tablespoon.n.02_1 - tablespoon.n.02
Expand All @@ -31,6 +33,8 @@
(:init
(filled flour__sack.n.01_1 flour.n.01_1)
(ontop flour__sack.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)
(ontop tablespoon.n.02_1 countertop.n.01_1)
(filled sugar__sack.n.01_1 granulated_sugar.n.01_1)
(ontop sugar__sack.n.01_1 countertop.n.01_1)
Expand Down
12 changes: 2 additions & 10 deletions bddl/activity_definitions/make_a_red_meat_sauce/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
clove.n.03_1 clove.n.03_2 clove.n.03_3 - clove.n.03
ground_beef.n.01_1 - ground_beef.n.01
basil.n.03_1 basil.n.03_2 basil.n.03_3 basil.n.03_4 - basil.n.03
red_meat_sauce.n.01_1 - red_meat_sauce.n.01
cooked__red_meat_sauce.n.01_1 - cooked__red_meat_sauce.n.01
stove.n.01_1 - stove.n.01
saucepan.n.01_1 - saucepan.n.01
Expand Down Expand Up @@ -47,21 +46,14 @@
(inroom countertop.n.01_1 kitchen)
(inroom electric_refrigerator.n.01_1 kitchen)
(future cooked__red_meat_sauce.n.01_1)
(future red_meat_sauce.n.01_1)
(inroom floor.n.01_1 kitchen)
(ontop agent.n.01_1 floor.n.01_1)
)

(:goal
(and
(or
(real ?cooked__red_meat_sauce.n.01_1)
(real ?red_meat_sauce.n.01_1)
)
(or
(contains ?saucepan.n.01_1 ?cooked__red_meat_sauce.n.01_1)
(contains ?saucepan.n.01_1 ?red_meat_sauce.n.01_1)
)
(real ?cooked__red_meat_sauce.n.01_1)
(contains ?saucepan.n.01_1 ?cooked__red_meat_sauce.n.01_1)
)
)
)
6 changes: 2 additions & 4 deletions bddl/activity_definitions/make_iced_tea/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
electric_kettle.n.01_1 - electric_kettle.n.01
mug.n.04_1 - mug.n.04
ice_cube.n.01_1 ice_cube.n.01_2 - ice_cube.n.01
tea.n.01_1 - tea.n.01
water_glass.n.02_1 - water_glass.n.02
countertop.n.01_1 - countertop.n.01
cup.n.01_1 - cup.n.01
Expand All @@ -34,16 +33,15 @@
(inroom cabinet.n.01_1 kitchen)
(inroom electric_refrigerator.n.01_1 kitchen)
(inroom sink.n.01_1 kitchen)
(future tea.n.01_1)
(inroom floor.n.01_1 kitchen)
(inroom stove.n.01_1 kitchen)
(ontop agent.n.01_1 floor.n.01_1)
)

(:goal
(and
(real ?tea.n.01_1)
(contains ?water_glass.n.02_1 ?tea.n.01_1)
(contains ?water_glass.n.02_1 ?water.n.06_1)
(inside ?tea_bag.n.01_1 ?water_glass.n.02_1)
(forall
(?ice_cube.n.01 - ice_cube.n.01)
(inside ?ice_cube.n.01 ?water_glass.n.02_1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
mixing_bowl.n.01_1 - mixing_bowl.n.01
flour__sack.n.01_1 - flour__sack.n.01
salt__shaker.n.01_1 - salt__shaker.n.01
onion_powder__shaker.n.01_1 - onion_powder__shaker.n.01
onion_powder.n.01_1 - onion_powder.n.01
countertop.n.01_1 - countertop.n.01
electric_refrigerator.n.01_1 - electric_refrigerator.n.01
cabinet.n.01_1 - cabinet.n.01
Expand All @@ -32,7 +34,9 @@
(filled cooking_oil__bottle.n.01_1 cooking_oil.n.01_1)
(ontop cooking_oil__bottle.n.01_1 countertop.n.01_1)
(insource salt__shaker.n.01_1 salt.n.02_1)
(insource onion_powder__shaker.n.01_1 onion_powder.n.01_1)
(ontop salt__shaker.n.01_1 countertop.n.01_1)
(ontop onion_powder__shaker.n.01_1 countertop.n.01_1)
(ontop electric_mixer.n.01_1 countertop.n.01_1)
(attached mixing_bowl.n.01_1 electric_mixer.n.01_1)
(future onion_ring_batter.n.01_1)
Expand Down
8 changes: 4 additions & 4 deletions bddl/activity_definitions/make_waffles/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
butter.n.01_1 - butter.n.01
vanilla.n.02_1 - vanilla.n.02
flour.n.01_1 - flour.n.01
baking_powder.n.01_1 - baking_powder.n.01
yogurt.n.01_1 - yogurt.n.01
salt.n.02_1 - salt.n.02
granulated_sugar.n.01_1 - granulated_sugar.n.01
whole_milk.n.01_1 - whole_milk.n.01
Expand All @@ -17,7 +17,7 @@
waffle_iron.n.01_1 - waffle_iron.n.01
plate.n.04_1 - plate.n.04
flour__sack.n.01_1 - flour__sack.n.01
baking_powder__jar.n.01_1 - baking_powder__jar.n.01
yogurt__carton.n.01_1 - yogurt__carton.n.01
salt__shaker.n.01_1 - salt__shaker.n.01
sugar__sack.n.01_1 - sugar__sack.n.01
countertop.n.01_1 countertop.n.01_2 - countertop.n.01
Expand All @@ -40,8 +40,8 @@
(inside vanilla__bottle.n.01_1 cabinet.n.01_1)
(filled flour__sack.n.01_1 flour.n.01_1)
(ontop flour__sack.n.01_1 countertop.n.01_1)
(filled baking_powder__jar.n.01_1 baking_powder.n.01_1)
(inside baking_powder__jar.n.01_1 cabinet.n.01_1)
(filled yogurt__carton.n.01_1 yogurt.n.01_1)
(inside yogurt__carton.n.01_1 electric_refrigerator.n.01_1)
(insource salt__shaker.n.01_1 salt.n.02_1)
(ontop salt__shaker.n.01_1 countertop.n.01_1)
(filled sugar__sack.n.01_1 granulated_sugar.n.01_1)
Expand Down
6 changes: 6 additions & 0 deletions bddl/activity_definitions/preserving_fruit/problem0.bddl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
soup_ladle.n.01_1 - soup_ladle.n.01
mason_jar.n.01_1 - mason_jar.n.01
water.n.06_1 - water.n.06
mint.n.04_1 - mint.n.04
blender.n.01_1 - blender.n.01
carving_knife.n.01_1 - carving_knife.n.01
electric_refrigerator.n.01_1 - electric_refrigerator.n.01
cabinet.n.01_1 - cabinet.n.01
sink.n.01_1 - sink.n.01
Expand All @@ -29,12 +32,15 @@
(inside strawberry.n.01_6 tupperware.n.01_1)
(inside strawberry.n.01_7 tupperware.n.01_1)
(inside tupperware.n.01_1 electric_refrigerator.n.01_1)
(inside mint.n.04_1 electric_refrigerator.n.01_1)
(filled granulated_sugar__sack.n.01_1 granulated_sugar.n.01_1)
(ontop granulated_sugar__sack.n.01_1 countertop.n.01_1)
(ontop carving_knife.n.01_1 countertop.n.01_1)
(inside saucepot.n.01_1 cabinet.n.01_1)
(inside soup_ladle.n.01_1 cabinet.n.01_1)
(ontop mason_jar.n.01_1 countertop.n.01_1)
(open mason_jar.n.01_1)
(ontop blender.n.01_1 countertop.n.01_1)
(insource sink.n.01_1 water.n.06_1)
(future sugar_syrup.n.01_1)
(inroom sink.n.01_1 kitchen)
Expand Down
124 changes: 123 additions & 1 deletion bddl/data_generation/get_implicit_transition_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def generate_dicing_rules(syns_to_param_props, props_to_syns):
Generates transition rules for dicing of diceable objects.
Form:
{
"rule_name": <non-unique string>,
"rule_name": <unique string name>,
"input_objects": {
<diceable>: 1
},
Expand Down Expand Up @@ -167,16 +167,138 @@ def generate_substance_cooking_rules(syns_to_param_props, props_to_syns):
return rules


def generate_melting_rules(syns_to_param_props, props_to_syns):
"""
Generates transition rules for melting of meltable objects.
Form:
{
"rule_name": <unique string name>,
"input_objects": {
<meltable>: 1
},
"output_objects": {
<meltable_derivative_synset>: 1
}
}
"""
rules = []
meltables = props_to_syns["meltable"]
for meltable in meltables:
assert "meltable_derivative_synset" in syns_to_param_props[meltable]["meltable"], f"Synset {meltable} has no meltable derivative synset. Add one in the parameter annotations or handle otherwise."
assert syns_to_param_props[meltable]["meltable"]["meltable_derivative_synset"] in syns_to_param_props, f"Synset {meltable} has meltable derivative synset {syns_to_param_props[meltable]['meltable_derivative_synset']} that is not a valid synset. Please check."
meltable_derivative_synset = syns_to_param_props[meltable]["meltable"]["meltable_derivative_synset"]

rule = {
"rule_name": f"{meltable}-melting",
"input_objects": {
meltable: 1
},
"output_objects": {
meltable_derivative_synset: 1
}
}

rules.append(rule)

rules.sort(key=lambda x: x["rule_name"])
return rules


def generate_washer_particleremover_rules(props_to_syns):
"""
Generates transition rules for adding water to particleRemovers that come out of a washer
Form:
{
"rule_name": <particleRemover>-washer-saturate-cover,
"input_objects": {},
"washed_item": {
<particleRemover>: 1,
},
"output_objects": {
"water.n.06": 1
}
}
Invariants not explicitly stated in rule:
- At input time washer.n.03 exists and is toggled on, `washed_item` is inside
- At output time `washed_item` is covered and saturated in water
"""
rules = []
particleRemovers = set(props_to_syns["particleRemover"])
for particleRemover in particleRemovers:
rule = {
"rule_name": f"{particleRemover}-washer-saturate-cover",
"input_objects": {},
"washed_item": {
particleRemover: 1
},
"output_objects": {
"water.n.06": 1
}
}
rules.append(rule)
rules.sort(key=lambda x: x["rule_name"])
return rules


def generate_washer_nonparticleremover_rules(props_to_syns):
"""
Generates transition rules for adding water to non-particleRemover nonSubstances that come
out of a washer.
Form:
{
"rule_name": <nonSubstance,non-particleRemover>-washer-cover,
"input_objects": {},
"washed_item": {
<non-particleRemover,nonSubstance>: 1
},
"output_objects": {
"water.n.06": 1
}
}
Invariants not explicitly stated in rule:
- At input time washer.n.03 exists and is toggled on, `washed_item` is
inside
- At output time `washed_item` is covered and saturated in water
"""
rules = []
particleRemovers = set(props_to_syns["particleRemover"])
nonSubstances = set(props_to_syns["nonSubstance"])
nonparticleremover_nonsubstances = nonSubstances.difference(particleRemovers)
for syn in nonparticleremover_nonsubstances:
rule = {
"rule_name": f"{syn}-washer-cover",
"input_objects": {},
"washed_item": {
syn: 1
},
"output_objects": {
"water.n.06": 1
}
}
rules.append(rule)
rules.sort(key=lambda x: x["rule_name"])
return rules


def create_get_save_implicit_transition_rules(syns_to_param_props, props_to_syns):
print("Creating implicit transition rule jsons...")
slicing_rules = generate_slicing_rules(syns_to_param_props, props_to_syns)
dicing_rules = generate_dicing_rules(syns_to_param_props, props_to_syns)
substance_cooking_rules = generate_substance_cooking_rules(syns_to_param_props, props_to_syns)
melting_rules = generate_melting_rules(syns_to_param_props, props_to_syns)
washer_particleremover_rules = generate_washer_particleremover_rules(props_to_syns)
washer_nonparticleremover_rules = generate_washer_nonparticleremover_rules(props_to_syns)

with open(os.path.join(TRANSITION_MAP_DIR, "slicing.json"), "w") as f:
json.dump(slicing_rules, f, indent=4)
with open(os.path.join(TRANSITION_MAP_DIR, "dicing.json"), "w") as f:
json.dump(dicing_rules, f, indent=4)
with open(os.path.join(TRANSITION_MAP_DIR, "substance_cooking.json"), "w") as f:
json.dump(substance_cooking_rules, f, indent=4)
with open(os.path.join(TRANSITION_MAP_DIR, "melting.json"), "w") as f:
json.dump(melting_rules, f, indent=4)
with open(os.path.join(TRANSITION_MAP_DIR, "washer_particleremover.json"), "w") as f:
json.dump(washer_particleremover_rules, f, indent=4)
with open(os.path.join(TRANSITION_MAP_DIR, "washer_nonparticleremover.json"), "w") as f:
json.dump(washer_nonparticleremover_rules, f, indent=4)
print("Created and saved implicit transition rule jsons.")
9 changes: 8 additions & 1 deletion bddl/data_generation/process_prop_param_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ def create_get_save_propagated_annots_params(syns_to_props):
raise ValueError(f"synset {param_record['synset']} particleSink annotation has NaN value for parameter {param_name}. Either handle NaN or annotate parameter value.")
elif prop == "particleSource":
raise ValueError(f"synset {param_record['synset']} particleSource annotation has NaN value for parameter {param_name}. Either handle NaN or annotate parameter value.")
elif prop == "meltable":
raise ValueError(f"synset {param_record['synset']} meltable annotation has NaN value for parameter {param_name}. Either handle NaN or annotate param value.")


# `conditions` values - format is keyword1:bool_value1;keyword2:bool_value2;...;keywordN:bool_valueN
elif param_name == "conditions":
Expand All @@ -188,7 +191,7 @@ def create_get_save_propagated_annots_params(syns_to_props):

else:
raise ValueError(f"prop {prop} not handled for parameter name `conditions`")

# Can skip system since it's just part of handling `conditions`
elif param_name == "system": continue

Expand All @@ -199,6 +202,10 @@ def create_get_save_propagated_annots_params(syns_to_props):
else:
raise ValueError(f"prop {prop} not handled for parameter name `method`")

# Required derivative synsets
elif param_name == "meltable_derivative_synset":
formatted_param_value = param_value

# Float values
else:
try:
Expand Down
1 change: 1 addition & 0 deletions bddl/data_generation/pull_sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
(SYNSET_PARAMS_SHEET_KEY, "particleSink", "prop_param_annots/particleSink.csv"),
(SYNSET_PARAMS_SHEET_KEY, "diceable", "prop_param_annots/diceable.csv"),
(SYNSET_PARAMS_SHEET_KEY, "sliceable", "prop_param_annots/sliceable.csv"),
(SYNSET_PARAMS_SHEET_KEY, "meltable", "prop_param_annots/meltable.csv"),
(EXPLICIT_TRANSITION_RULES_SHEET_KEY, "electric_mixer", "transition_map/tm_raw_data/electric_mixer.csv"),
(EXPLICIT_TRANSITION_RULES_SHEET_KEY, "heat_cook", "transition_map/tm_raw_data/heat_cook.csv"),
(EXPLICIT_TRANSITION_RULES_SHEET_KEY, "mixing_stick", "transition_map/tm_raw_data/mixing_stick.csv"),
Expand Down
Loading

0 comments on commit 0421a04

Please sign in to comment.