Double FlyWheel
We will learn how to program a Double FlyWheel shooter!
Mechanism classes are meant to be used with "tightly coupled" mechanisms where the Mechanism has 1 or more motor controlling it on a connected shaft, gearbox, or other linkage.
IF your mechanism is "loosely coupled", you CAN still use YAMS. HOWEVER you have to create and control the SmartMotorController directly as shown in How do I control a Mechanism without a Mechanism Class? OR use SmartMotorControllerConfig.withLooselyCoupledFollowers(SmartMotorController...)
Intro
At the end of this tutorial you will have a Double FlyWheel shooter with two independently controlled flywheels that will work in both real life and simulation with the same code! Double flywheels are commonly used in FRC games where spin control on the game piece is important - one wheel spinning faster than the other can add backspin or topspin to shots.
What is a Double FlyWheel?
A double flywheel is a shooter mechanism with two separate flywheels, typically arranged as:
Upper FlyWheel - Controls the top surface of the game piece
Lower FlyWheel - Controls the bottom surface of the game piece
By running these at different speeds, you can:
Add backspin for lob shots (upper faster than lower)
Add topspin for line drive shots (lower faster than upper)
Achieve neutral spin for consistent shots (equal speeds)
Details
This DoubleFlyWheel will use the following hardware specs and control details:
Two
TalonFX(Kraken X60) motors controlling each flywheel independently3:1GearBox on each flywheel4 inch diameter, 1 pound flywheels
Pressing
Awill set both flywheels to 3000 RPM (neutral spin)Pressing
Bwill set upper to 3500 RPM, lower to 2500 RPM (backspin)Pressing
Xwill set upper to 2500 RPM, lower to 3500 RPM (topspin)Pressing
Ywill stop both flywheels
Lets create a WPILib Command-Based Project!
IF you already have a project and know how to place the DoubleFlyWheel mechanism into your own subsystem please skip to Install YAMS!
Setup our Command-Based Project
Follow WPILib's tutorial on how to create a Command-Based project.
Bring up the Visual Studio Code command palette with Ctrl+Shift+P. Then, type "WPILib" into the prompt and select "Create a new project".
Click on Select a project type (Example or Template)
Select Template then Java then Command Robot
Click on Select a new project folder and select a folder to store your robot project in.
Fill in Project Name with the name of your robot code project.
Enter your Team Number
Be sure to check Enable Desktop Support so we can run simulations!
Install YAMS!
Click on the WPILib logo on the left pane. Scroll down to Yet Another Mechanism System and click Install!
Let's make a Double FlyWheel!
Using Loosely Coupled Followers
If your double flywheel design has both motors mechanically linked (same shaft), you can use loosely coupled followers instead of separate mechanisms:
Loosely coupled followers only forward velocity and position requests, NOT DutyCycle or Voltage requests. Use separate mechanisms when you need fully independent control.
Advanced: Dynamic Spin Control
For more advanced shot control, you can create a method that calculates spin ratios:
Summary
You now have a fully functional double flywheel shooter with:
Independent velocity control for upper and lower flywheels
Preset shot types (neutral, backspin, topspin)
Full simulation support
Telemetry for tuning both flywheels
The key differences from a single flywheel are:
Two separate
SmartMotorControllerConfiginstancesTwo separate
SmartMotorControllerinstancesTwo separate
FlyWheelmechanism instancesCommands that coordinate both flywheels using
Commands.parallel()
Last updated