Package com.crossbotics.ftchelper.drive
Class DriveConfig
java.lang.Object
com.crossbotics.ftchelper.drive.DriveConfig
The drivetrain type, the motor names and directions, and a power limit.
Start from the factory method for your drivetrain, change what is different on your robot,
and give it to MecanumDrive or TankDrive (and to AutoDrive).
(A "factory method" is a method that makes a ready-filled object for you, like
mecanum() or tank().)
DriveConfig cfg = DriveConfig.mecanum(); // or DriveConfig.tank() / DriveConfig.tankTwoMotor()
cfg.frontLeft = "fl"; // your configuration names
cfg.powerLimit = 0.8; // never more than 80% power
Default directions: the left motors are reversed. This is right for most goBILDA and REV chassis, but CHECK IT: see "Check motor directions" in docs/modules/drive.md. (The motors on the left side face the other way from the ones on the right, so one side must be reversed for "positive power" to mean "forward" on both.)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionConfiguration name of the back-left motor.booleanTrue = this motor is reversed.Configuration name of the back-right motor.booleanTrue = this motor is reversed.booleanTrue = wheels hold still at power 0 (recommended).Configuration name of the front-left motor (tank: the left motor, or the front one of two).booleanTrue = this motor is reversed.Configuration name of the front-right motor (tank: the right motor, or the front one of two).booleanTrue = this motor is reversed.doubleThe largest power any wheel gets, 0 to 1.The kind of drivetrain. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTrue if there are back motors (always for mecanum; for tank, when both back names are set).static DriveConfigmecanum()Settings for a four-motor mecanum drive (the same asnew DriveConfig()).static DriveConfigtank()Settings for a four-motor standard (tank) drive: front_left, front_right, back_left, back_right.static DriveConfigSettings for a two-motor standard (tank) drive.voidvalidate()Checks the settings make sense.
-
Field Details
-
type
The kind of drivetrain. Default MECANUM. -
frontLeft
Configuration name of the front-left motor (tank: the left motor, or the front one of two). -
frontRight
Configuration name of the front-right motor (tank: the right motor, or the front one of two). -
backLeft
Configuration name of the back-left motor. Tank with 2 motors:null. -
backRight
Configuration name of the back-right motor. Tank with 2 motors:null. -
frontLeftReversed
public boolean frontLeftReversedTrue = this motor is reversed. -
frontRightReversed
public boolean frontRightReversedTrue = this motor is reversed. -
backLeftReversed
public boolean backLeftReversedTrue = this motor is reversed. -
backRightReversed
public boolean backRightReversedTrue = this motor is reversed. -
powerLimit
public double powerLimitThe largest power any wheel gets, 0 to 1. Start low (0.4) on a new robot. -
brake
public boolean brakeTrue = wheels hold still at power 0 (recommended). False = wheels coast.
-
-
Constructor Details
-
DriveConfig
public DriveConfig()
-
-
Method Details
-
mecanum
Settings for a four-motor mecanum drive (the same asnew DriveConfig()). ("static" means you call it on the class,DriveConfig.mecanum(), without having one first.) -
tank
Settings for a four-motor standard (tank) drive: front_left, front_right, back_left, back_right. -
tankTwoMotor
Settings for a two-motor standard (tank) drive. The names are "left_drive" and "right_drive", the same as the FTC SDK samples. -
hasBackMotors
public boolean hasBackMotors()True if there are back motors (always for mecanum; for tank, when both back names are set). -
validate
public void validate()Checks the settings make sense. Called by the drive classes. It fails right away in INIT with a clear message, instead of the robot driving strangely later.- Throws:
IllegalArgumentException- with a plain message if something is missing
-