Class ControlMap<R extends RobotDefinition>

java.lang.Object
com.qualcomm.robotcore.eventloop.opmode.OpMode
com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
com.crossbotics.ftchelper.teleop.EasyTeleOp
com.crossbotics.ftchelper.robot.ControlMap<R>

public abstract class ControlMap<R extends RobotDefinition> extends EasyTeleOp
The team's TeleOp and button map in one file, Controls.java. Every module on the robot already has its standard buttons; you only write what is different.

 @TeleOp(name = "TeleOp")
 public class Controls extends ControlMap<Robot> {
     public static boolean oneDriver = false;   // true: everything on gamepad 1

     @Override protected void buttons(Robot robot, Pad g1, Pad g2) {
         g2.y.press(Actions.scoreHigh(robot));   // replaces the lift's "high" on Y
         g2.rightStickButton.free();              // free: nothing yet
     }
 }
 

Driving (gamepad 1, always): left stick drives (and strafes on mecanum), right stick X turns, LT slow (the further it is pulled, the slower), Y field-centric on/off (mecanum), BACK pauses everything (motors on brake; again to go on), holding BACK 1 s resets "forward", START + BACK debug lines, GUIDE shows the button map (a tap) or opens the tuning menu (held 1 s, PRACTICE profile). With oneDriver = true: left stick click slow on/off, right stick click field-centric, and the operator's buttons move to gamepad 1.

Checked at INIT: a button with two jobs in this file, or a job on a driving button, stops with the button's name. INIT shows the whole map, the Tunables notes and any tuned values that differ from Tunables.java (lines to copy back).

Everything else is EasyTeleOp: match timer, buzzes, everything stopped at the end. Docs: docs/modules/robot.md (section "Controls")

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    com.qualcomm.robotcore.hardware.Gamepad
     
    com.qualcomm.robotcore.hardware.Gamepad
     
    com.qualcomm.robotcore.hardware.HardwareMap
     
    static final int
     
    int
    Deprecated.
    org.firstinspires.ftc.robotcore.external.Telemetry
     

    Fields inherited from class com.crossbotics.ftchelper.teleop.EasyTeleOp

    BACK_HOLD_SEC, GUIDE_HOLD_SEC

    Fields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    blackboard, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, time
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    Extra lines for the Driver Station during INIT (before START), every INIT loop.
    protected final void
    Extra lines for the Driver Station, every loop.
    protected final Runnable
    What a tap of BACK does, or null (default): then BACK resets "forward".
    protected final void
    Your buttons.
    protected final List<String>
    The button map's lines for the help page, or null (default) for none.
    protected abstract void
    buttons(R robot, Pad g1, Pad g2)
    Your buttons, after the modules' standard ones.
    protected final DriverHeading
    createHeading(com.qualcomm.robotcore.hardware.IMU imu)
    The driver's heading for field-centric driving: from the IMU (with autonomous's saved heading).
    protected final Subsystems
    Your mechanisms: kept updated every loop and stopped at the end.
    protected final void
    drive(com.qualcomm.robotcore.hardware.Gamepad gamepad)
    Drives the robot from gamepad 1, every loop (not while the tuning menu is open).
    protected final void
    Your own code for every loop, e.g.
    protected final ControllerBindings.Btn
    The gamepad 1 button that switches field-centric driving on and off (mecanum with an IMU only).
    protected final boolean
    True if this class has public static boolean oneDriver = true.
    protected final void
    Runs once, right after START, before the first loop.
    final void
     
    protected final R
    The robot, made from ControlMap<Robot>'s type.
    protected final RobotConfig
    Your robot's settings, shared with autonomous (see RobotConfig).
    protected final void
    show(String label, Supplier<?> value)
    Shows a value of your own on the Driver Station during the match, read again every loop.
    protected final double
    Speed at a full squeeze of the slow trigger, 0 to 1.
    protected boolean
    False to switch the modules' suggested buttons off (only Controls.java's jobs).

    Methods inherited from class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode

    idle, init, init_loop, isStarted, isStopRequested, loop, opModeInInit, opModeIsActive, sleep, start, stop, waitForStart

    Methods inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    getRuntime, internalPostInitLoop, internalPostLoop, internalPreInit, internalUpdateTelemetryNow, resetRuntime, terminateOpModeNow, updateTelemetry

    Methods inherited from class java.lang.Object

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

    • MS_BEFORE_FORCE_STOP_AFTER_STOP_REQUESTED

      public static final int MS_BEFORE_FORCE_STOP_AFTER_STOP_REQUESTED
      See Also:
    • gamepad1

      public volatile com.qualcomm.robotcore.hardware.Gamepad gamepad1
    • gamepad2

      public volatile com.qualcomm.robotcore.hardware.Gamepad gamepad2
    • telemetry

      public org.firstinspires.ftc.robotcore.external.Telemetry telemetry
    • hardwareMap

      public volatile com.qualcomm.robotcore.hardware.HardwareMap hardwareMap
    • msStuckDetectStop

      @Deprecated public int msStuckDetectStop
      Deprecated.
  • Constructor Details

    • ControlMap

      public ControlMap()
  • Method Details

    • buttons

      protected abstract void buttons(R robot, Pad g1, Pad g2)
      Your buttons, after the modules' standard ones. A job here replaces a module's suggestion on the same button.
      Parameters:
      robot - your robot (its modules are set up)
      g1 - the driver's gamepad (the operator's too with oneDriver)
      g2 - the operator's gamepad (with oneDriver = true: gamepad 1, the same as g1)
    • useStandardButtons

      protected boolean useStandardButtons()
      False to switch the modules' suggested buttons off (only Controls.java's jobs). Default true.
    • robot

      protected final R robot()
      The robot, made from ControlMap<Robot>'s type.
    • oneDriver

      protected final boolean oneDriver()
      True if this class has public static boolean oneDriver = true.
    • robotConfig

      protected final RobotConfig robotConfig()
      Description copied from class: EasyTeleOp
      Your robot's settings, shared with autonomous (see RobotConfig). Return new RobotSettings(). If you do not have one, override EasyTeleOp.driveConfig() and EasyTeleOp.createImu() instead.
      Overrides:
      robotConfig in class EasyTeleOp
    • slowSpeed

      protected final double slowSpeed()
      Description copied from class: EasyTeleOp
      Speed at a full squeeze of the slow trigger, 0 to 1. Default 0.3.
      Overrides:
      slowSpeed in class EasyTeleOp
    • fieldCentricButton

      protected final ControllerBindings.Btn fieldCentricButton()
      Description copied from class: EasyTeleOp
      The gamepad 1 button that switches field-centric driving on and off (mecanum with an IMU only). Default Y. Return null for none (then field-centric stays as EasyTeleOp.startFieldCentric() says).
      Overrides:
      fieldCentricButton in class EasyTeleOp
    • createSubsystems

      protected final Subsystems createSubsystems()
      Description copied from class: EasyTeleOp
      Your mechanisms: kept updated every loop and stopped at the end. Default: none.
      Overrides:
      createSubsystems in class EasyTeleOp
    • createHeading

      protected final DriverHeading createHeading(com.qualcomm.robotcore.hardware.IMU imu)
      Description copied from class: EasyTeleOp
      The driver's heading for field-centric driving: from the IMU (with autonomous's saved heading). The robot in five files uses its odometry instead when it has one.
      Overrides:
      createHeading in class EasyTeleOp
      Parameters:
      imu - the IMU from EasyTeleOp.createImu(), or null
    • bindButtons

      protected final void bindButtons(ControllerBindings driver, ControllerBindings operator)
      Description copied from class: EasyTeleOp
      Your buttons. Put gamepad 2 buttons on operator. Extra gamepad 1 buttons go on driver: those pause while the tuning menu is open (it uses gamepad 1). Already taken on gamepad 1: Y (field-centric; see EasyTeleOp.fieldCentricButton()), BACK, START + BACK, GUIDE.
      Overrides:
      bindButtons in class EasyTeleOp
    • buttonHelp

      protected final List<String> buttonHelp()
      Description copied from class: EasyTeleOp
      The button map's lines for the help page, or null (default) for none. With a map, a tap of GUIDE shows it during the match and holding GUIDE 1 s opens the tuning menu; without one, GUIDE opens the tuning menu.
      Overrides:
      buttonHelp in class EasyTeleOp
    • backTap

      protected final Runnable backTap()
      Description copied from class: EasyTeleOp
      What a tap of BACK does, or null (default): then BACK resets "forward". With a job here (a Controls.java TeleOp: pause everything), holding BACK EasyTeleOp.BACK_HOLD_SEC resets "forward".
      Overrides:
      backTap in class EasyTeleOp
    • drive

      protected final void drive(com.qualcomm.robotcore.hardware.Gamepad gamepad)
      Description copied from class: EasyTeleOp
      Drives the robot from gamepad 1, every loop (not while the tuning menu is open). Default: the standard controls. Replace it to drive your own way, with EasyTeleOp.driving()'s drive(...) or tank(...). Example, two-stick tank style:
      
       @Override protected void drive(Gamepad gamepad) {
           driving().tank(-gamepad.left_stick_y, -gamepad.right_stick_y, 1);
       }
       
      Overrides:
      drive in class EasyTeleOp
    • onStart

      protected final void onStart()
      Description copied from class: EasyTeleOp
      Runs once, right after START, before the first loop. Must be quick: start things here, never wait. Nothing may move before START, so this is the first moment a mechanism may move.
      Overrides:
      onStart in class EasyTeleOp
    • addTelemetry

      protected final void addTelemetry(RobotTelemetry t)
      Description copied from class: EasyTeleOp
      Extra lines for the Driver Station, every loop. The mechanisms' lines are already shown.
      Overrides:
      addTelemetry in class EasyTeleOp
    • show

      protected final void show(String label, Supplier<?> value)
      Shows a value of your own on the Driver Station during the match, read again every loop. Call it in buttons(...), e.g. show("Lift ticks", robot.lift::position); or show("Ready", () -> robot.launcher.isReady());.
      Parameters:
      label - the words before the value
      value - how to read it (a method reference or a small lambda; it must not wait)
    • everyLoop

      protected final void everyLoop()
      Description copied from class: EasyTeleOp
      Your own code for every loop, e.g. a stick that moves the lift by hand. Runs after the buttons and driving, before the mechanisms update. Must be quick: never wait here.
      Overrides:
      everyLoop in class EasyTeleOp
    • addInitTelemetry

      protected final void addInitTelemetry(RobotTelemetry t)
      Description copied from class: EasyTeleOp
      Extra lines for the Driver Station during INIT (before START), every INIT loop.
      Overrides:
      addInitTelemetry in class EasyTeleOp
    • requestOpModeStop

      public final void requestOpModeStop()