Programming - Flywheel Control

All the flywheel controls are contained to the function setFlywheelVelocity.

Flywheel if/else statement for auto and manual controls

The flywheel has two main forms of operation:

  • Manual Control- This will spin up ONLY the flywheel to the target velocity. The driver can then manually spin the Core Hex to feed balls.

  • Auto Control- This will spin up the flywheel and activate the agigtator servo. Once the flywheel is in a specified range of the target velocity, the Core Hex will being to feed balls automatically. This is intended to be for a fully loaded robot to be able to make multiple shots in quick succession

Let's take a look at our entire if/else statement before exploring our Auto Control options.

Flywheel Control

Breakdown of flywheel buttons

When holding the "option" button on the gamepad, the flywheel will spin in reverse at half power. This is intended to help with freeing stuck balls if needed.

Reversing the flywheel

The left bumper or right bumper on the gamepad will request their specified function to run. We'll discuss these more below!

Activating the flywheel launcher's "auto" modes

When pressing the "circle" button, the flywheel will spin up to the set velocity for a "bank shot". This is the velocity for launching into the goal while against the goal or a couple inches back.

When pressing the "square" button, the flywheel will spin up to the set "max" velocity. This may be used for launching balls at the goal with adjustments to the deflector, however is intended mostly for teams wanting to explore working with the flywheel and differences in velocity.

Manual control for the flywheel

Be aware that launching balls at higher velocity can launch them to ceiling height. We do not recommend using this velocity option in rooms with low ceilings or hanging lights.

Turning off Actuators

Setting all actuators to 0 power or velocity

If no button is actively pressed on the gamepad, the flywheel, Core Hex feeder, and servo are told to set power or velocity to 0.

The servo has an additional check to allow manual control on the Dpad to override this function and prevent stuttering in the movements.

Check to prevent the servo from stuttering

Auto Launching with the Flywheel

While a bumper is pressed on the gamepad, the servo, Core Hex feeder, and flywheel will all activate with the intent to launch multiple balls in succession.

Bank "Near" Shot Auto

Code for the bank or "near" shot launching

When right bumper is held, the above sequence will run until release. This is intended for launching balls into the goal from against the goal or a couple inches back.

The flywheel is set to spin to the preset "bankVelocity" continously and the agigtator servo will activate.

Lastly, the robot will check first if the velocity of the flywheel is within 50 ticks below the "bankVelocity" before it will allow balls to fire. This value can be adjusted to be a bigger or tighter window if you notice the Core Hex is not feeding as expected.

Check to allow the flywheel to reach velocity between launches

"Far" Power Auto

Far power autonomous launching code

When the left bumper is held, the above sequence will run until release. This is intended for launching balls into the goal from a few feet back from the goal. This may require adjustments to the deflector if teams prefer this approach.

The flywheel is set to spin to the preset "farVelocity" continously and the agigtator servo will activate.

Similar to the bank auto, the robot will run a check to see if the flywheel velocity is currently within a specified window of the target "farVelocity" before it begins feeding. The default range is higher due to the increased velocity, but may be adjusted for further refinement.

In the default code example, there is not a check for if the flywheel's velocity is above the "bankVelocity" or "farVelocity" targets. Teams may consider adding this for additional refinement. Keep an eye out on our upgrades page for more information!

Last updated

Was this helpful?