Class Drive

java.lang.Object
com.crossbotics.ftchelper.robot.Drive

public final class Drive extends Object
The drivetrain in Robot.java: mecanum or standard (tank), its motor names, the motor and wheel, and how the Control Hub is mounted (for the IMU, the turn sensor).

 drive(Drive.mecanum("front_left", "front_right", "back_left", "back_right")
         .motor("gobilda-5203-312").wheelMm(96)
         .imu("imu", LogoFacingDirection.UP, UsbFacingDirection.FORWARD));
 drive(Drive.tank("left_drive", "right_drive").motor("gobilda-5203-312").wheelMm(96));
 

Its numbers are in Tunables.Drive: maxPower, practiceMaxPower (the PRACTICE profile's limit), slowSpeed (the slow trigger), and the autonomous ones (strafeCorrection, turnKp, turnKd, moveMinPower) with calibrated = true once the Drive Tuner is done (autonomous refuses to run before).

Motor directions: the left side is reversed by default (the usual way motors are mounted). If pushing the stick forward drives backward or spins the robot, name the reversed motors with reversed(String...). Docs: docs/modules/robot.md (section "Drive")

  • Method Summary

    Modifier and Type
    Method
    Description
    gearRatio(double motorTurnsPerWheelTurn)
    Motor turns per wheel turn, if gears or a belt sit between them.
    imu(String name, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb)
    The IMU's name and how the Control Hub is mounted.
    boolean
    True for mecanum (it can strafe).
    boolean
    True if this drive motor is reversed in Robot.java (a path follower module sets its motors the same way).
    static Drive
    mecanum(String frontLeft, String frontRight, String backLeft, String backRight)
    A four-wheel mecanum drive (it can strafe).
    The drive motor, by its parts-catalog id (see Motors).
    Every drive motor name, front left first.
    No IMU: TeleOp drives robot-centric only, and autonomous refuses to start.
    reversed(String... motorNames)
    Exactly these motors run reversed (instead of the left side).
    static Drive
    tank(String left, String right)
    A two-motor standard (tank) drive, one motor per side.
    static Drive
    tank(String frontLeft, String frontRight, String backLeft, String backRight)
    A four-motor standard (tank) drive.
    The wheel by its parts catalog id (see Parts): its diameter comes from the catalog.
    wheelMm(double mm)
    The wheel diameter in millimetres (goBILDA mecanum: 96 or 104).
    wheelsAtMm(double trackMm, double wheelBaseMm)
    Where the wheels sit, for the simulator's turning: wheel centres side to side (track) and front to back (wheel base), in mm.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • mecanum

      public static Drive mecanum(String frontLeft, String frontRight, String backLeft, String backRight)
      A four-wheel mecanum drive (it can strafe).
    • tank

      public static Drive tank(String left, String right)
      A two-motor standard (tank) drive, one motor per side.
    • tank

      public static Drive tank(String frontLeft, String frontRight, String backLeft, String backRight)
      A four-motor standard (tank) drive.
    • motor

      public Drive motor(String id)
      The drive motor, by its parts-catalog id (see Motors). Default "gobilda-5203-312".
      Parameters:
      id - e.g. "gobilda-5203-312", "rev-hd-hex-20"
    • wheelMm

      public Drive wheelMm(double mm)
      The wheel diameter in millimetres (goBILDA mecanum: 96 or 104). Default 96.
    • wheel

      public Drive wheel(String id)
      The wheel by its parts catalog id (see Parts): its diameter comes from the catalog.
      Parameters:
      id - e.g. "gobilda-hogback-96"
    • wheelsAtMm

      public Drive wheelsAtMm(double trackMm, double wheelBaseMm)
      Where the wheels sit, for the simulator's turning: wheel centres side to side (track) and front to back (wheel base), in mm.
    • gearRatio

      public Drive gearRatio(double motorTurnsPerWheelTurn)
      Motor turns per wheel turn, if gears or a belt sit between them. Default 1.
    • reversed

      public Drive reversed(String... motorNames)
      Exactly these motors run reversed (instead of the left side). Use it when the robot drives the wrong way: docs/troubleshooting.md.
      Parameters:
      motorNames - configuration names of the reversed motors (none = no motor reversed)
    • imu

      public Drive imu(String name, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection logo, com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection usb)
      The IMU's name and how the Control Hub is mounted. Default "imu", logo UP, USB FORWARD.
      Parameters:
      name - the IMU's configuration name (usually "imu")
      logo - which way the REV logo on the hub faces
      usb - which way the hub's USB port faces
    • noImu

      public Drive noImu()
      No IMU: TeleOp drives robot-centric only, and autonomous refuses to start.
    • isMecanum

      public boolean isMecanum()
      True for mecanum (it can strafe).
    • motorNames

      public List<String> motorNames()
      Every drive motor name, front left first.
    • isReversed

      public boolean isReversed(String name)
      True if this drive motor is reversed in Robot.java (a path follower module sets its motors the same way).