File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/reachy_mini/daemon/backend/robot Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 77
88import json
99import logging
10+ import struct
1011import time
1112from dataclasses import dataclass
1213from datetime import timedelta
@@ -512,13 +513,30 @@ def decode_hardware_error_byte(err_byte: int) -> list[str]:
512513 err_bits = [i for i in range (8 ) if (err_byte & (1 << i )) != 0 ]
513514 return [bits_to_error [b ] for b in err_bits if b in bits_to_error ]
514515
516+ def check_voltage (
517+ id : int ,
518+ allowed_max_voltage : float = 7.3 ,
519+ ) -> bool :
520+ assert self .c is not None , (
521+ "Motor controller not initialized or already closed."
522+ )
523+ # https://emanual.robotis.com/docs/en/dxl/x/xl330-m288/#present-input-voltage
524+ resp_bytes = self .c .async_read_raw_bytes (id , 144 , 2 )
525+ resp = struct .unpack ("h" , bytes (resp_bytes ))[0 ]
526+ voltage : float = resp / 10.0 # in Volts
527+
528+ return voltage > allowed_max_voltage
529+
515530 errors = {}
516531 for name , id in self .c .get_motor_name_id ().items ():
517532 # https://emanual.robotis.com/docs/en/dxl/x/xl330-m288/#hardware-error-status
518533 err_byte = self .c .async_read_raw_bytes (id , 70 , 1 )
519534 assert len (err_byte ) == 1
520535 err = decode_hardware_error_byte (err_byte [0 ])
521536 if err :
537+ if "Input Voltage Error" in err :
538+ if check_voltage (id ):
539+ err .remove ("Input Voltage Error" )
522540 errors [name ] = err
523541
524542 return errors
You can’t perform that action at this time.
0 commit comments