Class DriveConfig

java.lang.Object
com.crossbotics.ftchelper.drive.DriveConfig

public class DriveConfig extends Object
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.)

  • Field Details

    • type

      public DriveConfig.DriveType type
      The kind of drivetrain. Default MECANUM.
    • frontLeft

      public String frontLeft
      Configuration name of the front-left motor (tank: the left motor, or the front one of two).
    • frontRight

      public String frontRight
      Configuration name of the front-right motor (tank: the right motor, or the front one of two).
    • backLeft

      public String backLeft
      Configuration name of the back-left motor. Tank with 2 motors: null.
    • backRight

      public String backRight
      Configuration name of the back-right motor. Tank with 2 motors: null.
    • frontLeftReversed

      public boolean frontLeftReversed
      True = this motor is reversed.
    • frontRightReversed

      public boolean frontRightReversed
      True = this motor is reversed.
    • backLeftReversed

      public boolean backLeftReversed
      True = this motor is reversed.
    • backRightReversed

      public boolean backRightReversed
      True = this motor is reversed.
    • powerLimit

      public double powerLimit
      The largest power any wheel gets, 0 to 1. Start low (0.4) on a new robot.
    • brake

      public boolean brake
      True = wheels hold still at power 0 (recommended). False = wheels coast.
  • Constructor Details

    • DriveConfig

      public DriveConfig()
  • Method Details

    • mecanum

      public static DriveConfig mecanum()
      Settings for a four-motor mecanum drive (the same as new DriveConfig()). ("static" means you call it on the class, DriveConfig.mecanum(), without having one first.)
    • tank

      public static DriveConfig tank()
      Settings for a four-motor standard (tank) drive: front_left, front_right, back_left, back_right.
    • tankTwoMotor

      public static DriveConfig 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