This page focuses on error handling and diagnostics:
get_hardware_error_coderegister_hardware_error_event_callbackget_hardware_error_codefrom dexcelbot_apexhand_sdk import DexcelBot, ErrorCode
bot = DexcelBot()
# ... connect ...
code = bot.get_hardware_error_code()
if code == ErrorCode.ERROR_CODE_OK:
print("No hardware error")
elif code == ErrorCode.ERROR_CODE_OTHER_ERROR:
print("Hardware error detected, check callbacks or logs for details")
else:
print("get_hardware_error_code failed with:", code)
ERROR_CODE_OK: no hardware error.ERROR_CODE_OTHER_ERROR: some hardware error is present; inspect error callbacks and logs for details.from dexcelbot_apexhand_sdk import (
DexcelBot,
HardwareErrorCodes,
ErrorCode,
)
bot = DexcelBot()
# ... connect ...
def on_hardware_error(err: HardwareErrorCodes):
# Structure fields are defined by the native SDK
print("Device error code:", err.device_error)
print("Finger error codes:", err.finger_errors)
result = bot.register_hardware_error_event_callback(on_hardware_error)
if result != ErrorCode.ERROR_CODE_OK:
raise RuntimeError("Failed to register hardware error callback")
# ... run task ...
bot.unregister_hardware_error_event_callback()
When the firmware detects hardware issues (over‑current, sensor faults, etc.), the SDK invokes this callback with a HardwareErrorCodes structure.
To explore the available fields, use
help(HardwareErrorCodes)ordir(HardwareErrorCodes())in a Python REPL.
A common pattern is to:
from dexcelbot_apexhand_sdk import (
DexcelBot,
MotorStates,
HardwareErrorCodes,
ErrorCode,
)
bot = DexcelBot()
# ... connect ...
def on_motor_states(states: MotorStates):
for m in states.motors:
if m.temperature > 70.0:
print("[Soft monitor] Motor overheating:", m.motor_id, m.temperature)
def on_hardware_error(err: HardwareErrorCodes):
print("[Firmware error] Device code:", err.device_error)
print("[Firmware error] Finger codes:", err.finger_errors)
bot.register_motor_states_callback(on_motor_states, freq_hz=20)
bot.register_hardware_error_event_callback(on_hardware_error)
# ... run task ...
bot.unregister_motor_states_callback()
bot.unregister_hardware_error_event_callback()
from dexcelbot_apexhand_sdk import DexcelBot, ErrorCode
bot = DexcelBot()
result = bot.set_log_path("./logs")
if result != ErrorCode.ERROR_CODE_OK:
print("Failed to set log path:", result)
else:
print("SDK logs will be written to ./logs")
Notes:
from dexcelbot_apexhand_sdk import DexcelBot
bot = DexcelBot()
bot.enable_logging(True) # enable logging
# ... run task ...
bot.enable_logging(False) # disable when no longer needed
When an error is detected:
move_joint, servo callbacks, etc.).get_hardware_error_code() to confirm the error state.clean_faults() to try clearing the fault.from dexcelbot_apexhand_sdk import DexcelBot, ErrorCode
bot = DexcelBot()
code = bot.get_hardware_error_code()
if code == ErrorCode.ERROR_CODE_OTHER_ERROR:
print("Hardware error detected, trying to clear...")
clr = bot.clean_faults()
if clr == ErrorCode.ERROR_CODE_OK:
print("Fault cleared. You can re‑apply conservative limits and retry if appropriate.")
else:
print("Failed to clear fault. Stop usage and export logs for analysis.")
With the mechanisms above you can build a robust safety and diagnostics layer around your ApexHand applications.