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

Fault Handling

Fault detection for the L20Lite dexterous hand.

Overview

Use hand.fault to access fault-related functionality:

  • Read fault status in blocking or cached mode

Fault Code Table

Fault codeValueDescription
NONE0No fault
VOLTAGE_ABNORMAL1Overvoltage / undervoltage
ENCODER_ABNORMAL2Magnetic encoder abnormality
OVERTEMPERATURE4Overtemperature
OVERCURRENT8Overcurrent
OVERLOAD32Overload

Read Faults

Blocking Read

from realhand.exceptions import TimeoutError

try:
    data = hand.fault.get_blocking(timeout_ms=500)
except TimeoutError:
    print("Read timed out")

Parameter:

  • timeout_ms: Timeout in milliseconds, default 100

Return value: FaultData, containing:

  • faults: L20liteFault fault data
  • timestamp: Timestamp

Exception:

  • TimeoutError: No response before timeout

Cached Read

data = hand.fault.get_snapshot()
if data:
    print(f"Has fault: {data.faults.has_any_fault()}")

Returns the latest cached fault data, or None if no data is available.

Fault Data

L20liteFault fields

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

L20liteFault methods

# Check whether any fault exists
faults.has_any_fault()  # -> bool

# Convert to a list
faults.to_list()  # -> list[FaultCode]

# Index access
faults[0]  # thumb_flex

FaultCode methods

# Check whether a single joint motor has a fault
faults.thumb_flex.has_fault()  # -> bool

# Get fault names
faults.thumb_flex.get_fault_names()  # -> list[str]

Examples

Check Fault Status

from realhand import L20lite

with L20lite(side="left", interface_name="can0") as hand:
    # Read fault status
    data = hand.fault.get_blocking(timeout_ms=500)

    if data.faults.has_any_fault():
        print("Fault detected:")
        if data.faults.thumb_flex.has_fault():
            print(f"  Thumb flexion: {data.faults.thumb_flex.get_fault_names()}")
        if data.faults.index_flex.has_fault():
            print(f"  Index flexion: {data.faults.index_flex.get_fault_names()}")
    else:
        print("No faults")

Iterate Through All Joint Faults

from realhand import L20lite

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

    if data.faults.has_any_fault():
        for i, code in enumerate(data.faults.to_list()):
            if code.has_fault():
                print(f"Joint {i} fault: {code.get_fault_names()}")