Skip to content
Work in progress. This library and its docs are new and still changing, and some parts are not yet tested on a real robot. If something is wrong or unclear,tell us with a short GitHub form.

TeleOp module

Package: com.crossbotics.ftchelper.teleop

Learn it hands-on: 20 Easy TeleOp. Ready to copy: the starter kit’s MainTeleOp.

A whole TeleOp (the driver-controlled part of the match). You write only what is special about your robot. Driving, the match timer, safety at ▶ (start on the Driver Hub) and STOP, and the tuning menu come ready-made. The Controls.java of the robot in five files uses it inside, so with five files, start there. Use EasyTeleOp directly with the starter kit or your own classes.

Class Use it to
EasyTeleOp a whole TeleOp OpMode: give it your robot settings and mechanisms, add the operator’s buttons
LibraryButtons, Key move or free the library’s own buttons (pause, slow, field-centric, menus, switch alliance)
flowchart LR
    I["INIT<br/>drive, IMU, 'forward' from auto,<br/>your mechanisms + buttons,<br/>warnings, alliance"] --> S["▶ start<br/>match timer starts"]
    S --> L["every loop:<br/>buttons -> driving -> everyLoop() -><br/>mechanisms update() -> telemetry"]
    L --> L
    L --> E["STOP (or an error)<br/>wheels and every mechanism stopped"]

@TeleOp(name = "Main TeleOp")
public class MainTeleOp extends EasyTeleOp {
private Robot robot;
// the robot's settings, shared with every autonomous
@Override protected RobotConfig robotConfig() { return new RobotSettings(); }
// the mechanisms: updated every loop, shown, stopped at the end
@Override protected Subsystems createSubsystems() {
robot = new Robot(hardwareMap);
return robot.all;
}
// the operator's buttons (gamepad 2)
@Override protected void bindButtons(ControllerBindings driver, ControllerBindings operator) {
operator.bindPress(Pad.G2, Btn.RB, () -> robot.claw.toggle("OPEN", "CLOSED"));
}
// anything else, every loop (here: the lift by hand)
@Override protected void everyLoop() {
robot.lift.manual(StickShaping.shape(-gamepad2.left_stick_y, 0.1, 1));
}
}
Driving (gamepad 1) left stick drives, right stick X turns, left trigger slows. Mecanum and tank: your DriveConfig picks one. See DriverControls.
Field-centric It starts robot-centric (stick up = the way the robot faces). Y turns field-centric (stick up = away from the driver) on and off. Two buzzes = on, one = off. Mecanum with an IMU only.
“Forward” It carries on from where autonomous ended (DriverHeading), even after INIT, STOP, INIT again. Press and let go of BACK alone (one buzz) to say “the robot now faces away from me”. With odometry, that lasts for this run. After INIT again, “forward” comes from the pose. With backTap(), a tap of BACK does your job instead, and a 1 s hold of BACK sets “forward”. Either way, BACK resets “forward” only while field-centric is on. In robot-centric driving, BACK does not reset it, and the Driver Station says why for 3 s: BACK: "forward" is only reset in field-centric driving (turn it on first).
Alliance the one autonomous chose, from MatchMemory. When none came (no autonomous ran, or the robot app restarted), INIT says “Choose the alliance”: gamepad 1 X = BLUE, B = RED. The same buttons change it. INIT also shows autonomous’s report. A switch during the match is optional (off by default). lib.switchAlliance(Key.g1(Btn.BACK), Key.g1(Btn.START)) turns it on. Then hold START, then BACK (START first), both for 1.5 s, to switch. Both gamepads buzz twice, and the screen says Alliance now RED (was BLUE). alliance() and MatchMemory give the new one. INIT’s Switch alliance line says whether the switch is on.
Match timer 2:00. Both gamepads buzz at 1:00 and 0:20. The screen shows the time.
Tuning menu GUIDE opens it (PRACTICE profile only). Gamepad 1 runs the menu, and the wheels hold still. With a button map (buttonHelp(), as ControlMap has), a tap of GUIDE shows the map during the match, and the robot still drives. A 1 s hold of GUIDE opens the tuning menu.
Telemetry your mechanisms’ lines, drive mode, time. START + BACK together turns the debug lines on or off when you let go. With the alliance switch on, a 1.5 s hold of the pair switches the alliance instead. With a pause on BACK (backTap() and pauseState(), a Controls.java TeleOp), hold START first, then press BACK: BACK first only pauses. Without a pause job, either order works.
Moving the buttons You can move every one of the buttons above to another button, or free it: libraryButtons(lib).
Warnings PRACTICE profile, tuned values that differ from the code, slow button actions or update()s. At INIT: a freed pause button (“No pause button”: nothing pauses the robot) or a freed field-centric button.
Safety The library ignores buttons held through ▶. The wheels and every mechanism stop at the end, even after an error.
Method Required? What you return / do
robotConfig() yes* new RobotSettings(): the RobotConfig shared with autonomous
createSubsystems() no your mechanisms. Default: none
bindButtons(driver, operator) no your buttons. Put gamepad 2 on operator, and extra gamepad 1 buttons on driver (they pause while the tuning menu is open). The library takes these on gamepad 1, unless you move them: LT, Y (field-centric, when the drive has it), BACK, START (with BACK: debug lines; START first when BACK pauses), GUIDE.
libraryButtons(lib) no move or free the library’s buttons (below)
setPoseJob() no the “set pose here” job (it gives the words to show), or null (default). Controls.java gives one on a robot with odometry. Its button works in INIT too (held 1 s before ▶)
allianceChanged(now) no update what uses the alliance when the driver switches it during the match (Controls.java: robot.setAlliance(now))
everyLoop() no your code for every loop (sticks for mechanisms, simple rules). It must not wait.
addTelemetry(t) no extra screen lines
backTap() no a job for a tap of BACK (a Controls.java TeleOp: pause everything). Then a 1 s hold of BACK resets “forward”
pauseState() no how to read “paused now” (a BooleanSupplier), or null (default). With one, the pause button pauses at the PRESS, and a tap still goes on. This works even though BACK also has a held job. Controls.java gives one
buttonHelp() no the button map’s lines. Then a tap of GUIDE shows them, and a 1 s hold of GUIDE opens the tuning menu
addInitTelemetry(t) no extra screen lines during INIT
onStart() no runs once right after ▶, before the first loop. It is the first moment anything may move

* Starter kit: return new RobotSettings();. Tutorials (09-20): return RobotSettings.config();. The tutorial RobotSettings keeps its settings in static methods, so config() wraps them. Without a RobotConfig, override driveConfig() and createImu().

Note: the bindings name the gamepad themselves (Pad.G1, Pad.G2). A Pad.G1 button on operator works, but it does not pause while the tuning menu is open. So put gamepad 1 buttons on driver.

Method Default
startFieldCentric() false true = start in field-centric
slowSpeed() 0.3 speed at a full squeeze of the slow trigger
fieldCentricButton() Btn.Y the gamepad 1 button for field-centric on/off. It takes a double tap: one tap does nothing. Null = none. This is a shortcut: libraryButtons can put it anywhere
standardLibraryButtons() LibraryButtons.twoDrivers() the defaults before libraryButtons(lib) (Controls.java uses the one-driver ones with oneDriver)
buzzAtSecondsLeft() {60, 20} when both gamepads buzz
drive(gamepad) the standard controls replace it to drive your own way, for example two-stick tank style: driving().tank(-gamepad.left_stick_y, -gamepad.right_stick_y, 1)
Method Gives
alliance() RED or BLUE
robotTelemetry() the screen helper (RobotTelemetry)
driving() the DriverControls (field-centric, slow)
heading() the DriverHeading, or null without an IMU
matchTimer() the MatchTimer
isTuningMenuOpen() whether the menu has gamepad 1. While it does, do not read gamepad 1’s sticks
switchAlliance() switches BLUE / RED now. The START + BACK hold does this once lib.switchAlliance(...) turns it on
driveSpeed() the speed the library’s slow buttons ask for now, 0 to 1 (for your own drive(gamepad))
showNote(text) a warning at the top of the screen for 3 s (for example, to confirm a job)
libraryKeys(), libraryJobs(withMap), keyWords(job) where the library’s buttons are, which of its jobs this TeleOp has, and a job’s button in words (“BACK”)

Every button above is the library’s own job. You can move or free (null) each one in libraryButtons(lib). A Key names one button on one gamepad: Key.g1(Btn.X), Key.g2(Btn.BACK), Key.g1(Trigger.RT). In Controls.java, write g1.x: each button there is a Key.

@Override protected void libraryButtons(LibraryButtons lib) {
lib.fieldCentric(Key.g1(Btn.X)) // field-centric on/off: X instead of Y
.slow(Key.g1(Trigger.RT)) // slow on the right trigger
.switchAlliance(Key.g1(Btn.BACK), Key.g1(Btn.START)); // optional: turn on the alliance switch
}
LibraryButtons Default (twoDrivers(); oneDriver() in brackets) How it works
pause(key) G1 BACK runs backTap() (Controls.java: pause everything). With pauseState(), a press pauses at once, and a tap goes on. A 1 s hold runs the hold job too, still paused. A pair with this button forms only when its other button went down first, so a pair never takes a pause back. Without pauseState(), a tap. Without backTap(), nothing. Null: INIT warns “No pause button”
resetForward(key) G1 BACK a 1 s hold when its button has a quick job (pause), or else a tap. Field-centric only (in robot-centric, a note)
debug(key, with) G1 START + BACK both together; it runs when you let go. When one is the pause button, the other goes first (hold START, then press BACK; BACK first only pauses). with null = one button
switchAlliance(key, with) none (off) turns it on: hold both for 1.5 s (SWITCH_ALLIANCE_SEC). With the pause button in the pair, the other goes first. with null = hold one button
setPose(key) G1 START a 1 s hold (HOLD_SEC), in INIT too. Only with a setPoseJob(). START + A/B (pairing a gamepad) cancels it
slow(key) G1 LT (none) a trigger: the further you squeeze, the slower. A button: slow while held
slowToggle(key) none (G1 left stick click) each press turns slow on or off
fieldCentric(key) G1 Y (G1 right stick click) a press. Only where field-centric works
buttonMap(key) G1 GUIDE a tap. Only with buttonHelp()
tuningMenu(key) G1 GUIDE a 1 s hold when its button shows the map, or else a tap
allianceInInit(blue, red) G1 X, G1 B INIT only, and not while START is held (START + A/B pairs a gamepad)
swapSticks(boolean) false true: the right stick drives, and the left stick X turns (DriverControls.swapSticks)
moveAllToGamepad1() - one driver: every gamepad 2 button of these jobs goes to gamepad 1 (Controls.java does it)
key(job), with(job), initBlue(), initRed(), sticksSwapped(), words(jobs) - read them back. words checks them and gives each button’s words for the map

Checked at INIT (the message names the button):

  • a button with two quick library jobs, or two held ones
  • the slow key with another job
  • a pair on two gamepads, or with one button twice
  • the tuning menu on a button the menu itself uses (gamepad 1 D-pad, A, B, X, Y, LB, RB)

While a pair is down, its buttons’ own jobs wait until you let go. While the tuning menu is open, only its button works.

runOpMode() is final: your class cannot replace it, so the safety steps always run. For a completely different loop, write a plain LinearOpMode (tutorials 04 and 12) with the same parts.

Something wrong on this page? Tell us with a short GitHub form.