Skip to content

Commit 86ef834

Browse files
committed
Fix: more precise grasp in grasp_demo.py
1 parent d88051b commit 86ef834

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

examples/fr3/grasp_demo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ def approach(self, geom_name: str):
6161

6262
def grasp(self, geom_name: str):
6363

64-
waypoints = self.plan_linear_motion(geom_name=geom_name, delta_up=0.01, num_waypoints=60)
64+
waypoints = self.plan_linear_motion(geom_name=geom_name, delta_up=-0.005, num_waypoints=60)
6565
self.execute_motion(waypoints=waypoints, gripper=GripperWrapper.BINARY_GRIPPER_OPEN)
6666

67-
self.step(self._action(Pose(), GripperWrapper.BINARY_GRIPPER_CLOSED))
67+
for _ in range(4):
68+
self.step(self._action(self.unwrapped.robot.get_cartesian_position(), GripperWrapper.BINARY_GRIPPER_CLOSED))
6869

6970
waypoints = self.plan_linear_motion(geom_name=geom_name, delta_up=0.2, num_waypoints=60)
7071
self.execute_motion(waypoints=waypoints, gripper=GripperWrapper.BINARY_GRIPPER_CLOSED)

python/rcs/envs/sim.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], float, bool, boo
104104
return obs, 0.0, False, bool(truncated), info
105105

106106
def reset(
107-
self, seed: dict[str, int | None] | None = None, options: dict[str, Any] | None = None # type: ignore
107+
self,
108+
seed: dict[str, int | None] | None = None,
109+
options: dict[str, Any] | None = None, # type: ignore
108110
) -> tuple[dict[str, Any], dict[str, Any]]:
109111
if seed is None:
110-
seed = {key: None for key in self.env.envs}
112+
seed = dict.fromkeys(self.env.envs)
111113
if options is None:
112114
options = {key: {} for key in self.env.envs}
113115
obs = {}
@@ -196,7 +198,6 @@ def __init__(
196198
self.sim.open_gui()
197199

198200
def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], SupportsFloat, bool, bool, dict[str, Any]]:
199-
200201
self.collision_env.get_wrapper_attr("robot").set_joints_hard(self.unwrapped.robot.get_joint_position())
201202
_, _, _, _, info = self.collision_env.step(action)
202203

@@ -219,7 +220,7 @@ def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], SupportsFloat, b
219220
return obs, reward, done, truncated, info
220221

221222
def reset(
222-
self, seed: int | None = None, options: dict[str, Any] | None = None
223+
self, *, seed: int | None = None, options: dict[str, Any] | None = None
223224
) -> tuple[dict[str, Any], dict[str, Any]]:
224225
# check if move to home is collision free
225226
if self.check_home_collision:
@@ -333,7 +334,7 @@ def __init__(
333334
self.y_offset = y_offset
334335

335336
def reset(
336-
self, seed: int | None = None, options: dict[str, Any] | None = None
337+
self, *, seed: int | None = None, options: dict[str, Any] | None = None
337338
) -> tuple[dict[str, Any], dict[str, Any]]:
338339
if options is not None and "RandomObjectPos.init_object_pose" in options:
339340
assert isinstance(
@@ -381,7 +382,7 @@ def __init__(self, env: gym.Env, simulation: sim.Sim, include_rotation: bool = F
381382
self.cube_joint_name = cube_joint_name
382383

383384
def reset(
384-
self, seed: int | None = None, options: dict[str, Any] | None = None
385+
self, *, seed: int | None = None, options: dict[str, Any] | None = None
385386
) -> tuple[dict[str, Any], dict[str, Any]]:
386387
obs, info = super().reset(seed=seed, options=options)
387388
self.sim.step(1)
@@ -456,11 +457,7 @@ def step(self, action: dict[str, Any]):
456457
reward /= 3 # type: ignore
457458
return obs, reward, success, truncated, info
458459

459-
def reset(
460-
self,
461-
seed: dict[str, int | None] | None = None,
462-
options: dict[str, Any] | None = None, # type: ignore
463-
):
460+
def reset(self, *, seed: int | None = None, options: dict[str, Any] | None = None):
464461
obs, info = super().reset()
465462
self.home_pose = self.unwrapped.robot.get_cartesian_position()
466463
return obs, info

0 commit comments

Comments
 (0)