Skip to content

Commit ac4d6a8

Browse files
committed
fix: previous sim wrapper and gripper id
1 parent 08805e6 commit ac4d6a8

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

python/rcs/envs/sim.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def __init__(self, env, simulation: sim.Sim, sim_wrapper: Type[SimWrapper] | Non
3939
if sim_wrapper is not None:
4040
env = sim_wrapper(env, simulation)
4141
super().__init__(env)
42-
# self.unwrapped: RobotEnv
43-
# assert isinstance(self.unwrapped.robot, sim.SimRobot), "Robot must be a sim.SimRobot instance."
44-
# self.sim_robot = cast(sim.SimRobot, self.unwrapped.robot)
42+
self.unwrapped: RobotEnv
43+
assert isinstance(self.unwrapped.robot, sim.SimRobot), "Robot must be a sim.SimRobot instance."
44+
self.sim_robot = cast(sim.SimRobot, self.unwrapped.robot)
4545
self.sim = simulation
4646
cfg = self.sim.get_config()
4747
self.frame_rate = SimpleFrameRate(1 / cfg.frequency, "RobotSimWrapper")
@@ -56,19 +56,19 @@ def step(self, action: dict[str, Any]) -> tuple[dict[str, Any], float, bool, boo
5656
self.frame_rate()
5757

5858
else:
59-
# self.sim_robot.clear_collision_flag()
59+
self.sim_robot.clear_collision_flag()
6060
self.sim.step_until_convergence()
61-
# state = self.sim_robot.get_state()
62-
# if "collision" not in info:
63-
# info["collision"] = state.collision
64-
# else:
65-
# info["collision"] = info["collision"] or state.collision
66-
# info["ik_success"] = state.ik_success
61+
state = self.sim_robot.get_state()
62+
if "collision" not in info:
63+
info["collision"] = state.collision
64+
else:
65+
info["collision"] = info["collision"] or state.collision
66+
info["ik_success"] = state.ik_success
6767
info["is_sim_converged"] = self.sim.is_converged()
6868
# truncate episode if collision
69-
# obs.update(self.unwrapped.get_obs())
70-
# return obs, 0, False, info["collision"] or not state.ik_success, info
71-
return obs, 0, False, False, info
69+
obs.update(self.unwrapped.get_obs())
70+
return obs, 0, False, info["collision"] or not state.ik_success, info
71+
# return obs, 0, False, False, info
7272

7373
def reset(
7474
self, *, seed: int | None = None, options: dict[str, Any] | None = None
@@ -77,7 +77,7 @@ def reset(
7777
obs, info = super().reset(seed=seed, options=options)
7878
self.sim.step(1)
7979
# todo: an obs method that is recursive over wrappers would be needed
80-
# obs.update(self.unwrapped.get_obs())
80+
obs.update(self.unwrapped.get_obs())
8181
return obs, info
8282

8383

python/rcs/envs/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ def default_tilburg_hw_hand_cfg(file: str | PathLike | None = None) -> THConfig:
3737
return hand_cfg
3838

3939

40-
def default_sim_gripper_cfg(_idx: str = "0") -> sim.SimGripperConfig:
40+
def default_sim_gripper_cfg(idx: str = "0") -> sim.SimGripperConfig:
4141
cfg = sim.SimGripperConfig()
42-
cfg.collision_geoms = []
43-
cfg.collision_geoms_fingers = []
44-
# cfg.add_id(idx)
42+
cfg.add_id(idx)
4543
return cfg
4644

4745

0 commit comments

Comments
 (0)