Temperature Reading
Overview
Use hand.temperature to read the temperature data of the 6 L6 joint motors in °C.
Temperature fields
| Field | Description |
|---|---|
thumb_flex | Thumb flexion motor |
thumb_abd | Thumb abduction motor |
index | Index finger motor |
middle | Middle finger motor |
ring | Ring finger motor |
pinky | Pinky motor |
Read Temperature
Blocking Read
data = hand.temperature.get_blocking(timeout_ms=500)
print(f"Thumb temperature: {data.temperatures.thumb_flex}°C")
Parameter
timeout_ms: Timeout in milliseconds, default100
Return value
TemperatureData: Containstemperaturesandtimestamp
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
TemperatureDataorNoneif no cached data is available
Streaming Read
Receive all sensor events through the top-level hand.stream() interface:
from realhand.hand.l6 import SensorSource, TemperatureEvent
hand.start_polling({SensorSource.TEMPERATURE: 0.1})
for event in hand.stream():
match event:
case TemperatureEvent(data=data):
print(f"Temperature: {data.temperatures.to_list()}")
hand.stop_polling()
hand.stop_stream()
Examples
Read All Joint Temperatures
from realhand import L6
with L6(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 finger: {data.temperatures.index}°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 L6
from realhand.hand.l6 import SensorSource, TemperatureEvent
with L6(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()