feathersdk.robot.actuators.damiao.utils Module¶
- feathersdk.robot.actuators.damiao.utils.write_json_file(data, file_path, *, perms=None, indent=2)¶
Atomically serialize
dataas JSON tofile_path.Uses
feathersdk.utils.files.thread_safe_file_writer()so the file is written to a temporary location and renamed in place, avoiding partial writes if the process is interrupted.
- feathersdk.robot.actuators.damiao.utils.read_json_file(file_path)¶
Read and parse a JSON file at
file_path.
- feathersdk.robot.actuators.damiao.utils.uint_to_float(x_int, x_min, x_max, bits)¶
Converts unsigned int to float, given range and number of bits.
- feathersdk.robot.actuators.damiao.utils.float_to_uint(x, x_min, x_max, bits)¶
Converts a float to an unsigned int, given range and number of bits.
- class feathersdk.robot.actuators.damiao.utils.MotorConstants(POSITION_MAX: float = 12.5, POSITION_MIN: float = -12.5, VELOCITY_MAX: float = 45, VELOCITY_MIN: float = -45, TORQUE_MAX: float = 54, TORQUE_MIN: float = -54, CURRENT_MAX: float = 1.0, CURRENT_MIN: float = -1.0, KT: float = 1.0, KP_MAX: float = 500.0, KP_MIN: float = 0.0, KD_MAX: float = 5.0, KD_MIN: float = 0.0)¶
Bases:
object- Parameters:
- class feathersdk.robot.actuators.damiao.utils.MotorInfo(id, error_code, target_torque=0, vel=0.0, eff=0, pos=0, voltage=-1, temp_mos=-1, temp_rotor=-1)¶
Bases:
objectClass to represent motor information.
- Variables:
- Parameters:
- class feathersdk.robot.actuators.damiao.utils.FeedbackFrameInfo(id: int, error_code: int, error_message: str, position: float, velocity: float, torque: float, temperature_mos: float, temperature_rotor: float)¶
Bases:
object- Parameters:
- class feathersdk.robot.actuators.damiao.utils.EncoderInfo¶
Bases:
object- encoder = -1¶
- encoder_raw = -1¶
- encoder_offset = -1¶
- class feathersdk.robot.actuators.damiao.utils.MotorErrorCode¶
Bases:
object- disabled = 0¶
- normal = 1¶
- over_voltage = 8¶
- under_voltage = 9¶
- over_current = 10¶
- mosfet_over_temperature = 11¶
- motor_over_temperature = 12¶
- loss_communication = 13¶
- overload = 14¶
- motor_error_code_dict = {0: 'disabled', 1: 'normal', 8: 'over voltage', 9: 'under voltage', 10: 'over current', 11: 'mosfet over temperature', 12: 'motor over temperature', 13: 'loss communication', 14: 'overload'}¶
- class feathersdk.robot.actuators.damiao.utils.MotorType¶
Bases:
object- DM4310 = 'DM4310'¶
- class feathersdk.robot.actuators.damiao.utils.ReceiveMode(value)¶
Bases:
AutoNameEnum- p16 = 'p16'¶
- same = 'same'¶
- zero = 'zero'¶
- plus_one = 'plus_one'¶
- class feathersdk.robot.actuators.damiao.utils.RawCanInterface(channel='PCAN_USBBUS1', bustype='pcan', bitrate=1000000, name='default_can_interface')¶
Bases:
object- close()¶
Shut down the CAN bus.
- Return type:
None
- feathersdk.robot.actuators.damiao.utils.bytes_to_uint32(data)¶
Convert the last 4 bytes (data[4:8]) in a bytearray to uint32 (little-endian).
- feathersdk.robot.actuators.damiao.utils.bytes_to_float32(data)¶
Convert the last 4 bytes (data[4:8]) in a bytearray to float32 (little-endian).
- feathersdk.robot.actuators.damiao.utils.uint32_to_bytes(value)¶
Convert a uint32 value to a 4-byte bytearray (little-endian).
- feathersdk.robot.actuators.damiao.utils.float32_to_bytes(value)¶
Convert a float32 value to a 4-byte bytearray (little-endian).
- feathersdk.robot.actuators.damiao.utils.get_special_message_response(can_interface, motor_id, reg_name)¶
Get the current value of a register from a motor.
- Parameters:
can_interface (RawCanInterface) – The CAN interface to use.
motor_id (int) – The ID of the motor to read the register value from.
reg_name (str) – The name of the register to read.
- Returns:
The value read from the register.
- Return type:
Any
- feathersdk.robot.actuators.damiao.utils.write_special_message(can_interface, motor_id, reg_name, data)¶
Write a value to a register of a motor.
- Parameters:
can_interface (RawCanInterface) – The CAN interface to use.
motor_id (int) – The ID of the motor to write the register value for.
reg_name (str) – The name of the register to write.
data (Any) – The value to write to the register.
- Returns:
The value read from the register after writing.
- Return type:
Any
- feathersdk.robot.actuators.damiao.utils.save_to_memory(can_interface, motor_id, reg_name)¶
Save the current value of a register to the motor’s memory.
- Parameters:
can_interface (RawCanInterface) – The CAN interface to use.
motor_id (int) – The ID of the motor to save the register value for.
reg_name (str) – The name of the register to save.
- Returns:
The response message from the motor.
- Return type:
can.Message