For the complete documentation index, see llms.txt. This page is also available as Markdown.

Programming - Auto

The autonomous program for the 2026-27 Starter Bot has the robot move forward from the starting location then launch the preloaded Pollen into the Hive. An optional delay is available so that the robot can either start on the high end of the Hive or wait until after your alliance partner launches their preloads and shifts the goal on the other side!

Auto Initialization

Initialization for the Auto OpMode

During initialization, the robot will complete a few tasks in preparation for "Play" being pressed. Similarly to the TeleOp code, one of the drivetrain motors must be reversed and the flywheel motor told to use the encoder.

The targetVelocity variable is set to the same as in TeleOp, but another variable is created here. The autoTimer sets up our ElapsedTime timer that we will be using during the auto period!

What is ElapsedTime?

What do you think of when you think of a timer? A stopwatch? Your phone? Maybe the timer on a microwave or oven? Timers commonly consist of two main categories: count up and count down. You can think about the differences of these two by a comparison like keeping track of how fast a runner did a 100m dash vs. needing to know how much longer our food should cook.

ElapsedTime is a count up timer. Registering the amount of time elapsed from the start of a set event, like the starting of a stopwatch. In this situation, it is the amount of time passed from when the timer is created or reset within the code.

Optional Delay

At the very start of the auto OpMode, after "Play" is pressed, the pollenServo will move to it's 1 position if not already there.

Reset the servo to be up

Then there is a disabled block in the sample code.

Sleep Block to add a delay to the start of the program

This sleep call is available to force the OpMode to wait before beginning the code proper. During this time we don't want the robot to do anything so we'll tell it to sleep for 10 seconds then begin.

If your team's strategy is to wait on the low side of the Hive, with the intention of launching your preloads after your alliance partner has gone and shifted the Hive up, then enable this block! Be sure to check how long the sleep period should be to make sure there is enough time to execute the full auto.

Blocks can be enabled/disabled by right clicking, then selecting the option as seen here:

Driving Forward

The timer used for ElapsedTime begins as soon as the OpMode is initialized. Since it's hard to plan for how long it's been running, we'll first simply reset the timer before using it.

Resetting the autoTimer

Next, we have a loop for the robot to move for 0.7 seconds to reposition from the wall.

Code for backing up for 0.7 seconds

How long the robot needs to move may vary per robot build. Be sure to test this and make adjustments for your final design!

Loop Controls

Looking more closely at the loop, there are two checks. The loop while continue so long as BOTH are true. A check for if opModeIsActive, meaning if the "Play" has been pressed, should always be used with loops to ensure the OpMode executes properly and safely disables when needed!

Checks for the loop

The other check looks at if the autoTimer is still less than or equal to 0.7 seconds. Remember we just restarted the timer so it'll be at 0 when entering the loop!

Stopping

During the loop, the robot will send -0.25 power to the drivetrain motors to move slowly away. Since the recommended orientation for starting is the robot sitting with the front side (intake) to the wall, the robot must back up or use negative power.

Motor power for reversing then coming to a stop

After the 0.7 seconds is over, the motors are told to go to 0 power to prevent any extra movement. At this point the robot is in place and ready to launch!

Flywheel Auto Sequence

Before our next loop begins, we'll reset our timer again so it starts from 0 and is easier to make adjustments to the program.

Resetting the autoTimer

Similar to the driving portion of the code, the loop will continue while the OpMode is active AND the timer is less than or equal to 15 seconds. Make sure to test this amount of time and adjusted it based on your robot and strategy!

Checks for the second loop

Launching Pollen

Once the loop begins, the flywheel will turn on to get up to velocity.

Activating the flywheel to spin to velocity

Before feeding in game pieces, the robot will check if the flywheel's velocity is within a specified range of the targetVelocity, similar to the TeleOp code.

The range is larger than when running the TeleOp program, but it's recommended to do some testing with your final robot to adjust this range appropriately!

Check for if the flywheel velocity is within a specified range

If the velocity is within range, then the servo feeder AND intake will begin moving game pieces into the flywheel shoot to be launched.

Activating the servo and intake motor if true

If the velocity is out of range, the servo feeder and intake will turn off. This may cause what appears to be "stuttering" or "rubberbanding" while the flywheel stabilizes to the correct velocity.

Turning off the servo and motor if false

Once the 15 seconds for the flywheel portion of the code ends the program will stop!

Last updated

Was this helpful?