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 6 joint motors on the O6 dexterous hand.

  • Torque range: 0-100 (unitless percentage)
  • Maximum current: 1657.5 mA at value 100

Set Torque

from realhand import O6
from realhand.hand.o6 import O6Torque

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

# Using an O6Torque object
torques = O6Torque(
    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.torque.set_torques(torques)

# Using mA values
torques = O6Torque.from_milliamps([800.0, 800.0, 1000.0, 1000.0, 1000.0, 1000.0])
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.o6 import SensorSource, TorqueEvent

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

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

hand.stop_polling()
hand.stop_stream()

mA Conversion

O6 supports conversion between torque values and current values in mA.

Create from mA

from realhand.hand.o6 import O6Torque

# Create from mA values (range 0-1657.5 mA)
torques = O6Torque.from_milliamps([800.0, 800.0, 1000.0, 1000.0, 1200.0, 1200.0])
print(f"Normalized values: {torques.to_list()}")  # Converted to the 0-100 range

Convert to mA

torques = O6Torque(50.0, 50.0, 50.0, 50.0, 50.0, 50.0)
ma_values = torques.to_milliamps()
print(f"mA values: {ma_values}")  # [828.75, 828.75, ...]

Complete Example

from realhand import O6
from realhand.hand.o6 import O6Torque

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

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

    # Set torque using mA
    torques = O6Torque.from_milliamps([1000.0] * 6)
    hand.torque.set_torques(torques)