Skip to content

Commit 146fa77

Browse files
committed
chore: collision guard update
1 parent af472e9 commit 146fa77

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

extensions/rcs_xarm7/src/rcs_xarm7/creators.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def __call__( # type: ignore
3535
control_mode: ControlMode,
3636
ip: str,
3737
calibration_dir: PathLike | str | None = None,
38+
collision_guard: str | PathLike | None = None,
39+
cg_kinematics_path: str | PathLike | None = None,
3840
camera_set: HardwareCameraSet | None = None,
3941
hand_cfg: THConfig | None = None,
4042
max_relative_movement: float | tuple[float, float] | None = None,
@@ -55,6 +57,21 @@ def __call__( # type: ignore
5557
hand = TilburgHand(cfg=hand_cfg, verbose=True)
5658
env = HandWrapper(env, hand, True)
5759

60+
if collision_guard:
61+
env = CollisionGuard.env_from_xml_paths(
62+
env=env,
63+
collision_guard=collision_guard,
64+
cg_kinematics_path=cg_kinematics_path,
65+
hand=True,
66+
gripper=False,
67+
check_home_collision=False,
68+
control_mode=control_mode,
69+
tcp_offset=rcs.common.Pose(),
70+
sim_gui=True,
71+
truncate_on_collision=True,
72+
id="",
73+
)
74+
5875
if max_relative_movement is not None:
5976
env = RelativeActionSpace(env, max_mov=max_relative_movement, relative_to=relative_to)
6077

python/rcs/envs/sim.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import gymnasium as gym
55
import numpy as np
6-
from rcs.envs.base import ControlMode, GripperWrapper, MultiRobotWrapper, RobotEnv
6+
from rcs.envs.base import ControlMode, GripperWrapper, HandWrapper, MultiRobotWrapper, RobotEnv
77
from rcs.envs.space_utils import ActObsInfoWrapper
8-
from rcs.envs.utils import default_sim_robot_cfg
8+
from rcs.envs.utils import default_sim_robot_cfg, default_sim_tilburg_hand_cfg
99

1010
import rcs
1111
from rcs import sim
@@ -213,9 +213,10 @@ def env_from_xml_paths(
213213
cls,
214214
env: gym.Env,
215215
mjmld: str,
216-
urdf: str,
216+
cg_kinematics_path: str,
217217
id: str = "0",
218218
gripper: bool = True,
219+
hand: bool = False,
219220
check_home_collision: bool = True,
220221
tcp_offset: rcs.common.Pose | None = None,
221222
control_mode: ControlMode | None = None,
@@ -226,7 +227,7 @@ def env_from_xml_paths(
226227
# TODO: this needs to support non FR3 robots
227228
assert isinstance(env.unwrapped, RobotEnv)
228229
simulation = sim.Sim(mjmld)
229-
ik = rcs.common.RL(urdf, max_duration_ms=300)
230+
ik = rcs.common.Pin(cg_kinematics_path, "attachment_site", False)
230231
cfg = default_sim_robot_cfg(mjmld, id)
231232
cfg.realtime = False
232233
if tcp_offset is not None:
@@ -250,6 +251,13 @@ def env_from_xml_paths(
250251
fh = sim.SimGripper(simulation, gripper_cfg)
251252
c_env = GripperWrapper(c_env, fh)
252253
c_env = GripperWrapperSim(c_env, fh)
254+
if hand:
255+
hand_cfg = default_sim_tilburg_hand_cfg()
256+
# hand_cfg.add_id(id)
257+
th = sim.SimTilburgHand(simulation, hand_cfg)
258+
c_env = HandWrapper(c_env, th)
259+
c_env = HandWrapperSim(c_env, th)
260+
253261
return cls(
254262
env=env,
255263
simulation=simulation,

0 commit comments

Comments
 (0)