Skip to content

Drivetrain

The DriveTrain.java class provides a abstractoin layer upon the bare motors that power the drive train. It is built around a Mecanum drive and implement a full FDIR loop to detect motor failures.

Property Value
Package Path org.firstinspires.ftc.teamcode.systemsControls.DriveTrain
Type Utility / Subsystem
Argument Type Description
flName String name of the front-left drive motor
frName String name of the front-right drive motor
blName String name of the back-left drive motor
brName String name of the front-right drive motor
motorDirections Map directions of all the motors
maxMotorPower float Maximum power to supply to the motors
hardwareMap HardwareMap the opModes hardware map
follower Follower Reference to the follower used throughout TeleOp
public void moveWithFDIRPipeline(float x, float y, float rotation)

Commands drivetrain movement while running the Fault Detection, Isolation, and Recovery (FDIR) system.

The FDIR pipeline monitors drivetrain performance and attempts to detect failed or stalled motors. If a motor failure is detected, the drivetrain automatically changes behavior to maintain control when possible.

Name Type Description
x float Requested strafe movement.
y float Requested forward/backward movement.
rotation float Requested rotational movement.
Type Description
void Executes the drive command with fault monitoring enabled.

public void moveWithoutFDIR(float x, float y, float rotation)

Commands standard mecanum drivetrain movement without running fault detection.

This method should be used when motor failure detection is not required.

Name Type Description
x float Requested strafe movement.
y float Requested forward/backward movement.
rotation float Requested rotational movement.
Type Description
void Applies movement commands directly to the drivetrain.

public void setMotorPowerRaw(float fl, float fr, float bl, float br)

Directly sets power values for each individual drivetrain motor.

Power values are automatically clipped between -1 and 1.

Name Type Description
fl float Front-left motor power.
fr float Front-right motor power.
bl float Back-left motor power.
br float Back-right motor power.
Type Description
void Applies raw motor power values.

public void brake()

Stops all drivetrain motors.

Type Description
void Sets all motor powers to zero.

public void resetEncoders()

Resets all drivetrain motor encoders while restoring their previous run modes.

Type Description
void Resets drivetrain encoder positions.

public static void resetSingleMotorEncoder(DcMotorEx motor)

Resets the encoder of a single motor while preserving its previous run mode.

Name Type Description
motor DcMotorEx Motor whose encoder should be reset.
Type Description
void Resets the selected motor encoder.

public void devTelemetry(Telemetry tele, boolean verbose)

Displays drivetrain debugging telemetry including motor power and optional motor diagnostics.

Name Type Description
tele Telemetry Telemetry instance used to display data.
verbose boolean Whether additional diagnostic information should be displayed.
Type Description
void Adds drivetrain telemetry data.

public void devTelemetry(Telemetry tele, boolean verbose, float X, float Y, float rotation)

Displays drivetrain debugging telemetry with the requested drive inputs included.

Name Type Description
tele Telemetry Telemetry instance used to display data.
verbose boolean Whether additional diagnostic information should be displayed.
X float Requested strafe input.
Y float Requested forward/backward input.
rotation float Requested rotation input.
Type Description
void Adds drivetrain telemetry data.

public static double normalizeDegrees(double degrees)

Converts an angle into a normalized range between -180 and 180 degrees.

Name Type Description
degrees double Input angle in degrees.
Type Description
double Normalized angle.

FDIR stands for Fault Detection, Isolation, and Recovery.

The drivetrain uses multiple sensor inputs to identify possible motor failures:

  • Comparing commanded movement against actual robot movement using cosine similarity.
  • Monitoring motor current draw to detect stalled motors.
  • Checking the number of affected motors to avoid false positives caused by external forces or sensor failures.
  • Requiring failure conditions to persist before disabling a motor.

When possible, the drivetrain will continue operating with reduced capability after detecting a motor failure.