Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Angle Control

Use hand.angle to control and read the 6 joint motor angles of the L6 dexterous hand.

  • Angle range: 0-100
  • Unit: Unitless, mapped to actual joint motor angles

Set Angles

from realhand import L6
from realhand.hand.l6 import L6Angle

# Using a list
hand.angle.set_angles([50.0, 30.0, 60.0, 60.0, 60.0, 60.0])

# Using an L6Angle object
angles = L6Angle(
    thumb_flex=50.0,  # Thumb flexion
    thumb_abd=30.0,  # Thumb abduction
    index=60.0,  # Index finger
    middle=60.0,  # Middle finger
    ring=60.0,  # Ring finger
    pinky=60.0,  # Pinky
)
hand.angle.set_angles(angles)

Read Angles

Blocking Read

from realhand import L6
from realhand.exceptions import TimeoutError

try:
    data = hand.angle.get_blocking(timeout_ms=500)
    print(f"Thumb flexion: {data.angles.thumb_flex}")
    print(f"All angles: {data.angles.to_list()}")
except TimeoutError:
    print("Read timed out")

Cached Read

data = hand.angle.get_snapshot()
if data:
    print(f"Angles: {data.angles.to_list()}")
    print(f"Timestamp: {data.timestamp}")

Streaming Read

Receive all sensor events through the top-level hand.stream() interface:

from realhand.hand.l6 import SensorSource, AngleEvent

hand.start_polling({SensorSource.ANGLE: 0.1})

for event in hand.stream():
    match event:
        case AngleEvent(data=data):
            print(f"Angles: {data.angles.to_list()}")

hand.stop_polling()
hand.stop_stream()

Complete Example

from realhand import L6

with L6(side="left", interface_name="can0") as hand:
    # Set angles
    hand.angle.set_angles([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

    # Read current angles
    data = hand.angle.get_blocking(timeout_ms=500)
    print(f"Current angles: {data.angles.to_list()}")

    # Incremental motion
    for i in range(0, 101, 10):
        hand.angle.set_angles([float(i)] * 6)