githubEdit

Double FlyWheel

We will learn how to program a Double FlyWheel shooter!

triangle-exclamation

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 independently

  • 3:1 GearBox on each flywheel

  • 4 inch diameter, 1 pound flywheels

  • Pressing A will set both flywheels to 3000 RPM (neutral spin)

  • Pressing B will set upper to 3500 RPM, lower to 2500 RPM (backspin)

  • Pressing X will set upper to 2500 RPM, lower to 3500 RPM (topspin)

  • Pressing Y will stop both flywheels

Lets create a WPILib Command-Based Project!

circle-check

Setup our Command-Based Project

Follow WPILib's tutorialarrow-up-right 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".

  1. Click on Select a project type (Example or Template)

  2. Select Template then Java then Command Robot

  3. Click on Select a new project folder and select a folder to store your robot project in.

  4. Fill in Project Name with the name of your robot code project.

  5. Enter your Team Number

  6. 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!

1

Create our Subsystem with two SmartMotorControllerConfigs

We need separate configurations for each flywheel since they will be controlled independently.

2

Create our motor controllers

Create the vendor motor controller objects for each flywheel.

3

Create and Configure our FlyWheel mechanisms

Each flywheel gets its own FlyWheel mechanism for intuitive control.

4

Create Commands for our Double FlyWheel

Now we create command factory methods for different shot types.

5

Configure controller bindings in RobotContainer

Wire up the controller buttons to our shot types.

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:

circle-exclamation

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:

  1. Two separate SmartMotorControllerConfig instances

  2. Two separate SmartMotorController instances

  3. Two separate FlyWheel mechanism instances

  4. Commands that coordinate both flywheels using Commands.parallel()

Last updated