Programming - Flywheel Control
All the flywheel controls are contained to the function setFlywheelVelocity.

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

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.

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

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.

Turning off Actuators

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.

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

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.

"Far" Power Auto

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.
Last updated
Was this helpful?