Class ControlMap<R extends RobotDefinition>
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
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 RunnablebackTap()What a tap of 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 booleanTrue if this class haspublic static boolean oneDriver = true.protected final voidonStart()Runs once, right after START, before the first loop.final voidprotected final Rrobot()The robot, made fromControlMap<Robot>'s type.protected final RobotConfigYour robot's settings, shared with autonomous (seeRobotConfig).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 booleanFalse to switch the modules' suggested buttons off (only Controls.java's jobs).Methods inherited from class com.crossbotics.ftchelper.teleop.EasyTeleOp
alliance, buzzAtSecondsLeft, configureDriving, createImu, driveConfig, driving, heading, isTuningMenuOpen, matchTimer, robotTelemetry, runOpMode, startFieldCentricMethods 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.- 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)
-
useStandardButtons
protected boolean useStandardButtons()False to switch the modules' suggested buttons off (only Controls.java's jobs). Default true. -
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).- 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
-
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: Y (field-centric; seeEasyTeleOp.fieldCentricButton()), BACK, START + BACK, 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 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".- Overrides:
backTapin 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
-
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
-
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()
-