Programming - Initialization

This walkthrough is for the example program that DOES NOT include autonomous. For the autonomous program click here!

Before the bulk of our program begins, we need to first establish our variables and tell our motors how we want them to run. This section of code will run once when the program is activated and before we hit "Play" on the Driver Hub.

Initialization Code

Motor and Servo Settings

Since we are going to be using velocity control for our flywheel, we need to set it up to run with encoders enabled. It has also been set to be reversed due to the direction it rests on our robot. Our Core Hex being used for the feeder is reversed for a similar reason.

Meanwhile the motors on our drivetrain are a mirror of each other, therefore one needs to be set to run in reverse. In this case, we have the leftDrive motor set to run in reverse.

Lastly, our servo is set to no power. Though it's not being used quite yet this helps to make sure it's properly enabled for when it's later called. You may hear it twitch slightly when initializing the program!

Initializing Variables

The three variables used in our program this year are used to set targets for what velocity our flywheel needs to reach. If at any time the target velocity needs to be adjusted it only has to be updated here to reflect through the whole code!

Variable
Purpose

bankVelocity

The flywheel velocity target for launching balls while against, or close to the goal

farVelocity

The flywheel velocity target for launching balls from a few feet back from the goal

maxVelocity

The "max" velocity for the flywheel. This can be increased, but is not recommended

Variations in your robot build may require these values to be changed. For example, adjusting the deflector may allow the robot to do far shots from further away.

We encourage experimenting with different velocities to determine what works best for your team and robot!

Last updated

Was this helpful?