Skip to content

Commit 4ccffe8

Browse files
committed
style: fix types
1 parent 47a3e62 commit 4ccffe8

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from rcs_fr3 import desk, envs
2+
from rcs_fr3._core import hw
23

34
__all__ = [
45
"desk",
56
"envs",
7+
"hw",
68
]

extensions/rcs_fr3/src/rcs_fr3/creators.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from rcs.hand.tilburg_hand import TilburgHand
2121
from rcs_fr3.envs import FR3HW
2222
from rcs_fr3.utils import default_fr3_hw_gripper_cfg, default_fr3_hw_robot_cfg
23+
from rcs_fr3 import hw
2324

2425
import rcs
2526

@@ -32,9 +33,9 @@ def __call__( # type: ignore
3233
self,
3334
ip: str,
3435
control_mode: ControlMode,
35-
robot_cfg: rcs.hw.FR3Config,
36+
robot_cfg: hw.FR3Config,
3637
collision_guard: str | PathLike | None = None,
37-
gripper_cfg: rcs.hw.FHConfig | rcs.hand.tilburg_hand.THConfig | None = None,
38+
gripper_cfg: hw.FHConfig | rcs.hand.tilburg_hand.THConfig | None = None,
3839
camera_set: HardwareCameraSet | None = None,
3940
max_relative_movement: float | tuple[float, float] | None = None,
4041
relative_to: RelativeTo = RelativeTo.LAST_STEP,
@@ -65,14 +66,14 @@ def __call__( # type: ignore
6566
if urdf_path is None:
6667
urdf_path = rcs.scenes["fr3_empty_world"]["urdf"]
6768
ik = rcs.common.IK(str(urdf_path)) if urdf_path is not None else None
68-
robot = rcs.hw.FR3(ip, ik)
69+
robot = hw.FR3(ip, ik)
6970
robot.set_parameters(robot_cfg)
7071

7172
env: gym.Env = RobotEnv(robot, ControlMode.JOINTS if collision_guard is not None else control_mode)
7273

7374
env = FR3HW(env)
74-
if isinstance(gripper_cfg, rcs.hw.FHConfig):
75-
gripper = rcs.hw.FrankaHand(ip, gripper_cfg)
75+
if isinstance(gripper_cfg, hw.FHConfig):
76+
gripper = hw.FrankaHand(ip, gripper_cfg)
7677
env = GripperWrapper(env, gripper, binary=True)
7778
elif isinstance(gripper_cfg, rcs.hand.tilburg_hand.THConfig):
7879
hand = TilburgHand(gripper_cfg)
@@ -107,8 +108,8 @@ class RCSFR3MultiEnvCreator(RCSHardwareEnvCreator):
107108
def __call__( # type: ignore
108109
ips: list[str],
109110
control_mode: ControlMode,
110-
robot_cfg: rcs.hw.FR3Config,
111-
gripper_cfg: rcs.hw.FHConfig | None = None,
111+
robot_cfg: hw.FR3Config,
112+
gripper_cfg: hw.FHConfig | None = None,
112113
camera_set: HardwareCameraSet | None = None,
113114
max_relative_movement: float | tuple[float, float] | None = None,
114115
relative_to: RelativeTo = RelativeTo.LAST_STEP,
@@ -117,17 +118,17 @@ def __call__( # type: ignore
117118

118119
urdf_path = rcs.scenes["fr3_empty_world"]["urdf"]
119120
ik = rcs.common.IK(str(urdf_path)) if urdf_path is not None else None
120-
robots: dict[str, rcs.hw.FR3] = {}
121+
robots: dict[str, hw.FR3] = {}
121122
for ip in ips:
122-
robots[ip] = rcs.hw.FR3(ip, ik)
123+
robots[ip] = hw.FR3(ip, ik)
123124
robots[ip].set_parameters(robot_cfg)
124125

125126
envs = {}
126127
for ip in ips:
127128
env: gym.Env = RobotEnv(robots[ip], control_mode)
128129
env = FR3HW(env)
129130
if gripper_cfg is not None:
130-
gripper = rcs.hw.FrankaHand(ip, gripper_cfg)
131+
gripper = hw.FrankaHand(ip, gripper_cfg)
131132
env = GripperWrapper(env, gripper, binary=True)
132133

133134
if max_relative_movement is not None:

extensions/rcs_fr3/src/rcs_fr3/desk.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import requests
1414
from dotenv import load_dotenv
1515
from rcs_fr3.utils import default_fr3_hw_gripper_cfg
16+
import rcs_fr3
1617
from requests.packages import urllib3 # type: ignore[attr-defined]
1718
from websockets.sync.client import connect
1819

19-
import rcs
2020

2121
_logger = logging.getLogger("desk")
2222

@@ -38,13 +38,13 @@ def load_creds_fr3_desk() -> tuple[str, str]:
3838

3939
def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False):
4040
with Desk.fci(ip, username, password, unlock=unlock):
41-
f = rcs.hw.FR3(ip)
42-
config = rcs.hw.FR3Config()
41+
f = rcs_fr3.hw.FR3(ip)
42+
config = rcs_fr3.hw.FR3Config()
4343
config.speed_factor = 0.2
44-
config.ik_solver = rcs.hw.IKSolver.franka_ik
44+
config.ik_solver = rcs_fr3.hw.IKSolver.franka_ik
4545
f.set_parameters(config)
46-
config_hand = rcs.hw.FHConfig()
47-
g = rcs.hw.FrankaHand(ip, config_hand)
46+
config_hand = rcs_fr3.hw.FHConfig()
47+
g = rcs_fr3.hw.FrankaHand(ip, config_hand)
4848
if shut:
4949
g.shut()
5050
else:
@@ -54,8 +54,8 @@ def home(ip: str, username: str, password: str, shut: bool, unlock: bool = False
5454

5555
def info(ip: str, username: str, password: str, include_hand: bool = False):
5656
with Desk.fci(ip, username, password):
57-
f = rcs.hw.FR3(ip)
58-
config = rcs.hw.FR3Config()
57+
f = rcs_fr3.hw.FR3(ip)
58+
config = rcs_fr3.hw.FR3Config()
5959
f.set_parameters(config)
6060
print("Robot info:")
6161
print("Current cartesian position:")
@@ -64,7 +64,7 @@ def info(ip: str, username: str, password: str, include_hand: bool = False):
6464
print(f.get_joint_position())
6565
if include_hand:
6666
config_hand = default_fr3_hw_gripper_cfg()
67-
g = rcs.hw.FrankaHand(ip, config_hand)
67+
g = rcs_fr3.hw.FrankaHand(ip, config_hand)
6868
print("Gripper info:")
6969
print("Current normalized width:")
7070
print(g.get_normalized_width())

python/examples/fr3.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from rcs._core.sim import CameraType
77
from rcs.camera.sim import SimCameraConfig, SimCameraSet
88
from rcs_fr3.desk import FCI, ContextManager, Desk, load_creds_fr3_desk
9+
from rcs_fr3._core import hw
910

1011
import rcs
1112
from rcs import sim
@@ -94,17 +95,17 @@ def main():
9495
else:
9596
urdf_path = rcs.scenes["fr3_empty_world"]["urdf"]
9697
ik = rcs.common.IK(str(urdf_path))
97-
robot = rcs.hw.FR3(ROBOT_IP, ik)
98+
robot = hw.FR3(ROBOT_IP, ik)
9899
robot_cfg = FR3Config()
99100
robot_cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
100101
robot_cfg.ik_solver = IKSolver.rcs_ik
101-
robot.set_parameters(robot_cfg)
102+
robot.set_parameters(robot_cfg) # type: ignore
102103

103-
gripper_cfg_hw = rcs.hw.FHConfig()
104+
gripper_cfg_hw = hw.FHConfig()
104105
gripper_cfg_hw.epsilon_inner = gripper_cfg_hw.epsilon_outer = 0.1
105106
gripper_cfg_hw.speed = 0.1
106107
gripper_cfg_hw.force = 30
107-
gripper = rcs.hw.FrankaHand(ROBOT_IP, gripper_cfg_hw)
108+
gripper = hw.FrankaHand(ROBOT_IP, gripper_cfg_hw)
108109
input("the robot is going to move, press enter whenever you are ready")
109110

110111
# move to home position and open gripper

0 commit comments

Comments
 (0)