EasyStack Docs

Components

Esta página ainda não foi traduzida. Mostrando a versão em inglês.

A component is a small object with four optional hooks. Components keep the OpMode short and let you reuse behavior between OpModes. EasyOpMode calls their hooks at the right moment of the lifecycle.

#EasyComponent

The interface has four default methods. Override only the ones you need:

Java
public interface EasyComponent {
    default void init(HardwareMap hardwareMap) {}
    default void start() {}
    default void loop() {}
    default void stop() {}
}
  • init(hardwareMap): called once after initialize(), before waitForStart().
  • start(): called once after Play.
  • loop(): called every cycle before onUpdate().
  • stop(): called when the OpMode ends, in reverse order of registration.

#EasyCommandComponent

Runs the command scheduler. It calls scheduler.run() every loop and scheduler.cancelAll() on stop. A second constructor takes a custom EasyCommandScheduler.

Without it, commands, triggers and default commands never run.

#EasySubsystemComponent

Takes any number of subsystems. It calls init(hardwareMap) on each one, then loop() every cycle. The subsystems are also registered with the dashboard.

Java
addComponents(
        new EasySubsystemComponent(shooter, intake),
        new EasyCommandComponent());

#Order Matters

Components run in the order they were added. Put the subsystem component before the command component when your subsystems must update before commands run.

#Writing Your Own Component

Java
public class BatteryWarning implements EasyComponent {

    private VoltageSensor sensor;

    @Override
    public void init(HardwareMap hardwareMap) {
        sensor = hardwareMap.voltageSensor.iterator().next();
    }

    @Override
    public void loop() {
        if (sensor.getVoltage() < 11.5) {
            EasyDash.warn("Low battery");
        }
    }
}

Última atualização 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.