Files
Lumi/tests/test_gripper.py
T

11 lines
760 B
Python
Raw Normal View History

2026-10-21 15:19:07 +09:00
"""Self-check of robot/gripper.py's finger gap from AI_1 (no robot): python tests/test_gripper.py"""
import no_robot # noqa: F401 any connection to the robot fails the test
2026-10-21 15:19:07 +09:00
from robot import gripper as g
assert g.gap_mm(g.AI_OPEN) == 94.0 and g.gap_mm(g.AI_SHUT) == 68.0 # belly, open / closed (tape)
assert g.gap_mm(50) == 94.0 and g.gap_mm(5000) == 68.0 # readings past the ends are clamped
assert abs(g.gap_mm((g.AI_OPEN + g.AI_SHUT) / 2) - 81.0) < 0.01 # linear between
assert g.gap_mm(g.AI_SHUT, "tips") == 63.0 and g.gap_mm(g.AI_OPEN, "shank") == 66.0
2026-10-21 15:19:07 +09:00
assert all(hasattr(g, n) for n in ("MOVE_S", "SENSOR_DI", "READ_TRIES", "READ_GAP_S", "CLOSED_AI", "EMPTY_AI"))
print("gripper ok")