Skip to content

Commit dde203e

Browse files
committed
format: pylint
1 parent 2d882bd commit dde203e

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

examples/simple_tilburg_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ def pad_qpos(q: np.ndarray):
7373
print("power_grasp_radians=[", ", ".join(f"{rad:.2f}" for rad in rads), "]")
7474
print("min_joints_radians=[", ", ".join(f"{rad:.2f}" for rad in min_joints_radians), "]")
7575
print("max_joints_radians=[", ", ".join(f"{rad:.2f}" for rad in max_joints_radians), "]")
76-
config = THConfig(
76+
hand_cfg = THConfig(
7777
calibration_file="/home/sbien/Documents/Development/RCS/robot-control-stack/python/rcs/hand/calibration_og.json",
7878
grasp_percentage=1,
7979
hand_orientation="right",
8080
)
81-
hand = TilburgHand(cfg=config, verbose=True)
81+
hand = TilburgHand(cfg=hand_cfg, verbose=True)
8282
hand.set_grasp_type(GraspType.POWER_GRASP)
8383
hand.grasp()
8484
sleep(2)

examples/tilburg_grasp.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@
5353

5454
def main():
5555

56-
if ROBOT_INSTANCE == RobotPlatform.HARDWARE:
57-
# env_rel = RCSFR3EnvCreator()(
58-
# ip=ROBOT_IP,
59-
# control_mode=ControlMode.JOINTS,
60-
# robot_cfg=default_fr3_hw_robot_cfg(),
61-
# collision_guard=None,
62-
# gripper_cfg=default_fr3_hw_gripper_cfg(),
63-
# max_relative_movement=np.deg2rad(5),
64-
# relative_to=RelativeTo.LAST_STEP,
65-
# )
66-
return
67-
else:
56+
if ROBOT_INSTANCE == RobotPlatform.SIMULATION:
6857
env_rel = SimEnvCreator()(
6958
control_mode=ControlMode.JOINTS,
7059
collision_guard=False,
@@ -77,15 +66,15 @@ def main():
7766
)
7867
env_rel.get_wrapper_attr("sim").open_gui()
7968

80-
for _ in range(10):
81-
obs, info = env_rel.reset()
8269
for _ in range(10):
83-
# sample random relative action and execute it
84-
act = env_rel.action_space.sample()
85-
obs, reward, terminated, truncated, info = env_rel.step(act)
86-
if truncated or terminated:
87-
logger.info("Truncated or terminated!")
88-
return
70+
obs, info = env_rel.reset()
71+
for _ in range(10):
72+
# sample random relative action and execute it
73+
act = env_rel.action_space.sample()
74+
obs, reward, terminated, truncated, info = env_rel.step(act)
75+
if truncated or terminated:
76+
logger.info("Truncated or terminated!")
77+
return
8978

9079

9180
if __name__ == "__main__":

python/rcs/envs/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def default_sim_gripper_cfg(idx: str = "0") -> sim.SimGripperConfig:
4040

4141

4242
def default_sim_tilburg_hand_cfg() -> sim.SimTilburgHandConfig:
43-
cfg = sim.SimTilburgHandConfig()
44-
return cfg
43+
return sim.SimTilburgHandConfig()
4544

4645

4746
def default_digit(name2id: dict[str, str] | None, stream_name: str = "QVGA") -> DigitCam | None:

python/rcs/hand/tilburg_hand.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import copy
2-
import enum
32
import logging
43
from dataclasses import dataclass
54
from time import sleep
@@ -29,6 +28,13 @@ def __post_init__(self):
2928
# 👇 satisfy pybind11 by actually calling the C++ constructor
3029
super().__init__()
3130

31+
@dataclass
32+
class TilburgHandState(common.HandState):
33+
joint_positions: Vec18Type
34+
35+
def __post_init__(self):
36+
super().__init__()
37+
3238

3339
class TilburgHand(common.Hand):
3440
"""
@@ -190,7 +196,8 @@ def set_grasp_type(self, grasp_type: common.GraspType):
190196
Sets the grasp type for the hand.
191197
"""
192198
if not isinstance(grasp_type, common.GraspType):
193-
raise ValueError(f"Invalid grasp type: {grasp_type}. Must be an instance of common.GraspType.")
199+
error_msg = f"Invalid grasp type: {grasp_type}. Must be an instance of common.GraspType."
200+
raise ValueError(error_msg)
194201
if grasp_type == common.GraspType.POWER_GRASP:
195202
self._cfg.grasp_type = common.GraspType.POWER_GRASP
196203
elif grasp_type == common.GraspType.PRECISION_GRASP:
@@ -203,7 +210,8 @@ def set_grasp_type(self, grasp_type: common.GraspType):
203210
logger.warning("Tripod grasp is not implemented yet. Defaulting to power grasp.")
204211
self._cfg.grasp_type = common.GraspType.POWER_GRASP
205212
else:
206-
raise ValueError(f"Unknown grasp type: {grasp_type}.")
213+
error_msg = f"Unknown grasp type: {grasp_type}."
214+
raise ValueError(error_msg)
207215

208216
logger.info(f"Grasp type set to: {self._cfg.grasp_type}")
209217

@@ -226,11 +234,11 @@ def reset(self):
226234
self.set_zero_pos()
227235
logger.info("Hand reset to initial state.")
228236

229-
def get_state(self) -> np.ndarray:
237+
def get_state(self) -> TilburgHandState:
230238
"""
231239
Returns the current state of the hand.
232240
"""
233-
return self.get_pos_vector()
241+
return TilburgHandState(joint_positions=self.get_pos_vector())
234242

235243
def close(self):
236244
"""

0 commit comments

Comments
 (0)