Skip to content

Commit 70607c4

Browse files
committed
refactor(lab env): flexible camera robot joint position
1 parent feaa1ca commit 70607c4

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

python/examples/grasp_demo_lab.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def main():
8585
"rcs/LabPickUpSimDigitHand-v0",
8686
render_mode="human",
8787
delta_actions=True,
88+
cam_robot_joints=np.array(
89+
[-0.78452318, -1.18096017, 1.75158399, -1.0718541, -0.11207275, 1.01050546, 2.47343638]
90+
),
8891
)
8992
env.reset()
9093
controller = PickUpDemo(env)

python/rcsss/envs/factories.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
RandomCubePosLab,
2929
SimWrapper,
3030
)
31+
from rcsss.envs.space_utils import Vec7Type
3132
from rcsss.envs.utils import (
3233
default_fr3_hw_gripper_cfg,
3334
default_fr3_hw_robot_cfg,
@@ -306,18 +307,17 @@ def __call__( # type: ignore
306307

307308
class CamRobot(gym.Wrapper):
308309

309-
def __init__(self, env):
310+
def __init__(self, env, cam_robot_joints: Vec7Type):
310311
super().__init__(env)
311312
self.unwrapped: FR3Env
312313
assert isinstance(self.unwrapped.robot, sim.FR3), "Robot must be a sim.FR3 instance."
313314
self.sim = env.get_wrapper_attr("sim")
314315
self.cam_robot = rcsss.sim.FR3(self.sim, "1", env.unwrapped.robot.get_ik())
315316
self.cam_robot.set_parameters(default_fr3_sim_robot_cfg("lab_simple_pick_up_digit_hand"))
317+
self.cam_robot_joints = cam_robot_joints
316318

317319
def step(self, action: dict):
318-
self.cam_robot.set_joints_hard(
319-
[-0.78452318, -1.18096017, 1.75158399, -1.0718541, -0.11207275, 1.01050546, 2.47343638]
320-
)
320+
self.cam_robot.set_joints_hard(self.cam_robot_joints)
321321
obs, reward, done, truncated, info = super().step(action)
322322
return obs, reward, done, truncated, info
323323

@@ -330,6 +330,7 @@ def reset(self, *, seed=None, options=None):
330330
class FR3LabPickUpSimDigitHand(EnvCreator):
331331
def __call__( # type: ignore
332332
self,
333+
cam_robot_joints: Vec7Type,
333334
render_mode: str = "human",
334335
control_mode: str = "xyzrpy",
335336
resolution: tuple[int, int] | None = None,
@@ -368,7 +369,7 @@ def __call__( # type: ignore
368369
sim_wrapper=RandomCubePosLab,
369370
)
370371
env_rel = FR3LabPickUpSimSuccessWrapper(env_rel)
371-
env_rel = CamRobot(env_rel)
372+
env_rel = CamRobot(env_rel, cam_robot_joints)
372373
if render_mode == "human":
373374
sim = env_rel.get_wrapper_attr("sim")
374375
sim.open_gui()

0 commit comments

Comments
 (0)