Skip to content

Commit 7dd4eff

Browse files
committed
feat: working real setup integration
1 parent c32337f commit 7dd4eff

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

extensions/rcs_xarm7/src/rcs_xarm7/creators.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
CameraSetWrapper,
1212
ControlMode,
1313
GripperWrapper,
14+
HandWrapper,
1415
RelativeActionSpace,
1516
RelativeTo,
1617
RobotEnv,
1718
)
19+
from rcs.hand.tilburg_hand import TilburgHand, THConfig
1820
from rcs.envs.creators import RCSHardwareEnvCreator
1921
from rcs.envs.sim import CollisionGuard, GripperWrapperSim, RobotSimWrapper, SimWrapper
2022
from rcs.sim import SimCameraConfig, SimGripperConfig, SimRobotConfig
@@ -34,6 +36,7 @@ def __call__( # type: ignore
3436
ip: str,
3537
calibration_dir: PathLike | str | None = None,
3638
camera_set: HardwareCameraSet | None = None,
39+
hand_cfg: THConfig | None = None,
3740
max_relative_movement: float | tuple[float, float] | None = None,
3841
relative_to: RelativeTo = RelativeTo.LAST_STEP,
3942
) -> gym.Env:
@@ -48,6 +51,9 @@ def __call__( # type: ignore
4851
camera_set.wait_for_frames()
4952
logger.info("CameraSet started")
5053
env = CameraSetWrapper(env, camera_set)
54+
if hand_cfg is not None and isinstance(hand_cfg, THConfig):
55+
hand = TilburgHand(cfg=hand_cfg, verbose=True)
56+
env = HandWrapper(env, hand, True)
5157

5258
if max_relative_movement is not None:
5359
env = RelativeActionSpace(env, max_mov=max_relative_movement, relative_to=relative_to)

extensions/rcs_xarm7/src/rcs_xarm7/env_cartesian_control.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from rcs.envs.creators import SimEnvCreator
77
from rcs.envs.utils import get_tcp_offset
88
from rcs_xarm7.creators import RCSXArm7EnvCreator, XArm7SimEnvCreator
9-
9+
from rcs.hand.tilburg_hand import THConfig
1010
import rcs
1111
from rcs import sim
1212

@@ -21,9 +21,15 @@
2121
def main():
2222

2323
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
24+
hand_cfg = THConfig(
25+
calibration_file="/home/ken/tilburg_hand/calibration.json",
26+
grasp_percentage=1,
27+
hand_orientation="right"
28+
)
2429
env_rel = RCSXArm7EnvCreator()(
2530
control_mode=ControlMode.CARTESIAN_TQuat,
2631
ip=ROBOT_IP,
32+
hand_cfg=hand_cfg,
2733
relative_to=RelativeTo.LAST_STEP,
2834
max_relative_movement=np.deg2rad(3),
2935
)
@@ -66,21 +72,21 @@ def main():
6672
env_rel.get_wrapper_attr("sim").open_gui()
6773

6874
env_rel.reset()
69-
act = {"tquat": [0.1, 0, 0, 0, 0, 0, 1], "gripper": 0}
70-
obs, reward, terminated, truncated, info = env_rel.step(act)
75+
# act = {"tquat": [0.1, 0, 0, 0, 0, 0, 1], "gripper": 0}
76+
# obs, reward, terminated, truncated, info = env_rel.step(act)
7177

7278
with env_rel:
7379
for _ in range(10):
7480
for _ in range(10):
7581
# move 1cm in x direction (forward) and close gripper
76-
act = {"tquat": [0.01, 0, 0, 0, 0, 0, 1], "gripper": 0}
82+
act = {"tquat": [0.01, 0, 0, 0, 0, 0, 1], "hand": 1}
7783
obs, reward, terminated, truncated, info = env_rel.step(act)
7884
if truncated or terminated:
7985
logger.info("Truncated or terminated!")
8086
return
8187
for _ in range(10):
8288
# move 1cm in negative x direction (backward) and open gripper
83-
act = {"tquat": [-0.01, 0, 0, 0, 0, 0, 1], "gripper": 1}
89+
act = {"tquat": [-0.01, 0, 0, 0, 0, 0, 1], "hand": 0}
8490
obs, reward, terminated, truncated, info = env_rel.step(act)
8591
if truncated or terminated:
8692
logger.info("Truncated or terminated!")

python/rcs/envs/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,6 @@ def action(self, action: dict[str, Any]) -> dict[str, Any]:
802802
self._last_hand_cmd = hand_action
803803
del action[self.hand_key]
804804
return action
805-
805+
806806
def close(self):
807807
self._hand.close()

0 commit comments

Comments
 (0)