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

Torque Control

Use hand.torque to control and read the torque of the 10 joint motors on the L20Lite dexterous hand.

  • Torque range: 0-100
  • Unit: Unitless percentage

Set Torque

from realhand import L20lite
from realhand.hand.l20lite import L20liteTorque

# Using a list
hand.torque.set_torques([50.0, 50.0, 60.0, 60.0, 60.0, 60.0, 30.0, 30.0, 30.0, 30.0])

# Using an L20liteTorque object
torques = L20liteTorque(
    thumb_flex=50.0,  # Thumb flexion
    thumb_abd=50.0,  # Thumb abduction
    index_flex=60.0,  # Index flexion
    middle_flex=60.0,  # Middle flexion
    ring_flex=60.0,  # Ring flexion
    pinky_flex=60.0,  # Pinky flexion
    index_abd=30.0,  # Index abduction
    ring_abd=30.0,  # Ring abduction
    pinky_abd=30.0,  # Pinky abduction
    thumb_yaw=30.0,  # Thumb rotation
)
hand.torque.set_torques(torques)

Read Torque

Blocking Read

from realhand.exceptions import TimeoutError

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

Cached Read

data = hand.torque.get_snapshot()
if data:
    print(f"Torque: {data.torques.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, TorqueEvent

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

try:
    for event in hand.stream():
        match event:
            case TorqueEvent(data=data):
                print(f"Torque: {data.torques.to_list()}")
finally:
    hand.stop_polling()
    hand.stop_stream()

Complete Example

from realhand import L20lite
from realhand.hand.l20lite import L20liteTorque

with L20lite(side="left", interface_name="can0") as hand:
    # Set torque
    hand.torque.set_torques([50.0] * 10)

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

    # Fine-grained control with the data class
    torques = L20liteTorque(
        thumb_flex=70.0,
        thumb_abd=70.0,
        index_flex=50.0,
        middle_flex=50.0,
        ring_flex=50.0,
        pinky_flex=50.0,
        index_abd=40.0,
        ring_abd=40.0,
        pinky_abd=40.0,
        thumb_yaw=40.0,
    )
    hand.torque.set_torques(torques)