-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4066065
commit fb4758c
Showing
6 changed files
with
383 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Ground-truth models for coffee environment and variants.""" | ||
|
||
from .nsrts import PyBulletFloatGroundTruthNSRTFactory | ||
from .options import PyBulletFloatGroundTruthOptionFactory | ||
|
||
__all__ = [ | ||
"PyBulletFloatGroundTruthNSRTFactory", | ||
"PyBulletFloatGroundTruthOptionFactory" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"""Ground-truth NSRTs for the coffee environment.""" | ||
|
||
from typing import Dict, Set | ||
|
||
from predicators.ground_truth_models import GroundTruthNSRTFactory | ||
from predicators.structs import NSRT, DummyParameterizedOption, LiftedAtom, \ | ||
ParameterizedOption, Predicate, Type, Variable | ||
from predicators.utils import null_sampler | ||
|
||
|
||
class PyBulletFloatGroundTruthNSRTFactory(GroundTruthNSRTFactory): | ||
"""Ground-truth NSRTs for the float environment.""" | ||
|
||
@classmethod | ||
def get_env_names(cls) -> Set[str]: | ||
return {"pybullet_float"} | ||
|
||
@staticmethod | ||
def get_nsrts(env_name: str, types: Dict[str, Type], | ||
predicates: Dict[str, Predicate], | ||
options: Dict[str, ParameterizedOption]) -> Set[NSRT]: | ||
# Types | ||
block_type = types["block"] | ||
robot_type = types["robot"] | ||
vessel_type = types["vessel"] | ||
|
||
# Predicates | ||
InWater = predicates["InWater"] | ||
HandEmpty = predicates["HandEmpty"] | ||
Holding = predicates["Holding"] | ||
|
||
# Options | ||
Pick = options["PickBlock"] | ||
Drop = options["Drop"] | ||
|
||
nsrts = set() | ||
|
||
# PickFromTable | ||
block = Variable("?block", block_type) | ||
robot = Variable("?robot", robot_type) | ||
parameters = [robot, block] | ||
option_vars = [robot, block] | ||
option = Pick | ||
preconditions = { | ||
LiftedAtom(HandEmpty, [robot]) | ||
} | ||
add_effects = { | ||
LiftedAtom(Holding, [robot, block]) | ||
} | ||
delete_effects = { | ||
LiftedAtom(HandEmpty, [robot]) | ||
} | ||
|
||
pickfromtable_nsrt = NSRT("PickFromTable", parameters, | ||
preconditions, add_effects, delete_effects, | ||
set(), option, option_vars, null_sampler) | ||
nsrts.add(pickfromtable_nsrt) | ||
|
||
# DropInWater | ||
robot = Variable("?robot", robot_type) | ||
block = Variable("?block", block_type) | ||
vessel = Variable("?vessel", vessel_type) | ||
parameters = [robot, vessel, block] | ||
option_vars = [robot, vessel] | ||
option = Drop | ||
preconditions = { | ||
LiftedAtom(Holding, [robot, block]), | ||
} | ||
add_effects = { | ||
LiftedAtom(InWater, [block]), | ||
LiftedAtom(HandEmpty, [robot]) | ||
} | ||
delete_effects = { | ||
LiftedAtom(Holding, [robot, block]), | ||
} | ||
drop_in_water_nsrt = NSRT("DropInWater", parameters, | ||
preconditions, add_effects, delete_effects, | ||
set(), option, option_vars, null_sampler) | ||
nsrts.add(drop_in_water_nsrt) | ||
|
||
return nsrts |
Oops, something went wrong.