Controller
- class f28379d_drv8305_dual_comm.Controller(port=None, device_name=None, baud=115200)[source]
Communicate using serial with a f28379d used to control two motors through drv8305.
- set_control_mode(motor_no, mode)[source]
Set motor control mode.
- Parameters:
motor_no (int) – 1 or 2
mode (str) – Choose between ‘speed control’, ‘torque control’, ‘position control (speed)’, ‘position control (direct)’, ‘bang bang control’, and ‘impedance control’ modes
- set_max_torque(motor_no, torque)[source]
Set maximum torque in N m. Used in position control (speed), position control (direct), bang bang, and impedance control modes.
- Parameters:
motor_no (int) – 1 or 2
torque (float) – Torque in N m (max torque = 4.3 N m)
- set_speed(motor_no, speed)[source]
Set target speed. Used in speed control mode.
- Parameters:
motor_no (int) – 1 or 2
speed (float) – Rotational speed in rad/s (max speed = 30 rad/s)
- set_pos(motor_no, pos)[source]
Set target pos. Used in position control (speed), position control (direct), bang bang, and impedance control modes.
- Parameters:
motor_no (int) – 1 or 2
pos (float) – Target angle in radians
- set_current_measure_cutoff_freq(motor_no, freq)[source]
Set the cutoff frequency for iq current filter. Used when estimating motor torque from phase currents.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_torque_sensor_cutoff_freq(motor_no, freq)[source]
Set the cutoff frequency for torque sensor filter. Used when measuring torque from torque sensor.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_torque_sensor_scaling(motor_no, gradient)[source]
Set the gradient of torque sensor calibration curve. Used for calibrating torque sensor.
- Parameters:
motor_no (int) – 1 or 2
gradient (float) – gradient of torque sensor calibration line
- set_torque_sensor_offset(motor_no, offset)[source]
Set the offset of torque sensor calibration curve. Used for calibrating torque sensor.
- Parameters:
motor_no (int) – 1 or 2
offset (float) – offset of torque sensor calibration line
- set_direct_torque_p(motor_no, gain)[source]
Set P gain for direct torque control. Used to regulate motor torque to achieve sensor torque target.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Proportional gain
- set_direct_torque_i(motor_no, gain)[source]
Set I gain for direct torque control. Used to regulate motor torque to achieve sensor torque target.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Integral gain
- set_direct_torque_d(motor_no, gain)[source]
Set D gain for direct torque control. Used to regulate motor torque to achieve sensor torque target.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Derivative gain
- set_direct_torque_d_cutoff_freq(motor_no, freq)[source]
Set the derivative filter cutoff frequency (Hz) for direct torque control. Used to regulate motor torque to achieve sensor torque target.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_speed_p(motor_no, gain)[source]
Set P gain for speed control. Used in speed control and position control (speed) modes.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Proportional gain
- set_speed_i(motor_no, gain)[source]
Set I gain for speed control. Used in speed control and position control (speed) modes.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Integral gain
- set_speed_d(motor_no, gain)[source]
Set D gain for speed control. Used in speed control and position control (speed) modes.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Derivative gain
- set_speed_d_cutoff_freq(motor_no, freq)[source]
Set the derivative filter cutoff frequency (Hz) for speed control. Used in speed control and position control (speed) modes.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_hold_torque(motor_no, torque)[source]
Set constant torque. Used in torque control mode and impedance control with torque mode.
- Parameters:
motor_no (int) – 1 or 2
torque (float) – Torque in N m (max torque = 4.3 N m)
- set_pos_p(motor_no, gain)[source]
Set P gain for position control (speed). Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Proportional gain
- set_pos_i(motor_no, gain)[source]
Set I gain for position control (speed). Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Integral gain
- set_pos_d(motor_no, gain)[source]
Set D gain for position control (speed). Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Derivative gain
- set_pos_d_cutoff_freq(motor_no, freq)[source]
Set the derivative filter cutoff frequency (Hz) for position control (speed). Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_max_speed(motor_no, speed)[source]
Set maximum target speed for position control. Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
speed (float) – Rotational speed in rad/s (max speed = 30 rad/s)
- set_pos_p_direct(motor_no, gain)[source]
Set P gain for position control (direct). Used in position control (direct) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Proportional gain
- set_pos_i_direct(motor_no, gain)[source]
Set I gain for position control (direct). Used in position control (direct) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Integral gain
- set_pos_d_direct(motor_no, gain)[source]
Set D gain for position control (direct). Used in position control (direct) mode.
- Parameters:
motor_no (int) – 1 or 2
gain (float) – Derivative gain
- set_pos_d_direct_cutoff_freq(motor_no, freq)[source]
Set the derivative filter cutoff frequency (Hz) for position control (direct). Used in position control (speed) mode.
- Parameters:
motor_no (int) – 1 or 2
freq (float) – Cutoff frequency in Hz
- set_bang_bang_torque(motor_no, torque)[source]
Set constant torque in bang-bang control. Used in bang-bang control mode.
- Parameters:
motor_no (int) – 1 or 2
torque (float) – Torque in N m (max torque = 4.3 N m)
- set_bang_bang_deadband(motor_no, deadband)[source]
Set deadband in radians in bang-bang control. Used in bang-bang control mode.
- Parameters:
motor_no (int) – 1 or 2
deadband (float) – Deadband in radians
- set_inertia(motor_no, inertia)[source]
Set rotational inertia. Used in impedance control mode.
- Parameters:
motor_no (int) – 1 or 2
inertia (float) – Inertia
- set_damping(motor_no, damping)[source]
Set rotational damping. Used in impedance control mode.
- Parameters:
motor_no (int) – 1 or 2
damping (float) – Damping
- set_stiffness(motor_no, stiffness)[source]
Set rotational stiffness. Used in impedance control mode.
- Parameters:
motor_no (int) – 1 or 2
stiffness (float) – Stiffness
- set_zero_angle(motor_no)[source]
Set zero angle. Used in position control (speed), position control (direct), bang bang, and impedance control modes.
- Parameters:
motor_no (int) – 1 or 2
- set_match_other_position(motor_no)[source]
Set motor target position to current position of the other motor.
- Parameters:
motor_no (int) – 1 or 2
- unset_match_other_position(motor_no)[source]
Unset motor target position to current position of the other motor.
- Parameters:
motor_no (int) – 1 or 2
- set_friction_torque(motor_no, torque)[source]
Torque value for friction compensation.
- Parameters:
motor_no (int) – 1 or 2
torque (float) – Friction compensation torque in N m
- set_friction_vel_tolerance(motor_no, vel_tolerance)[source]
Velocity tolerance for friction compensation.
- Parameters:
motor_no (int) – 1 or 2
vel_tolerance (float) – Velocity in rad s-1
- set_direct_torque_on(motor_no)[source]
Set direct torque control on. (Adjust motor torque to target a torque sensor value)
- Parameters:
motor_no (int) – 1 or 2
- set_direct_torque_off(motor_no)[source]
Set direct torque control off. (Adjust motor torque to target a torque sensor value)
- Parameters:
motor_no (int) – 1 or 2
- set_callback(cb_func)[source]
Set callback function for when data from motors arrives. The data in the form of a dictionary will be pass to this function.
- Parameters:
cb_func (Callable[[dict], None]) – function with one argument
- get_from_queue()[source]
Data from motors are put into a read queue by default. To get data from motors, either read from this queue or set a callback function.
- get_pos(motor_no)[source]
Get current pos.
- Parameters:
motor_no (int) – 1 or 2
- Returns:
Current position in radians
- Return type:
float
- get_speed(motor_no)[source]
Get current speed.
- Parameters:
motor_no (int) – 1 or 2
- Returns:
Current speed in rad/s
- Return type:
float