Speed Control
Use hand.speed to control and read the motion speed of each joint motor on the L20Lite dexterous hand.
- Speed range: 0-100
- Unit: Unitless, mapped to actual motor speed
Set Speed
from realhand import L20lite
from realhand.hand.l20lite import L20liteSpeed
# Using a list
hand.speed.set_speeds([50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0])
# Using an L20liteSpeed object
speeds = L20liteSpeed(
thumb_flex=30.0, # Thumb flexion
thumb_abd=30.0, # Thumb abduction
index_flex=80.0, # Index flexion
middle_flex=80.0, # Middle flexion
ring_flex=80.0, # Ring flexion
pinky_flex=80.0, # Pinky flexion
index_abd=50.0, # Index abduction
ring_abd=50.0, # Ring abduction
pinky_abd=50.0, # Pinky abduction
thumb_yaw=50.0, # Thumb rotation
)
hand.speed.set_speeds(speeds)
Read Speed
Blocking Read
from realhand.exceptions import TimeoutError
try:
data = hand.speed.get_blocking(timeout_ms=500)
print(f"Thumb flexion speed: {data.speeds.thumb_flex}")
print(f"All speeds: {data.speeds.to_list()}")
except TimeoutError:
print("Read timed out")
Cached Read
data = hand.speed.get_snapshot()
if data:
print(f"Speed: {data.speeds.to_list()}")
print(f"Timestamp: {data.timestamp}")
Streaming Read
Receive all sensor events through the top-level hand.stream() interface:
from realhand.hand.l20lite import SensorSource, SpeedEvent
hand.start_polling({SensorSource.SPEED: 0.1})
try:
for event in hand.stream():
match event:
case SpeedEvent(data=data):
print(f"Speed: {data.speeds.to_list()}")
finally:
hand.stop_polling()
hand.stop_stream()
Complete Example
from realhand import L20lite
from realhand.hand.l20lite import L20liteSpeed
with L20lite(side="left", interface_name="can0") as hand:
# Thumb slow, other fingers fast
speeds = L20liteSpeed(
thumb_flex=20.0,
thumb_abd=20.0,
index_flex=80.0,
middle_flex=80.0,
ring_flex=80.0,
pinky_flex=80.0,
index_abd=60.0,
ring_abd=60.0,
pinky_abd=60.0,
thumb_yaw=60.0,
)
hand.speed.set_speeds(speeds)
# Read current speed
data = hand.speed.get_blocking(timeout_ms=500)
print(f"Current speed: {data.speeds.to_list()}")
# Observe the effect after setting angles
hand.angle.set_angles([100.0] * 10)