-
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.
Ball and Cup Sticky Table Env (#1576)
* initial commit that seems to run without error... * fix bug in placing logic * delete outdated comment * fix replanning bug * more data = better results??? * starting tests * try oracle feature selection? * fix buggy test * increase training time? * yapf + fix tom comment * fix reachability issue in placing * minor * more unit tests * fix and more tests * this should be interesting * see if this yields a difference * let's see what happens now * woops * try removing placing cup with the ball on the table * hail mary * minor changes + logging * run task repeat first * sticky table with moving radius * yay! try other approaches... * polar coordinates ftw! * try a simpler thing * let's see how this does. * try more probability of success * all baselines * try running grid row env * most things passing * try this * progress towards PR * should be ready! * revert unnecessary change * fix linting * tom comments --------- Co-authored-by: Tom Silver <[email protected]>
- Loading branch information
1 parent
db29a6c
commit 3090591
Showing
12 changed files
with
1,740 additions
and
61 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
9 changes: 9 additions & 0 deletions
9
predicators/ground_truth_models/ball_and_cup_sticky_table/__init__.py
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 ball and cup sticky table environment.""" | ||
|
||
from .nsrts import BallAndCupStickyTableGroundTruthNSRTFactory | ||
from .options import BallAndCupStickyTableGroundTruthOptionFactory | ||
|
||
__all__ = [ | ||
"BallAndCupStickyTableGroundTruthNSRTFactory", | ||
"BallAndCupStickyTableGroundTruthOptionFactory" | ||
] |
533 changes: 533 additions & 0 deletions
533
predicators/ground_truth_models/ball_and_cup_sticky_table/nsrts.py
Large diffs are not rendered by default.
Oops, something went wrong.
198 changes: 198 additions & 0 deletions
198
predicators/ground_truth_models/ball_and_cup_sticky_table/options.py
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,198 @@ | ||
"""Ground-truth options for the ball and cup sticky table environment.""" | ||
|
||
from typing import Dict, Sequence, Set | ||
|
||
import numpy as np | ||
from gym.spaces import Box | ||
|
||
from predicators import utils | ||
from predicators.envs.ball_and_cup_sticky_table import BallAndCupStickyTableEnv | ||
from predicators.ground_truth_models import GroundTruthOptionFactory | ||
from predicators.structs import Action, Array, Object, ParameterizedOption, \ | ||
ParameterizedPolicy, Predicate, State, Type | ||
|
||
|
||
class BallAndCupStickyTableGroundTruthOptionFactory(GroundTruthOptionFactory): | ||
"""Ground-truth options for the sticky table environment.""" | ||
|
||
@classmethod | ||
def get_env_names(cls) -> Set[str]: | ||
return {"ball_and_cup_sticky_table"} | ||
|
||
@classmethod | ||
def get_options(cls, env_name: str, types: Dict[str, Type], | ||
predicates: Dict[str, Predicate], | ||
action_space: Box) -> Set[ParameterizedOption]: | ||
|
||
cup_type = types["cup"] | ||
ball_type = types["ball"] | ||
table_type = types["table"] | ||
# Parameters are move_or_pickplace, obj_type_id, ball_only, | ||
# absolute x, y actions. | ||
params_space = Box( | ||
np.array([ | ||
0.0, 0.0, 0.0, BallAndCupStickyTableEnv.x_lb, | ||
BallAndCupStickyTableEnv.y_lb | ||
]), | ||
np.array([ | ||
1.0, 3.0, 1.0, BallAndCupStickyTableEnv.x_ub, | ||
BallAndCupStickyTableEnv.y_ub | ||
])) | ||
robot_type = types["robot"] | ||
|
||
PickBallFromTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, table] | ||
"PickBallFromTable", | ||
cls._create_pass_through_policy(action_space), | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type, table_type]) | ||
|
||
PickBallFromFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball] | ||
"PickBallFromFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type]) | ||
|
||
PlaceBallOnTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup, table] | ||
"PlaceBallOnTable", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type, table_type]) | ||
|
||
PlaceBallOnFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup, ball] | ||
"PlaceBallOnFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, cup_type, ball_type]) | ||
|
||
PickCupWithoutBallFromTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup, ball, table] | ||
"PickCupWithoutBallFromTable", | ||
cls._create_pass_through_policy(action_space), | ||
params_space=params_space, | ||
types=[robot_type, cup_type, ball_type, table_type]) | ||
|
||
PickCupWithBallFromTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup, ball, table] | ||
"PickCupWithBallFromTable", | ||
cls._create_pass_through_policy(action_space), | ||
params_space=params_space, | ||
types=[robot_type, cup_type, ball_type, table_type]) | ||
|
||
PickCupWithoutBallFromFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup, ball] | ||
"PickCupWithoutBallFromFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, cup_type, ball_type]) | ||
|
||
PickCupWithBallFromFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup, ball] | ||
"PickCupWithBallFromFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, cup_type, ball_type]) | ||
|
||
PlaceCupWithoutBallOnTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup, table] | ||
"PlaceCupWithoutBallOnTable", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type, table_type]) | ||
|
||
PlaceCupWithBallOnFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup] | ||
"PlaceCupWithBallOnFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type]) | ||
|
||
PlaceCupWithoutBallOnFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup] | ||
"PlaceCupWithoutBallOnFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type]) | ||
|
||
PlaceBallInCupOnFloor = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup] | ||
"PlaceBallInCupOnFloor", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type]) | ||
|
||
PlaceBallInCupOnTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball, cup] | ||
"PlaceBallInCupOnTable", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type, cup_type, table_type]) | ||
|
||
NavigateToTable = utils.SingletonParameterizedOption( | ||
# variables: [robot, table] | ||
"NavigateToTable", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, table_type]) | ||
|
||
NavigateToBall = utils.SingletonParameterizedOption( | ||
# variables: [robot, ball] | ||
"NavigateToBall", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, ball_type]) | ||
|
||
NavigateToCup = utils.SingletonParameterizedOption( | ||
# variables: [robot, cup] | ||
"NavigateToCup", | ||
cls._create_pass_through_policy(action_space), | ||
# Parameters are absolute x, y actions. | ||
params_space=params_space, | ||
types=[robot_type, cup_type]) | ||
|
||
return { | ||
NavigateToTable, | ||
PickBallFromTable, | ||
PickBallFromFloor, | ||
PlaceBallOnTable, | ||
PlaceBallOnFloor, | ||
PickCupWithoutBallFromTable, | ||
PickCupWithBallFromTable, | ||
PickCupWithoutBallFromFloor, | ||
PickCupWithBallFromFloor, #PlaceCupWithBallOnTable, | ||
PlaceCupWithoutBallOnTable, | ||
PlaceCupWithBallOnFloor, | ||
PlaceCupWithoutBallOnFloor, | ||
PlaceBallInCupOnFloor, | ||
PlaceBallInCupOnTable, | ||
NavigateToBall, | ||
NavigateToCup | ||
} | ||
|
||
@classmethod | ||
def _create_pass_through_policy(cls, | ||
action_space: Box) -> ParameterizedPolicy: | ||
|
||
def policy(state: State, memory: Dict, objects: Sequence[Object], | ||
params: Array) -> Action: | ||
del state, memory, objects # unused | ||
arr = np.array(params, dtype=np.float32) | ||
arr = np.clip(arr, action_space.low, action_space.high) | ||
return Action(arr) | ||
|
||
return policy |
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
Oops, something went wrong.