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

Temperature Reading

Use hand.temperature to read the temperature of the 10 L20Lite joint motors in °C.

Temperature fields

FieldDescription
thumb_flexThumb flexion motor
thumb_abdThumb abduction motor
index_flexIndex flexion motor
middle_flexMiddle flexion motor
ring_flexRing flexion motor
pinky_flexPinky flexion motor
index_abdIndex abduction motor
ring_abdRing abduction motor
pinky_abdPinky abduction motor
thumb_yawThumb rotation motor

Read Temperature

Blocking Read

from realhand.exceptions import TimeoutError

try:
    data = hand.temperature.get_blocking(timeout_ms=500)
    print(f"Thumb flexion temperature: {data.temperatures.thumb_flex}°C")
except TimeoutError:
    print("Read timed out")

Parameter

  • timeout_ms: Timeout in milliseconds, default 100

Return value

  • TemperatureData: Contains temperatures (L20liteTemperature) and timestamp

Exception

  • TimeoutError: No response before timeout

Cached Read

Read the most recent cached temperature data without blocking.

data = hand.temperature.get_snapshot()
if data:
    print(f"Temperature: {data.temperatures.to_list()}")

Return value

  • TemperatureData or None if no cached data is available

Streaming Read

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

from realhand.hand.l20lite import SensorSource, TemperatureEvent

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

try:
    for event in hand.stream():
        match event:
            case TemperatureEvent(data=data):
                print(f"Temperature: {data.temperatures.to_list()}")
finally:
    hand.stop_polling()
    hand.stop_stream()

Examples

Read All Joint Temperatures

from realhand import L20lite

with L20lite(side="left", interface_name="can0") as hand:
    data = hand.temperature.get_blocking(timeout_ms=500)

    # Access by field
    print(f"Thumb flexion: {data.temperatures.thumb_flex}°C")
    print(f"Index flexion: {data.temperatures.index_flex}°C")

    # Convert to list
    temps = data.temperatures.to_list()
    print(f"All temperatures: {temps}")

    # Index access
    print(f"First joint motor: {data.temperatures[0]}°C")

Temperature Monitoring

from realhand import L20lite
from realhand.hand.l20lite import SensorSource, TemperatureEvent

with L20lite(side="left", interface_name="can0") as hand:
    hand.start_polling({SensorSource.TEMPERATURE: 0.1})

    try:
        for event in hand.stream():
            match event:
                case TemperatureEvent(data=data):
                    for i, temp in enumerate(data.temperatures.to_list()):
                        if temp > 60.0:
                            print(f"Warning: joint motor {i} is overheating ({temp}°C)")
    except KeyboardInterrupt:
        pass
    finally:
        hand.stop_polling()
        hand.stop_stream()