Class ControlMap<R extends RobotDefinition>
Controls.java. The library's own buttons
(driving, pause, menus) are always there; every other button is a line in buttons(...), a
part's too (each part's "buttons to add" in docs/reference/robot-java.md).
@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)); // an action on Y
g2.rightStickButton.free(); // free: nothing yet
}
}
The library's own buttons (gamepad 1 by default): left stick drives (and strafes on
mecanum), right stick X turns, LT slow (the further it is pulled, the slower), Y double-tap: field-centric on/off
(mecanum), BACK pauses everything at the press (motors on brake; a tap again to go on), holding BACK
1 s also resets "forward" (field-centric), hold START then press BACK: debug lines (BACK first is
just a pause), START held 1 s sets the pose to
the reset spot (robots with odometry; sticks let go; also in INIT), GUIDE shows the button map (a
tap) or opens the tuning menu (held 1 s, PRACTICE profile). Switching the alliance during TeleOp is
off unless you turn it on: lib.switchAlliance(g1.start, g1.back). With oneDriver = true: left stick click slow
on/off, right stick click field-centric, and the operator's buttons move to gamepad 1. Every one can
be moved or freed in libraryButtons(LibraryButtons, Pad, Pad).
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/reference/robot-java.md (section "Controls")
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.qualcomm.robotcore.hardware.Gamepadcom.qualcomm.robotcore.hardware.Gamepadcom.qualcomm.robotcore.hardware.HardwareMapstatic final intintDeprecated.org.firstinspires.ftc.robotcore.external.TelemetryFields inherited from class com.crossbotics.ftchelper.teleop.EasyTeleOp
BACK_HOLD_SEC, GUIDE_HOLD_SECFields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode
blackboard, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, time -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidExtra lines for the Driver Station during INIT (before START), every INIT loop.protected final voidExtra lines for the Driver Station, every loop.protected final voidallianceChanged(Alliance now) Called when the alliance changes during TeleOp (EasyTeleOp.switchAlliance()), afterEasyTeleOp.alliance()has the new one: update what uses it.protected final voidatEnd()Your own code at the very end (STOP, the end, or an error), after the wheels and every part are stopped: e.g.protected final voidatSecondsLeft(double seconds, Runnable job) Runs a job once, when this many seconds of TeleOp are left, e.g.protected final RunnablebackTap()What a tap of the pause button (BACK) does, or null (default): then BACK resets "forward".protected final voidbindButtons(ControllerBindings driver, ControllerBindings operator) Your buttons.The button map's lines for the help page, or null (default) for none.protected abstract voidYour buttons, after the modules' standard ones.protected final DriverHeadingcreateHeading(com.qualcomm.robotcore.hardware.IMU imu) The driver's heading for field-centric driving: from the IMU (with autonomous's saved heading).protected final SubsystemsYour mechanisms: kept updated every loop and stopped at the end.protected final voiddrive(com.qualcomm.robotcore.hardware.Gamepad gamepad) Drives the robot from gamepad 1, every loop (not while the tuning menu is open).protected final voidYour own code for every loop, e.g.protected final ControllerBindings.BtnThe gamepad 1 button that switches field-centric driving on and off (mecanum with an IMU only).protected final voidMoves or frees the library's own buttons (pause, slow, field-centric, menus...).protected voidlibraryButtons(LibraryButtons lib, Pad g1, Pad g2) Moves or frees the library's own buttons (driving, pause, slow, field-centric, menus, "set pose here", "switch alliance").protected final booleanTrue if this class haspublic static boolean oneDriver = true.protected final voidonStart()Runs once, right after START, before the first loop.protected final BooleanSupplierHow to read "the robot is paused now", or null (default).final voidprotected final Rrobot()The robot, made fromControlMap<Robot>'s type.protected final RobotConfigYour robot's settings, shared with autonomous (seeRobotConfig).protected final RunnableMakes a job that drives the robot to a field spot by itself, around the boxes offieldMap(...)in Robot.java.protected final Runnableroute(String, double, double, double, double)with your own "close enough" at the end, inches.protected final booleanTrue while aroute(java.lang.String, double, double, double, double)job drives the robot.The "set pose here" job, or null (default: none).protected final StringWith noEasyTeleOp.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 voidShows a value of your own on the Driver Station during the match, read again every loop.protected final doubleSpeed at a full squeeze of the slow trigger, 0 to 1.protected final LibraryButtonsThe defaults beforeEasyTeleOp.libraryButtons(LibraryButtons):LibraryButtons.twoDrivers(), with field-centric onEasyTeleOp.fieldCentricButton().protected final voidEnds a runningroute(java.lang.String, double, double, double, double)job now (nothing happens if none runs).protected booleanTrue: each part adds its usual buttons by itself (the way before v0.39.0), and a line of yours on one of those buttons replaces it.Methods inherited from class com.crossbotics.ftchelper.teleop.EasyTeleOp
alliance, buzzAtSecondsLeft, configureDriving, createImu, driveConfig, driveSpeed, driving, heading, initMenu, isTuningMenuOpen, keyWords, libraryJobs, libraryKeys, matchTimer, robotTelemetry, runOpMode, showNote, startFieldCentric, switchAllianceMethods inherited from class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
idle, init, init_loop, isStarted, isStopRequested, loop, opModeInInit, opModeIsActive, sleep, start, stop, waitForStartMethods inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode
getRuntime, internalPostInitLoop, internalPostLoop, internalPreInit, internalUpdateTelemetryNow, resetRuntime, terminateOpModeNow, updateTelemetry
-
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.
-
-
Constructor Details
-
ControlMap
public ControlMap()
-
-
Method Details
-
buttons
Your buttons, after the modules' standard ones. A job here replaces a module's suggestion on the same button.It runs once, in INIT. Code of your own for this TeleOp only goes here too:
robot.duringInit(...),robot.atStart(...),robot.everyLoop(...),robot.atStop(...)(docs/guides/your-own-code.md).- Parameters:
robot- your robot (its modules are set up)g1- the driver's gamepad (the operator's too withoneDriver)g2- the operator's gamepad (withoneDriver = true: gamepad 1, the same as g1)
-
libraryButtons
Moves or frees the library's own buttons (driving, pause, slow, field-centric, menus, "set pose here", "switch alliance"). Default: nothing changes. Two jobs on one button stop at INIT with the button's name; a job of yours on a library button too.@Override protected void libraryButtons(LibraryButtons lib, Pad g1, Pad g2) { lib.fieldCentric(g1.x); // Y is free for buttons(...) now lib.setPose(g1.dpadDown); // hold D-pad down 1 s: set pose here lib.switchAlliance(g1.start, g1.back); // turn on the alliance switch (hold START, then BACK, 1.5 s) }- Parameters:
lib- the library's buttons, at their defaults (one driver: the one-driver ones)g1- gamepad 1's buttons, to name themg2- gamepad 2's (withoneDriver = true: gamepad 1, the same as g1)
-
useStandardButtons
protected boolean useStandardButtons()True: each part adds its usual buttons by itself (the way before v0.39.0), and a line of yours on one of those buttons replaces it. Default false: a part has no buttons until Controls.java writes its lines, so every button is a line you can read. INIT names each part's usual button that is still free ("Intake: usual buttons not in Controls.java: G2 RT (in (hold)), ..."). The usual lines: docs/reference/robot-java.md, each part's "Buttons to add". -
robot
The robot, made fromControlMap<Robot>'s type. -
oneDriver
protected final boolean oneDriver()True if this class haspublic static boolean oneDriver = true. -
robotConfig
Description copied from class:EasyTeleOpYour robot's settings, shared with autonomous (seeRobotConfig). Returnnew RobotSettings(). If you do not have one, overrideEasyTeleOp.driveConfig()andEasyTeleOp.createImu()instead.- Overrides:
robotConfigin classEasyTeleOp
-
slowSpeed
protected final double slowSpeed()Description copied from class:EasyTeleOpSpeed at a full squeeze of the slow trigger, 0 to 1. Default 0.3.- Overrides:
slowSpeedin classEasyTeleOp
-
fieldCentricButton
Description copied from class:EasyTeleOpThe 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 asEasyTeleOp.startFieldCentric()says). A shortcut:EasyTeleOp.libraryButtons(LibraryButtons)can put it on any button of either gamepad.- Overrides:
fieldCentricButtonin classEasyTeleOp
-
createSubsystems
Description copied from class:EasyTeleOpYour mechanisms: kept updated every loop and stopped at the end. Default: none.- Overrides:
createSubsystemsin classEasyTeleOp
-
createHeading
Description copied from class:EasyTeleOpThe 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:
createHeadingin classEasyTeleOp- Parameters:
imu- the IMU fromEasyTeleOp.createImu(), or null
-
standardLibraryButtons
Description copied from class:EasyTeleOpThe defaults beforeEasyTeleOp.libraryButtons(LibraryButtons):LibraryButtons.twoDrivers(), with field-centric onEasyTeleOp.fieldCentricButton(). Controls.java gives the one-driver ones.- Overrides:
standardLibraryButtonsin classEasyTeleOp
-
libraryButtons
Description copied from class:EasyTeleOpMoves 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.- Overrides:
libraryButtonsin classEasyTeleOp- Parameters:
lib- the buttons, already at their defaults (LibraryButtons.twoDrivers())
-
setPoseJob
Description copied from class:EasyTeleOpThe "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.- Overrides:
setPoseJobin classEasyTeleOp
-
setPoseMissingNote
Description copied from class:EasyTeleOpWith noEasyTeleOp.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.- Overrides:
setPoseMissingNotein classEasyTeleOp
-
allianceChanged
Description copied from class:EasyTeleOpCalled when the alliance changes during TeleOp (EasyTeleOp.switchAlliance()), afterEasyTeleOp.alliance()has the new one: update what uses it. Default: nothing. Must not wait.- Overrides:
allianceChangedin classEasyTeleOp
-
bindButtons
Description copied from class:EasyTeleOpYour buttons. Put gamepad 2 buttons onoperator. Extra gamepad 1 buttons go ondriver: those pause while the tuning menu is open (it uses gamepad 1). Already taken on gamepad 1 (unless moved withEasyTeleOp.libraryButtons(LibraryButtons)): LT, Y (field-centric), BACK, START (with BACK: debug lines), GUIDE.- Overrides:
bindButtonsin classEasyTeleOp
-
buttonHelp
Description copied from class:EasyTeleOpThe 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:
buttonHelpin classEasyTeleOp
-
backTap
Description copied from class:EasyTeleOpWhat 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 BACKEasyTeleOp.BACK_HOLD_SECresets "forward". The buttons can be moved:EasyTeleOp.libraryButtons(LibraryButtons).- Overrides:
backTapin classEasyTeleOp
-
pauseState
Description copied from class:EasyTeleOpHow 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,EasyTeleOp.backTap()runs when BACK is let go. Controls.java gives one.- Overrides:
pauseStatein classEasyTeleOp
-
drive
protected final void drive(com.qualcomm.robotcore.hardware.Gamepad gamepad) Description copied from class:EasyTeleOpDrives 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, withEasyTeleOp.driving()'sdrive(...)ortank(...). Example, two-stick tank style:@Override protected void drive(Gamepad gamepad) { driving().tank(-gamepad.left_stick_y, -gamepad.right_stick_y, 1); }- Overrides:
drivein classEasyTeleOp
-
onStart
protected final void onStart()Description copied from class:EasyTeleOpRuns 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:
onStartin classEasyTeleOp
-
addTelemetry
Description copied from class:EasyTeleOpExtra lines for the Driver Station, every loop. The mechanisms' lines are already shown.- Overrides:
addTelemetryin classEasyTeleOp
-
route
protected final Runnable route(String label, double xIn, double yIn, double headingDeg, double maxPower) Makes a job that drives the robot to a field spot by itself, around the boxes offieldMap(...)in Robot.java. Call it inbuttons(...)and give the job to a button or a time. It works out the route when the job starts, from where the robot is then.Runnable park = route("Park", -56, -36, 0, 0.8); g1.dpadLeft.tap(park).says("drive to the park spot"); atSecondsLeft(10, park);Any drive stick stops it at once, and the sticks drive from then on. Pause and the tuning menu stop it too, and it stays stopped. It also ends when it is stuck, when the odometry stops working, or after
actionTimeoutSecon one line of the route; the Driver Station says why. It never waits: the rest of the robot keeps running. It cannot see another robot.Mistakes stop INIT: no
fieldMap(...)orodometry(...)line, a tank drive, or a spot on a box. In the match it does not set off without a known pose, and on a real robot only after the Drive Tuner and the Odometry Tuner (Tunables.Drive.calibrated,Tunables.Odometry.checked; the INIT screen warns). Docs: docs/modules/odometry.md, "Keep-out boxes and routes".- Parameters:
label- a name for the Driver StationxIn- inches right of the center line, written for BLUE likedriveToyIn- inches from the center toward the far wallheadingDeg- the heading to turn to (counterclockwise +; 0 = facing away)maxPower- 0.1 to 1- Returns:
- the job: it starts the route, and returns at once
-
route
protected final Runnable route(String label, double xIn, double yIn, double headingDeg, double maxPower, double toleranceIn) route(String, double, double, double, double)with your own "close enough" at the end, inches. -
routeRunning
protected final boolean routeRunning()True while aroute(java.lang.String, double, double, double, double)job drives the robot. -
stopRoute
protected final void stopRoute()Ends a runningroute(java.lang.String, double, double, double, double)job now (nothing happens if none runs). -
atSecondsLeft
Runs a job once, when this many seconds of TeleOp are left, e.g.atSecondsLeft(10, park). Call it inbuttons(...). The job must be quick, like a button's.A
route(java.lang.String, double, double, double, double)job does not take the robot from a driver who is driving. If a drive stick is pushed at that time (or the robot is paused, or the menu is open), the gamepad buzzes and the route waits up to 5 s. It starts on the first loop the sticks are let go. After 5 s it gives up.- Parameters:
seconds- seconds left on the clockjob- what to do
-
show
Shows a value of your own on the Driver Station during the match, read again every loop. Call it inbuttons(...), e.g.show("Lift ticks", robot.lift::position);orshow("Ready", () -> robot.launcher.isReady());.- Parameters:
label- the words before the valuevalue- how to read it (a method reference or a small lambda; it must not wait)
-
everyLoop
protected final void everyLoop()Description copied from class:EasyTeleOpYour 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:
everyLoopin classEasyTeleOp
-
atEnd
protected final void atEnd()Description copied from class:EasyTeleOpYour 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.- Overrides:
atEndin classEasyTeleOp
-
addInitTelemetry
Description copied from class:EasyTeleOpExtra lines for the Driver Station during INIT (before START), every INIT loop.- Overrides:
addInitTelemetryin classEasyTeleOp
-
requestOpModeStop
public final void requestOpModeStop()
-