A named finger with ordered joints and safety limits.
Source code in dexterous_hand/finger.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 | @dataclass
class Finger:
"""A named finger with ordered joints and safety limits."""
name: str
joint_names: list[str]
lower_limits_rad: list[float]
upper_limits_rad: list[float]
def validate_positions(self, positions_rad: list[float]) -> None:
"""Validate joint positions against configured limits."""
if len(positions_rad) != len(self.joint_names):
msg = f"{self.name} expected {len(self.joint_names)} joints, got {len(positions_rad)}"
raise ValueError(msg)
for joint, value, lower, upper in zip(
self.joint_names, positions_rad, self.lower_limits_rad, self.upper_limits_rad
):
if value < lower or value > upper:
msg = f"{joint} position {value:.3f} rad outside [{lower:.3f}, {upper:.3f}]"
raise ValueError(msg)
|
validate_positions(positions_rad)
Validate joint positions against configured limits.
Source code in dexterous_hand/finger.py
25
26
27
28
29
30
31
32
33
34
35
36 | def validate_positions(self, positions_rad: list[float]) -> None:
"""Validate joint positions against configured limits."""
if len(positions_rad) != len(self.joint_names):
msg = f"{self.name} expected {len(self.joint_names)} joints, got {len(positions_rad)}"
raise ValueError(msg)
for joint, value, lower, upper in zip(
self.joint_names, positions_rad, self.lower_limits_rad, self.upper_limits_rad
):
if value < lower or value > upper:
msg = f"{joint} position {value:.3f} rad outside [{lower:.3f}, {upper:.3f}]"
raise ValueError(msg)
|