firmware.bionic_motors package

Subpackages

Submodules

firmware.bionic_motors.commands module

Defines firmware commands for the bionic MyActuator motors.

firmware.bionic_motors.commands.debug(command)[source]
Return type:

List[str]

firmware.bionic_motors.commands.force_position_hybrid_control(kp, kd, position, speed, torque_ff)[source]

Gets the command to set the position of a motor using PD control. Expect 8 bytes.

Parameters:
  • kp (float) – The proportional gain. No load default is 15

  • kd (float) – The derivative gain. No load default is 0.5

  • position (float) – The position to set the motor to, in degrees.

  • speed (float) – The speed to set the motor to, in rpm.

  • torque_ff (int) – The feedforward torque in Nm.

Return type:

List[int]

Returns:

The command to set the position of a motor using PD control.

firmware.bionic_motors.commands.get_motor_current()[source]

Gets the motor Position of a respective motor.

Parameters:

motor_id – The ID of the motor.

Return type:

List[int]

Returns:

The respective motor current draw

firmware.bionic_motors.commands.get_motor_pos()[source]

Gets the motor Position of a respective motor.

Parameters:

motor_id – The ID of the motor.

Return type:

List[int]

Returns:

The respective motor position

firmware.bionic_motors.commands.get_motor_power()[source]

Gets power consumption of a respective motor.

Parameters:

motor_id – The ID of the motor.

Return type:

List[int]

Returns:

The respective motor power consumption

firmware.bionic_motors.commands.get_motor_speed(motor_id)[source]

Gets the motor Position of a respective motor.

Parameters:

motor_id (int) – The ID of the motor.

Return type:

List[int]

Returns:

The respective motor speed.

firmware.bionic_motors.commands.push_bits(value, data, num_bits)[source]
Return type:

int

firmware.bionic_motors.commands.push_fp32_bits(value, data)[source]
Return type:

int

firmware.bionic_motors.commands.set_current_torque_control(motor_id, value, control_status=0, motor_mode=3, message_return=0)[source]

Gets the command to set the current OR torque of a motor. Expect 3 bytes.

Parameters:
  • motor_id (int) – The ID of the motor.

  • motor_mode (int) – 0x3 for current control.

  • value (int) – The current (A) or torque (N*m) to set the motor to, x10. (int16, not uint16)

  • message_return (Literal[0, 1, 2, 3]) – The message return status.

  • control_status (Literal[0, 1, 2, 3, 4, 5, 6, 7]) – 0x0 for current control, 0x1 for torque control. See page 18-19 of X12-150 manual for more options.

Return type:

List[int]

Returns:

The command to set the current of a motor.

firmware.bionic_motors.commands.set_position_control(motor_id, position, motor_mode=1, max_speed=60.0, max_current=5.0, message_return=0)[source]

Gets the command to set the position of a motor. Expect 8 bytes.

Parameters:
  • motor_id (int) – The ID of the motor.

  • motor_mode (int) – 0x1 for servo position control.

  • position (float) – The position to set the motor to.

  • max_speed (float) – The maximum speed of the motor, in rotations per minute.

  • max_current (float) – The maximum current of the motor, in amps.

  • message_return (Literal[0, 1, 2, 3]) – The message return status.

Return type:

List[int]

Returns:

The command to set the position of a motor.

firmware.bionic_motors.commands.set_speed_control(motor_id, speed, motor_mode=2, current=5.0, message_return=0)[source]

Gets the command to set the speed of a motor. Expect 7 bytes.

Parameters:
  • motor_id (int) – The ID of the motor.

  • motor_mode (int) – 0x2 for speed control.

  • speed (float) – The speed to set the motor to, in rotations per minute.

  • current (float) – The current of the motor, in amps. 0 to 65536 corresponds to 0 to 6553.6 A.

  • message_return (Literal[0, 1, 2, 3]) – The message return status.

Return type:

List[int]

Returns:

The command to set the speed of a motor.

firmware.bionic_motors.commands.set_zero_position(motor_id)[source]

Gets the command to set the zero position of a motor. Expect 4 bytes.

Parameters:

motor_id (int) – The ID of the motor.

Return type:

List[int]

Returns:

The command to set the zero position of a motor.

firmware.bionic_motors.commands.split_into_bytes(command, length=8, little_endian=True)[source]
Return type:

List[int]

firmware.bionic_motors.model module

Defines the motor model but with bionic motors instead.

class firmware.bionic_motors.model.Arm(rotator_cuff, shoulder, bicep, elbow, wrist, gripper)[source]

Bases: object

bicep: BionicMotor
elbow: BionicMotor
gripper: BionicMotor
hold_position(position, timeout=2.0)[source]
Return type:

None

property motor_ids: list[int]
property motors: list[BionicMotor]
rotator_cuff: BionicMotor
set_position_incremental(increments, target_vals, thresholds)[source]
Return type:

None

shoulder: BionicMotor
wrist: BionicMotor
class firmware.bionic_motors.model.Body(left_arm=None, right_arm=None, left_leg=None, right_leg=None)[source]

Bases: object

left_arm: Optional[Arm] = None
left_leg: Optional[Leg] = None
property motor_ids: list[int]
right_arm: Optional[Arm] = None
right_leg: Optional[Leg] = None
class firmware.bionic_motors.model.Leg(pelvis, hip, thigh, knee, ankle, foot)[source]

Bases: object

ankle: BionicMotor
foot: BionicMotor
hip: BionicMotor
hold_position(position, timeout=2.0)[source]
Return type:

None

knee: BionicMotor
property motor_ids: list[int]
property motors: list[BionicMotor]
pelvis: BionicMotor
set_position_incremental(increments, target_vals, thresholds)[source]
Return type:

None

thigh: BionicMotor

firmware.bionic_motors.motors module

Defines a class that dictates how to communicate with the motors.

class firmware.bionic_motors.motors.BionicMotor(motor_id, control_params, can_bus)[source]

Bases: MotorInterface

A class to interface with a motor over a CAN bus.

calibrate(current_limit)[source]

Calibrates motor assuming the existence of hard stops.

TODO: Implement calibration method.

Parameters:

current_limit (float) – The current limit to use for calibration.

Return type:

None

can_messages: List[Any] = []
get_position()[source]

Gets the current position of the motor.

Return type:

float

get_speed()[source]

Gets the current speed of the motor.

Return type:

float

read(timeout=0.001, read_data_only=True)[source]

Generic read can bus method that reads messages from the can bus.

Parameters:
  • timeout (float) – how long to read messages for in seconds

  • read_data_only (bool) – whether to read only data that has been queried. If true, only type 5 messages are read.

Return type:

None

send(can_id, data, length=8)[source]

Sends a CAN message to a motor.

Parameters:
  • can_id (int) – The motor ID.

  • data (bytes) – The data to send.

  • length (int) – The length of the data.

Return type:

None

set_current(current)[source]

Sets the current of the motor.

Parameters:

current (float) – The current to set the motor to (in A)

Return type:

None

set_position(position, **kwargs)[source]

Sets the position of the motor using force position hybrid control.

Parameters:
  • position (float) – The position to set the motor to (in degrees)

  • kwargs (Any) – Additional arguments to pass to the motor. (speed in rpm, torque in Nm)

Return type:

None

set_zero_position()[source]

Sets the zero position of the motor.

Return type:

None

update_position(wait_time=0.001)[source]

Updates the value of the motor’s position attribute.

NOTE: Do NOT use this to access the motor’s position value.

Just use <motor>.position instead.

Parameters:
  • wait_time (float) – how long to wait for a response from the motor

  • read_only – whether to read the position value or not

Return type:

None

update_speed(wait_time=0.001)[source]

Updates the value of the motor’s speed attribute.

NOTE: Do NOT use this to access the motor’s speed value.

Just use <motor>.speed instead.

Parameters:
  • wait_time (float) – how long to wait for a response from the motor

  • read_only – whether to read the speed value or not

Return type:

str

Returns:

“Valid” if the message is valid, “Invalid” otherwise

class firmware.bionic_motors.motors.CANInterface(bus, channel, bustype)[source]

Bases: object

bus: Any
bustype: Notifier
channel: BufferedReader
class firmware.bionic_motors.motors.CanMessage(id, data)[source]

Bases: object

data: Any
id: int
class firmware.bionic_motors.motors.ControlParams(kp, kd)[source]

Bases: MotorParams

kd: float
kp: float

firmware.bionic_motors.responses module

Takes in responses from the Q&A return type and interprets them.

firmware.bionic_motors.responses.configuration_message(msg)[source]

Message Type 4.

Interprets the message type 4 and returns a list of the results

Parameters:

msg (bytes) – bytes: The message to interpret

Return type:

dict

Returns:

dictionary of the message results

firmware.bionic_motors.responses.custom_message(msg)[source]

Message Type 5.

Interprets the message type 5 and returns a list of the results :type msg: bytes :param msg: bytes: The message to interpret.

Return type:

dict

Returns:

dictionary of the message results

firmware.bionic_motors.responses.get_message_type(msg)[source]

Returns the message type of the message.

Return type:

int

firmware.bionic_motors.responses.position_message(msg)[source]

Message Type 2.

Interprets the message type 2 and returns a list of the results

Parameters:

msg (bytes) – bytes: The message to interpret

Return type:

dict

Returns:

dictionary of the message results

firmware.bionic_motors.responses.position_speed_message(msg)[source]

Message Type 1.

Interprets the message type 1 and returns a list of the results

Parameters:

msg (bytes) – bytes: The message to interpret

Return type:

dict

Returns:

dictionary of the message results

firmware.bionic_motors.responses.read_result(msg)[source]

Reads the result of the message and returns a list of the results regardless of Message Type.

Parameters:

msg (bytes) – bytes: The message to interpret

Return type:

Optional[Dict]

Returns:

dictionary of the message results

firmware.bionic_motors.responses.speed_message(msg)[source]

Message Type 3.

Interprets the message type 3 and returns a list of the results

Parameters:

msg (bytes) – bytes: The message to interpret

Return type:

dict

Returns:

dictionary of the message results

firmware.bionic_motors.responses.valid_message(msg)[source]

Checks if the message is valid by checking the message type.

Parameters:

msg (bytes) – bytes: The message to check

Returns:

True if the message is valid, False otherwise

Return type:

bool

firmware.bionic_motors.utils module

Example driver file on instantiating new motors and driving them.

class firmware.bionic_motors.utils.ViolenceStrength(ARM_PARAMS, ARM_PARAMS_HEAVY, GRIPPERS_PARAMS, LEG_PARAMS, LEG_PARAMS_HEAVY)[source]

Bases: object

A class to dictate the strength of the violence.

ARM_PARAMS: ControlParams
ARM_PARAMS_HEAVY: ControlParams
GRIPPERS_PARAMS: ControlParams
LEG_PARAMS: ControlParams
LEG_PARAMS_HEAVY: ControlParams

Module contents