Class ReverseDrive

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

public final class ReverseDrive extends Object
A "drive backwards" mode: when ON, forward and strafe are flipped, so the back of the robot acts as the front. Turning is NOT flipped (the stick still turns the robot the same way).

Useful when the driver must look at the robot's back (for example to load a game piece).


 ReverseDrive reverse = new ReverseDrive();
 controls.bindPress(Pad.G1, Btn.L_STICK_BTN, () -> confirm.play(reverse.toggle()));
 // every loop:
 drive.drive(reverse.apply(forward), reverse.apply(strafe), turn);
 
Docs: docs/modules/drive.md. Tutorial 04 ("Reverse drive") shows it in a TeleOp.
  • Constructor Details

    • ReverseDrive

      public ReverseDrive()
  • Method Details

    • toggle

      public boolean toggle()
      Flips the mode.
      Returns:
      the new state (true = reversed), handy for a sound or rumble that tells the driver
    • set

      public void set(boolean reversed)
      Sets the mode.
    • isReversed

      public boolean isReversed()
      True when reversed.
    • apply

      public double apply(double translation)
      Use on forward and strafe only. Returns the value, flipped if reversed. (Not on turning: a stick pushed right should still turn the robot clockwise.)