Skip to content

Commit

Permalink
Add options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashay-bdai committed Sep 19, 2024
1 parent 15c741d commit 523656b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
74 changes: 37 additions & 37 deletions predicators/envs/spot_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2496,41 +2496,41 @@ def _detection_id_to_obj(self) -> Dict[ObjectDetectionID, Object]:
return detection_id_to_obj

def _create_operators(self) -> Iterator[STRIPSOperator]:
# Pick object
robot = Variable("?robot", _robot_type)
obj = Variable("?object", _movable_object_type)
table = Variable("?table", _movable_object_type)
parameters = [robot, obj, table]
preconds: Set[LiftedAtom] = {
LiftedAtom(_HandEmpty, [robot]),
LiftedAtom(_NotHolding, [robot, obj]),
LiftedAtom(_VLMOn, [obj, table])
}
add_effs: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
del_effs: Set[LiftedAtom] = {
LiftedAtom(_HandEmpty, [robot]),
LiftedAtom(_NotHolding, [robot, obj]),
LiftedAtom(_VLMOn, [obj, table])
}
ignore_effs: Set[LiftedAtom] = set()
yield STRIPSOperator("Pick", parameters, preconds, add_effs, del_effs,
ignore_effs)

# Place object
robot = Variable("?robot", _robot_type)
obj = Variable("?object", _movable_object_type)
pan = Variable("?pan", _container_type)
parameters = [robot, obj, pan]
preconds: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
add_effs: Set[LiftedAtom] = {
LiftedAtom(_HandEmpty, [robot]),
LiftedAtom(_NotHolding, [robot, obj]),
LiftedAtom(_VLMOn, [obj, pan])
}
del_effs: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
ignore_effs: Set[LiftedAtom] = set()
yield STRIPSOperator("Place", parameters, preconds, add_effs, del_effs,
ignore_effs)
# # Pick object
# robot = Variable("?robot", _robot_type)
# obj = Variable("?object", _movable_object_type)
# table = Variable("?table", _movable_object_type)
# parameters = [robot, obj, table]
# preconds: Set[LiftedAtom] = {
# LiftedAtom(_HandEmpty, [robot]),
# LiftedAtom(_NotHolding, [robot, obj]),
# LiftedAtom(_VLMOn, [obj, table])
# }
# add_effs: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
# del_effs: Set[LiftedAtom] = {
# LiftedAtom(_HandEmpty, [robot]),
# LiftedAtom(_NotHolding, [robot, obj]),
# LiftedAtom(_VLMOn, [obj, table])
# }
# ignore_effs: Set[LiftedAtom] = set()
# yield STRIPSOperator("Pick", parameters, preconds, add_effs, del_effs,
# ignore_effs)

# # Place object
# robot = Variable("?robot", _robot_type)
# obj = Variable("?object", _movable_object_type)
# pan = Variable("?pan", _container_type)
# parameters = [robot, obj, pan]
# preconds: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
# add_effs: Set[LiftedAtom] = {
# LiftedAtom(_HandEmpty, [robot]),
# LiftedAtom(_NotHolding, [robot, obj]),
# LiftedAtom(_VLMOn, [obj, pan])
# }
# del_effs: Set[LiftedAtom] = {LiftedAtom(_Holding, [robot, obj])}
# ignore_effs: Set[LiftedAtom] = set()
# yield STRIPSOperator("Place", parameters, preconds, add_effs, del_effs,
# ignore_effs)


##########################################3
Expand All @@ -2548,7 +2548,7 @@ def _create_operators(self) -> Iterator[STRIPSOperator]:
LiftedAtom(_NotHolding, [robot, dustpan]),
}
ignore_effs: Set[LiftedAtom] = set()
yield STRIPSOperator("Pick", parameters, preconds, add_effs, del_effs,
yield STRIPSOperator("Pick1", parameters, preconds, add_effs, del_effs,
ignore_effs)

# Place(robot, dustpan, mess)
Expand Down Expand Up @@ -2581,7 +2581,7 @@ def _create_operators(self) -> Iterator[STRIPSOperator]:
LiftedAtom(_NotHolding, [robot, broom]),
}
ignore_effs: Set[LiftedAtom] = set()
yield STRIPSOperator("Pick", parameters, preconds, add_effs, del_effs,
yield STRIPSOperator("Pick2", parameters, preconds, add_effs, del_effs,
ignore_effs)

# Sweep(robot, broom, mess, dustpan)
Expand Down
12 changes: 8 additions & 4 deletions predicators/ground_truth_models/spot_env/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,10 @@ def _teleop(robot: Robot, lease_client: LeaseClient):
"PrepareContainerForSweeping": Box(-np.inf, np.inf, (3, )), # dx, dy, dyaw
"DropNotPlaceableObject": Box(0, 1, (0, )), # empty
"MoveToReadySweep": Box(0, 1, (0, )), # empty
"Pick": Box(0, 1, (0, )), # empty
"Place": Box(0, 1, (0, )) # empty
"Pick1": Box(0, 1, (0, )), # empty
"Place": Box(0, 1, (0, )), # empty
"Pick2": Box(0, 1, (0, )), # empty
"Sweep": Box(0, 1, (0, )) # empty
}

# NOTE: the policies MUST be unique because they output actions with extra info
Expand All @@ -982,8 +984,10 @@ def _teleop(robot: Robot, lease_client: LeaseClient):
"PrepareContainerForSweeping": _prepare_container_for_sweeping_policy,
"DropNotPlaceableObject": _drop_not_placeable_object_policy,
"MoveToReadySweep": _move_to_ready_sweep_policy,
"Pick": _teleop_policy,
"Place": _teleop_policy
"Pick1": _teleop_policy,
"Place": _teleop_policy,
"Pick2": _teleop_policy,
"Sweep": _teleop_policy
}


Expand Down

0 comments on commit 523656b

Please sign in to comment.