Skip to content

Commit d85f584

Browse files
committed
fix(panda): using FR3 class name for linting and ik
1 parent ad38ee1 commit d85f584

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

extensions/rcs_panda/src/rcs_panda/creators.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ def __call__( # type: ignore
3030
self,
3131
ip: str,
3232
control_mode: ControlMode,
33-
robot_cfg: hw.PandaConfig,
33+
robot_cfg: hw.FR3Config,
3434
collision_guard: str | PathLike | None = None,
3535
gripper_cfg: hw.FHConfig | rcs.hand.tilburg_hand.THConfig | None = None,
3636
camera_set: HardwareCameraSet | None = None,
3737
max_relative_movement: float | tuple[float, float] | None = None,
3838
relative_to: RelativeTo = RelativeTo.LAST_STEP,
39-
urdf_path: str | PathLike | None = None,
4039
) -> gym.Env:
4140
"""
4241
Creates a hardware environment for the Panda robot.
@@ -55,16 +54,19 @@ def __call__( # type: ignore
5554
translational movement in meters. If tuple, it restricts both translational (in meters) and rotational
5655
(in radians) movements. If None, no restriction is applied.
5756
relative_to (RelativeTo): Specifies whether the movement is relative to a configured origin or the last step.
58-
urdf_path (str | PathLike | None): Path to the URDF file. If None the included one is used. A URDF file is needed for collision guarding.
5957
6058
Returns:
6159
gym.Env: The configured hardware environment for the Panda robot.
6260
"""
63-
if urdf_path is None:
64-
urdf_path = rcs.scenes["Panda_empty_world"].urdf
65-
ik = rcs.common.RL(str(urdf_path)) if urdf_path is not None else None
66-
robot = hw.Panda(ip, ik)
67-
robot.set_parameters(robot_cfg)
61+
ik = rcs.common.Pin(
62+
robot_cfg.kinematic_model_path,
63+
robot_cfg.attachment_site,
64+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
65+
)
66+
# ik = rcs_robotics_library._core.rl.RoboticsLibraryIK(robot_cfg.kinematic_model_path)
67+
68+
robot = hw.FR3(ip, ik)
69+
robot.set_config(robot_cfg)
6870

6971
env: gym.Env = RobotEnv(
7072
robot, ControlMode.JOINTS if collision_guard is not None else control_mode, home_on_reset=True
@@ -107,20 +109,24 @@ class RCSPandaMultiEnvCreator(RCSHardwareEnvCreator):
107109
def __call__( # type: ignore
108110
ips: list[str],
109111
control_mode: ControlMode,
110-
robot_cfg: hw.PandaConfig,
112+
robot_cfg: hw.FR3Config,
111113
gripper_cfg: hw.FHConfig | None = None,
112114
camera_set: HardwareCameraSet | None = None,
113115
max_relative_movement: float | tuple[float, float] | None = None,
114116
relative_to: RelativeTo = RelativeTo.LAST_STEP,
115-
urdf_path: str | PathLike | None = None,
116117
) -> gym.Env:
117118

118-
urdf_path = rcs.scenes["panda_empty_world"].urdf
119-
ik = rcs.common.RL(str(urdf_path)) if urdf_path is not None else None
120-
robots: dict[str, hw.Panda] = {}
119+
ik = rcs.common.Pin(
120+
robot_cfg.kinematic_model_path,
121+
robot_cfg.attachment_site,
122+
urdf=robot_cfg.kinematic_model_path.endswith(".urdf"),
123+
)
124+
# ik = rcs_robotics_library._core.rl.RoboticsLibraryIK(robot_cfg.kinematic_model_path)
125+
126+
robots: dict[str, hw.FR3] = {}
121127
for ip in ips:
122-
robots[ip] = hw.Panda(ip, ik)
123-
robots[ip].set_parameters(robot_cfg)
128+
robots[ip] = hw.FR3(ip, ik)
129+
robots[ip].set_config(robot_cfg)
124130

125131
envs = {}
126132
for ip in ips:

extensions/rcs_panda/src/rcs_panda/envs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class PandaHW(gym.Wrapper):
1212
def __init__(self, env):
1313
super().__init__(env)
1414
self.unwrapped: RobotEnv
15-
assert isinstance(self.unwrapped.robot, hw.Panda), "Robot must be a hw.Panda instance."
16-
self.hw_robot = cast(hw.Panda, self.unwrapped.robot)
15+
assert isinstance(self.unwrapped.robot, hw.FR3), "Robot must be a hw.Panda instance."
16+
self.hw_robot = cast(hw.FR3, self.unwrapped.robot)
1717

1818
def step(self, action: Any) -> tuple[dict[str, Any], SupportsFloat, bool, bool, dict]:
1919
try:

extensions/rcs_panda/src/rcs_panda/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from rcs import common
44

55

6-
def default_panda_hw_robot_cfg(async_control: bool = False) -> hw.PandaConfig:
7-
robot_cfg = hw.PandaConfig()
6+
def default_panda_hw_robot_cfg(async_control: bool = False) -> hw.FR3Config:
7+
robot_cfg = hw.FR3Config()
88
robot_cfg.tcp_offset = common.Pose(common.FrankaHandTCPOffset())
99
robot_cfg.speed_factor = 0.1
1010
robot_cfg.ik_solver = hw.IKSolver.rcs_ik

0 commit comments

Comments
 (0)