Class EasyTeleOp

java.lang.Object
com.qualcomm.robotcore.eventloop.opmode.OpMode
com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
com.crossbotics.ftchelper.teleop.EasyTeleOp
Direct Known Subclasses:
ControlMap

public abstract class EasyTeleOp extends com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
A whole TeleOp where you only write what is special about YOUR robot: its mechanisms, the operator's buttons, and any extra screen lines. Everything every TeleOp needs is done for you:
  • Driving on gamepad 1 (DriverControls): left stick drive, right stick X turn, left trigger slow. Mecanum and tank. Robot-centric to start; Y double-tap = field-centric on/off (mecanum).
  • Field-centric "forward" continues from autonomous (DriverHeading); BACK resets it.
  • The alliance from autonomous (alliance(); chosen in INIT if no autonomous ran; a switch during TeleOp only if you turn it on), the 2:00 match timer with gamepad buzzes at 1:00 and 0:20, the tuning menu on GUIDE (PRACTICE profile only), debug telemetry on BACK + START, warnings for slow code, a tuned value or the PRACTICE profile.
  • Every one of these buttons can move or be freed: libraryButtons(LibraryButtons).
  • Every mechanism updated every loop, and EVERYTHING stopped at the end, even after an error.

 @TeleOp(name = "Main TeleOp")
 public class MainTeleOp extends EasyTeleOp {
     private Robot robot;

     @Override protected RobotConfig robotConfig() { return new RobotSettings(); }
     @Override protected Subsystems createSubsystems() { robot = new Robot(hardwareMap); return robot.all; }

     @Override protected void bindButtons(ControllerBindings driver, ControllerBindings operator) {
         operator.bindPress(Pad.G2, Btn.RB, robot.claw::toggle);
     }
 }
 

Order in each loop: buttons, driving, everyLoop(), mechanisms' update(), telemetry. Nothing here waits. Your code must not wait either (docs/guides/non-blocking.md). Docs: docs/modules/teleop.md. Tutorial: docs/tutorials/20-easy-teleop.md.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    How long BACK is held to reset "forward" when a tap of BACK has another job, seconds.
    com.qualcomm.robotcore.hardware.Gamepad
     
    com.qualcomm.robotcore.hardware.Gamepad
     
    static final double
    How long GUIDE is held to open the tuning menu when there is a button map, seconds.
    com.qualcomm.robotcore.hardware.HardwareMap
     
    static final int
     
    int
    Deprecated.
    org.firstinspires.ftc.robotcore.external.Telemetry
     

    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 void
    Extra lines for the Driver Station during INIT (before START), every INIT loop.
    protected void
    Extra lines for the Driver Station, every loop.
    protected Alliance
    The alliance autonomous chose (BLUE if no autonomous ran in the last few minutes).
    protected void
    Called when the alliance changes during TeleOp (switchAlliance()), after alliance() has the new one: update what uses it.
    protected void
    Your own code at the very end (STOP, the end, or an error), after the wheels and every part are stopped: e.g.
    protected Runnable
    What a tap of the pause button (BACK) does, or null (default): then BACK resets "forward".
    protected void
    Your buttons.
    protected List<String>
    The button map's lines for the help page, or null (default) for none.
    protected double[]
    Seconds left when both gamepads buzz.
    protected void
    Changes how driving feels, once, in INIT, right after the drive is made.
    protected 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 com.qualcomm.robotcore.hardware.IMU
    The IMU, for field-centric driving and "forward" from autonomous.
    protected Subsystems
    Your mechanisms: kept updated every loop and stopped at the end.
    protected void
    drive(com.qualcomm.robotcore.hardware.Gamepad gamepad)
    Drives the robot from gamepad 1, every loop (not while the tuning menu is open).
    protected DriveConfig
    The drivetrain settings.
    protected final double
    The driving speed the library's slow buttons ask for now, 0 to 1 (1 = full speed): the slow trigger (the further, the slower), a slow button held, or slow on/off.
    protected DriverControls
    The driving (field-centric on/off, slow mode).
    protected void
    Your own code for every loop, e.g.
    The gamepad 1 button that switches field-centric driving on and off (mecanum with an IMU only).
    protected DriverHeading
    The heading compared with the driver, or null if there is no IMU.
    protected boolean
    The INIT menu on gamepad 1's D-pad (alliance, profile)? Default on.
    protected boolean
    True while the tuning menu is open.
    protected final String
    "G1 BACK" for a job's button ("BACK" alone on gamepad 1), or "(no button)".
    protected void
    Moves or frees the library's own buttons (pause, slow, field-centric, menus...).
    protected final Set<LibraryButtons.Job>
    libraryJobs(boolean withButtonMap)
    The library's jobs this TeleOp has: "pause" only with backTap(), "field-centric" only where possible, "set pose" only with setPoseJob()...
    protected final LibraryButtons
    Where the library's buttons are (after libraryButtons(LibraryButtons)); null before INIT.
    protected MatchTimer
    The 2:00 match timer (started at START).
    protected void
    Runs once, right after START, before the first loop.
    protected BooleanSupplier
    How to read "the robot is paused now", or null (default).
    final void
     
    protected RobotConfig
    Your robot's settings, shared with autonomous (see RobotConfig).
    protected RobotTelemetry
    The Driver Station screen helper (warnings, standard and debug lines).
    final void
    The whole TeleOp.
    protected Supplier<String>
    The "set pose here" job, or null (default: none).
    protected String
    With no setPoseJob(): a short note shown when the drivers hold the "set pose here" button anyway (alone, 1 s, then let go), so it does not silently do nothing; null (default) = no note.
    protected final void
    Shows text as a warning at the top of the Driver Station for 3 seconds (e.g.
    protected double
    Speed at a full squeeze of the slow trigger, 0 to 1.
    protected LibraryButtons
    protected boolean
    True to start in field-centric mode.
    protected final void
    Switches the alliance now (BLUE to RED, or RED to BLUE), in case the wrong one was chosen: everything that reads alliance() or MatchMemory gets the new one, both gamepads buzz twice and the Driver Station says so.

    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

    • BACK_HOLD_SEC

      public static final double BACK_HOLD_SEC
      How long BACK is held to reset "forward" when a tap of BACK has another job, seconds.
      See Also:
    • GUIDE_HOLD_SEC

      public static final double GUIDE_HOLD_SEC
      How long GUIDE is held to open the tuning menu when there is a button map, seconds.
      See Also:
    • 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

    • EasyTeleOp

      public EasyTeleOp()
  • Method Details

    • robotConfig

      protected RobotConfig robotConfig()
      Your robot's settings, shared with autonomous (see RobotConfig). Return new RobotSettings(). If you do not have one, override driveConfig() and createImu() instead.
    • driveConfig

      protected DriveConfig driveConfig()
      The drivetrain settings. Default: robotConfig().drive().
    • createHeading

      protected DriverHeading createHeading(com.qualcomm.robotcore.hardware.IMU imu)
      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.
      Parameters:
      imu - the IMU from createImu(), or null
    • createImu

      protected com.qualcomm.robotcore.hardware.IMU createImu()
      The IMU, for field-centric driving and "forward" from autonomous. Default: robotConfig().imu(...). Null = no IMU: robot-centric driving only.
    • createSubsystems

      protected Subsystems createSubsystems()
      Your mechanisms: kept updated every loop and stopped at the end. Default: none.
    • bindButtons

      protected void bindButtons(ControllerBindings driver, ControllerBindings operator)
      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 (unless moved with libraryButtons(LibraryButtons)): LT, Y (field-centric), BACK, START (with BACK: debug lines), GUIDE.
    • everyLoop

      protected void everyLoop()
      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.
    • atEnd

      protected void atEnd()
      Your own code at the very end (STOP, the end, or an error), after the wheels and every part are stopped: e.g. save a number for the next OpMode. Runs even if stopping failed.
    • addTelemetry

      protected void addTelemetry(RobotTelemetry t)
      Extra lines for the Driver Station, every loop. The mechanisms' lines are already shown.
    • buttonHelp

      protected List<String> buttonHelp()
      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.
    • showNote

      protected final void showNote(String text)
      Shows text as a warning at the top of the Driver Station for 3 seconds (e.g. to confirm a button's job). A new note replaces the old one. Never waits.
    • backTap

      protected Runnable backTap()
      What a tap of the pause button (BACK) does, or null (default): then BACK resets "forward". With a job here (a Controls.java TeleOp: pause everything), holding BACK BACK_HOLD_SEC resets "forward". The buttons can be moved: libraryButtons(LibraryButtons).
    • pauseState

      protected BooleanSupplier pauseState()
      How to read "the robot is paused now", or null (default). With one, a press of the pause button pauses AT ONCE (even though BACK also has "hold: reset forward"), and going on is a tap. Without one, backTap() runs when BACK is let go. Controls.java gives one.
    • setPoseJob

      protected Supplier<String> setPoseJob()
      The "set pose here" job, or null (default: none). It sets the pose and returns the words for the Driver Station ("Pose set: ..."). Controls.java gives one on a robot with odometry. Its button works in INIT too (held 1 s before START), so the pose can be set before the match.
    • setPoseMissingNote

      protected String setPoseMissingNote()
      With no setPoseJob(): a short note shown when the drivers hold the "set pose here" button anyway (alone, 1 s, then let go), so it does not silently do nothing; null (default) = no note. Controls.java says the robot needs odometry for it.
    • allianceChanged

      protected void allianceChanged(Alliance now)
      Called when the alliance changes during TeleOp (switchAlliance()), after alliance() has the new one: update what uses it. Default: nothing. Must not wait.
    • libraryButtons

      protected void libraryButtons(LibraryButtons lib)
      Moves or frees the library's own buttons (pause, slow, field-centric, menus...). Default: nothing changes. Example: lib.fieldCentric(Key.g1(Btn.X)).slow(Key.g1(Trigger.RT));. Two jobs on one button stop at INIT with the button's name. The table: docs/controls/04-move-library-buttons.md.
      Parameters:
      lib - the buttons, already at their defaults (LibraryButtons.twoDrivers())
    • standardLibraryButtons

      protected LibraryButtons standardLibraryButtons()
      The defaults before libraryButtons(LibraryButtons): LibraryButtons.twoDrivers(), with field-centric on fieldCentricButton(). Controls.java gives the one-driver ones.
    • libraryKeys

      protected final LibraryButtons libraryKeys()
      Where the library's buttons are (after libraryButtons(LibraryButtons)); null before INIT.
    • libraryJobs

      protected final Set<LibraryButtons.Job> libraryJobs(boolean withButtonMap)
      The library's jobs this TeleOp has: "pause" only with backTap(), "field-centric" only where possible, "set pose" only with setPoseJob()...
      Parameters:
      withButtonMap - true if there is a button map (buttonHelp())
    • keyWords

      protected final String keyWords(LibraryButtons.Job job)
      "G1 BACK" for a job's button ("BACK" alone on gamepad 1), or "(no button)".
    • switchAlliance

      protected final void switchAlliance()
      Switches the alliance now (BLUE to RED, or RED to BLUE), in case the wrong one was chosen: everything that reads alliance() or MatchMemory gets the new one, both gamepads buzz twice and the Driver Station says so. The switch-alliance buttons call it (both held LibraryButtons.SWITCH_ALLIANCE_SEC s).
    • driveSpeed

      protected final double driveSpeed()
      The driving speed the library's slow buttons ask for now, 0 to 1 (1 = full speed): the slow trigger (the further, the slower), a slow button held, or slow on/off.
    • addInitTelemetry

      protected void addInitTelemetry(RobotTelemetry t)
      Extra lines for the Driver Station during INIT (before START), every INIT loop.
    • onStart

      protected void onStart()
      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.
    • startFieldCentric

      protected boolean startFieldCentric()
      True to start in field-centric mode. Default false (robot-centric).
    • fieldCentricButton

      protected ControllerBindings.Btn fieldCentricButton()
      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 startFieldCentric() says). A shortcut: libraryButtons(LibraryButtons) can put it on any button of either gamepad.
    • slowSpeed

      protected double slowSpeed()
      Speed at a full squeeze of the slow trigger, 0 to 1. Default 0.3.
    • configureDriving

      protected void configureDriving(DriverControls driving)
      Changes how driving feels, once, in INIT, right after the drive is made. Example: driving.sticks(0.08, 3); for a bigger deadband and a stronger curve.
    • buzzAtSecondsLeft

      protected double[] buzzAtSecondsLeft()
      Seconds left when both gamepads buzz. Default 60 and 20 (1:00 and 0:20 left). Change it to the moments that matter in this season's game.
    • drive

      protected void drive(com.qualcomm.robotcore.hardware.Gamepad gamepad)
      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 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);
       }
       
    • alliance

      protected Alliance alliance()
      The alliance autonomous chose (BLUE if no autonomous ran in the last few minutes).
    • robotTelemetry

      protected RobotTelemetry robotTelemetry()
      The Driver Station screen helper (warnings, standard and debug lines).
    • driving

      protected DriverControls driving()
      The driving (field-centric on/off, slow mode).
    • heading

      protected DriverHeading heading()
      The heading compared with the driver, or null if there is no IMU.
    • matchTimer

      protected MatchTimer matchTimer()
      The 2:00 match timer (started at START).
    • isTuningMenuOpen

      protected boolean isTuningMenuOpen()
      True while the tuning menu is open. Gamepad 1 belongs to the menu then: do not read its sticks.
    • initMenu

      protected boolean initMenu()
      The INIT menu on gamepad 1's D-pad (alliance, profile)? Default on. Override with return false when your own INIT code uses gamepad 1's D-pad.
    • runOpMode

      public final void runOpMode()
      The whole TeleOp. The FTC SDK calls this when you press INIT. final: your class cannot replace it, so the safety steps here always run.
      Specified by:
      runOpMode in class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
    • requestOpModeStop

      public final void requestOpModeStop()