Package com.crossbotics.ftchelper.teleop
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 = field-centric on/off (mecanum). - Field-centric "forward" continues from autonomous (
DriverHeading); BACK resets it. - The alliance from autonomous (
alliance()), 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 START + BACK, warnings for slow code, a tuned value or the PRACTICE profile. - 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
FieldsModifier and TypeFieldDescriptionstatic final doubleHow long BACK is held to reset "forward" when a tap of BACK has another job, seconds.com.qualcomm.robotcore.hardware.Gamepadcom.qualcomm.robotcore.hardware.Gamepadstatic final doubleHow long GUIDE is held to open the tuning menu when there is a button map, seconds.com.qualcomm.robotcore.hardware.HardwareMapstatic final intintDeprecated.org.firstinspires.ftc.robotcore.external.TelemetryFields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode
blackboard, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, time -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidExtra lines for the Driver Station during INIT (before START), every INIT loop.protected voidExtra lines for the Driver Station, every loop.protected Alliancealliance()The alliance autonomous chose (BLUE if no autonomous ran in the last few minutes).protected RunnablebackTap()What a tap of BACK does, or null (default): then BACK resets "forward".protected voidbindButtons(ControllerBindings driver, ControllerBindings operator) Your buttons.The button map's lines for the help page, or null (default) for none.protected double[]Seconds left when both gamepads buzz.protected voidconfigureDriving(DriverControls driving) Changes how driving feels, once, in INIT, right after the drive is made.protected DriverHeadingcreateHeading(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.IMUprotected SubsystemsYour mechanisms: kept updated every loop and stopped at the end.protected voiddrive(com.qualcomm.robotcore.hardware.Gamepad gamepad) Drives the robot from gamepad 1, every loop (not while the tuning menu is open).protected DriveConfigThe drivetrain settings.protected DriverControlsdriving()The driving (field-centric on/off, slow mode).protected voidYour own code for every loop, e.g.protected ControllerBindings.BtnThe gamepad 1 button that switches field-centric driving on and off (mecanum with an IMU only).protected DriverHeadingheading()The heading compared with the driver, or null if there is no IMU.protected booleanTrue while the tuning menu is open.protected MatchTimerThe 2:00 match timer (started at START).protected voidonStart()Runs once, right after START, before the first loop.final voidprotected RobotConfigYour robot's settings, shared with autonomous (seeRobotConfig).protected RobotTelemetryThe Driver Station screen helper (warnings, standard and debug lines).final voidThe whole TeleOp.protected doubleSpeed at a full squeeze of the slow trigger, 0 to 1.protected booleanTrue to start in field-centric mode.Methods 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
-
BACK_HOLD_SEC
public static final double BACK_HOLD_SECHow 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_SECHow 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.
-
-
Constructor Details
-
EasyTeleOp
public EasyTeleOp()
-
-
Method Details
-
robotConfig
Your robot's settings, shared with autonomous (seeRobotConfig). Returnnew RobotSettings(). If you do not have one, overridedriveConfig()andcreateImu()instead. -
driveConfig
The drivetrain settings. Default:robotConfig().drive(). -
createHeading
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 fromcreateImu(), or null
-
createImu
protected com.qualcomm.robotcore.hardware.IMU createImu() -
createSubsystems
Your mechanisms: kept updated every loop and stopped at the end. Default: none. -
bindButtons
Your 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; seefieldCentricButton()), BACK, START + BACK, 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. -
addTelemetry
Extra lines for the Driver Station, every loop. The mechanisms' lines are already shown. -
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. -
backTap
What a tap of BACK does, or null (default): then BACK resets "forward". With a job here (a Controls.java TeleOp: pause everything), holding BACKBACK_HOLD_SECresets "forward". -
addInitTelemetry
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
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 asstartFieldCentric()says). -
slowSpeed
protected double slowSpeed()Speed at a full squeeze of the slow trigger, 0 to 1. Default 0.3. -
configureDriving
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, withdriving()'sdrive(...)ortank(...). Example, two-stick tank style:@Override protected void drive(Gamepad gamepad) { driving().tank(-gamepad.left_stick_y, -gamepad.right_stick_y, 1); } -
alliance
The alliance autonomous chose (BLUE if no autonomous ran in the last few minutes). -
robotTelemetry
The Driver Station screen helper (warnings, standard and debug lines). -
driving
The driving (field-centric on/off, slow mode). -
heading
The heading compared with the driver, or null if there is no IMU. -
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. -
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:
runOpModein classcom.qualcomm.robotcore.eventloop.opmode.LinearOpMode
-
requestOpModeStop
public final void requestOpModeStop()
-