Skip to content

Writing Auto OpModes

Autonomous OpModes in CoreControl are structured around two main commands: an initCommand (runs during initialization) and a startCommand (runs when the match starts). This structure encourages a clean, command-based approach to autonomous programming.

To create an Autonomous OpMode, extend CoreAuto.

@Autonomous(name = "Red Auto")
class RedAuto : CoreAuto(
// Register modules
modules = arrayOf(Drivetrain, Intake, Lift),
// Command to run during initialization
initCommand = instant {
Lift.resetEncoders()
Intake.closeClaw()
},
// Command to run when the match starts
startCommand = sequentially(
// Drive to position
DriveToPosition(10.0, 0.0),
// Score pixel
Lift.goToPosition(1000),
Intake.openClaw(),
wait(0.5),
Lift.goToPosition(0),
// Park
DriveToPosition(0.0, 24.0)
)
)
  1. Init Command: Use initCommand to perform setup tasks like resetting encoders, closing claws, or initializing vision pipelines. This command runs once when you press INIT.
  2. Start Command: Use startCommand to define your main autonomous sequence. This command runs once when you press PLAY.
  3. Command Groups: Use sequentially, inParallel, and racing to combine simple commands into complex behaviors.
  4. No Loop Logic: Unlike TeleOp, you generally do not need to override onMainLoop in CoreAuto. The command scheduler handles everything for you.