Skip to content

brian.motors.motor_types

brian.motors

DeviceClass class objects

class DeviceClass(Enum)

Device detected on a motor port using only ADC readings. Valid only when the port mode is not POWER_OFF.

NONE

No device is detected

ERROR

Some device was detected, but it is not clear which

EV3_ANALOG_MOTOR

NXT/EV3 motor was detected; the device type contains the ID

EV3_UART_DEVICE

Unknown EV3 UART device was detected; further active probing is needed

DeviceType class objects

class DeviceType(Enum)

More detailed type of a device detected as DeviceClass.EV3_ANALOG_MOTOR.

UNKNOWN

Motor type is not known (yet)

NXT_EV3_LARGE_MOTOR

NXT or EV3 large motor (these are not distinguishable)

EV3_MEDIUM_MOTOR

EV3 medium motor

MotorType class objects

class MotorType()

Description of a supported motor type and its default control parameters.

name

@property
def name() -> str

Returns:

Human-readable name of the motor

identification

@property
def identification() -> 'Identification'

Returns:

What will Brian report as the ID when this motor is connected

default_constants

@property
def default_constants() -> 'DefaultConstants'

Returns:

Default controller configuration

default_acceleration_limit

@property
def default_acceleration_limit() -> int

Returns:

Acceleration limit a new Motor of this type starts with, in degrees per second squared

Identification class objects

class Identification()

Results of auto-detection

device_type

@property
def device_type() -> 'DeviceType'

Returns:

More detailed device type

device_class

@property
def device_class() -> 'DeviceClass'

Returns:

Detected device class (portMode must not be POWER_OFF)

DefaultConstants class objects

class DefaultConstants()

Control loop parameters that are typically not changed much

motor

@property
def motor() -> 'Motor'

Returns:

Linear dynamic model of the motor

controller

@property
def controller() -> 'Controller'

Returns:

Constants of the position/speed controller

observer

@property
def observer() -> 'Observer'

Returns:

Configuration of the state observer

Motor class objects

class Motor()

Linear dynamic model of the connected motor. This model can be used for estimating various internal states of the motor.

Kt_NmPerA

@property
def Kt_NmPerA() -> float

Returns:

Torque constant, in N*m/A

Kb_VPerRadPerSec

@property
def Kb_VPerRadPerSec() -> float

Returns:

Torque constant in V/(rad/sec)

B_NmPerRadPerSec

@property
def B_NmPerRadPerSec() -> float

Returns:

Friction constant, in N*m/(rad/sec)

Udeadzone_Volts

@property
def Udeadzone_Volts() -> float

Returns:

Voltage needed to make the motor moves

R_Ohm

@property
def R_Ohm() -> float

Returns:

Armature resistance, in ohms

L_Henry

@property
def L_Henry() -> float

Returns:

Armature inductance, in henry

Cp_Farad

@property
def Cp_Farad() -> float

Returns:

Capacity of a EMI-eliminating capacitor across motor terminals, in farads

ticksPerRevolution

@property
def ticksPerRevolution() -> float

Returns:

Number of encoder ticks per one revolution.

Controller class objects

class Controller()

Constants of the position/speed controller Brian implements these two controllers: - a parallel-form 2-degrees-of-freedom PI controller for motor speed 1, and - a cascaded P controller for motor position.

speedKp

@property
def speedKp() -> float

Returns:

Proportional constant of the speed PI controller

speedKi

@property
def speedKi() -> float

Returns:

Integral constant of the speed PI controller

speedBeta

@property
def speedBeta() -> float

Returns:

Setpoint weight in the proportional branch of the PI controller (see 1)

positionKp

@property
def positionKp() -> float

Returns:

Proportional constant of the cascaded position P controller (its output is target speed in ticks/s)

positionToleranceTicks

@property
def positionToleranceTicks() -> int

Returns:

Tolerate up to this deviation with zero output (needed for EV3 medium motor)

Observer class objects

class Observer()

Additional configuration of state observer.

current

@property
def current() -> 'Current'

Current

speed

@property
def speed() -> 'Speed'

Speed

Current class objects

class Current()

Current observer parameters. Brian has to estimate motor winding current from H-bridge current measurements. These are not equal (PWM=0 makes the winding current impossible to directly measure). The way it does so is by simulating the current response using the provided model and then correcting the predicted value using real measurements (when they're available).

measurementWeight_pct

@property
def measurementWeight_pct() -> int

Returns:

Correction step: How much weight to give to measurements vs. model prediction

minimumPwmOnTime_pct

@property
def minimumPwmOnTime_pct() -> int

Returns:

Only trust measurements if the PWM has at least this duty cycle

Speed class objects

class Speed()

Speed tracking loop parameters Brian estimates motor speed using a tracking loop/observer inspired by figure 3 and equations (6) in 2. These constants specify the parameters of the loop.

Kp

@property
def Kp() -> int

Returns:

Proportional gain of the speed tracking loop

Ki

@property
def Ki() -> int

Returns:

Integral gain of the speed tracking loop