EasyOpMode
EasyOpMode is a base class for your OpModes. It extends the SDK LinearOpMode and gives you a clear lifecycle, so you write only the parts that belong to your robot. You implement initialize() and onUpdate(); runOpMode() is final and runs the lifecycle for you.
#Lifecycle
Every EasyOpMode runs the same steps, in this order:
- 1. Reset: the command scheduler is reset.
- 2.
initialize(): create your hardware here and register components withaddComponents(...). - 3. Components init: every registered component receives
init(hardwareMap). - 4.
waitForStart(): theOpModewaits for Play. If stop is requested here, theOpModeends. - 5. Start: components receive
start(), thenonStart()runs once. - 6. Loop: each cycle runs
EasyDash.tick(), the componentsloop(),onUpdate()andtelemetry.update(). - 7. Stop: components receive
stop()in reverse order, thenonStop()runs and the scheduler is reset.
#What You Write
- abstract void
initialize(): build the hardware, create subsystems and add components. - void
onStart(): optional. Runs once after Play. - abstract void
onUpdate(): your loop body. - void
onStop(): optional. Stop mechanisms here. - protected scheduler: the shared
EasyCommandSchedulerinstance. addComponents(EasyComponent...): registers components. Duplicates and nulls are ignored.
#What EasyOpMode Does Not Do
EasyOpMode does not run the command scheduler by itself. It only runs the loop() of the components you added. If you use commands, triggers or default commands, add an EasyCommandComponent.
EasyOpMode also does not call EasyGamepad.update(). Call it at the start of onUpdate().
telemetry.update() is called for you at the end of every cycle, so do not call it again in onUpdate().
#Example
@TeleOp(name = "Shooter")
public class ShooterTeleOp extends EasyOpMode {
private final Shooter shooter = new Shooter();
private EasyGamepad driver;
@Override
public void initialize() {
driver = new EasyGamepad(gamepad1);
addComponents(
new EasySubsystemComponent(shooter),
new EasyCommandComponent());
driver.aButton().onPress(shooter.runOnce(shooter::toggle));
}
@Override
public void onUpdate() {
driver.update();
telemetry.addData("RPM", shooter.getRpm());
}
@Override
public void onStop() {
shooter.stop();
}
}The dashboard loop time is measured automatically because EasyOpMode calls EasyDash.tick() on every cycle.
Última actualización 2026-11-16