Shooter/FlyWheels
We will learn how to program an 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?
Intro
At the end of this tutorial you will have an Shooter that will work in both real life and simulation with the same code!

Details
This Shooter will be using the following hardware specs and control details
SparkMaxcontrolling theShooter12:1GearBox on theShooterPressing
Awill make theShootergo to 60 RPMPressing
Bwill make theShootergo to 300 RPMPressing
Xwill make theShooterspeed up.Pressing
Ywill make theShooterslow down.
Lets create a WPILib Command-Based Project!
IF you already have a project and know how to place the Shooter mechanism into your own subsystem please skip to Install YAMS!
Setup our Command-Based Project
Here we will 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. Since all WPILib commands start with “WPILib”, this will bring up the list of WPILib-specific VS Code commands. Now, select the “Create a new project” command:

This will bring up the “New Project Creator Window:”

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 in so you can deploy to your robot.
Be sure to check Enable Desktop Support so we can run simulations!
If you followed these instructions it should look something like whats filled out below.

Congratulations! You now have a Command Based robot project!

Install YAMS!
Click on the WPILib logo on the left pane. Scroll down to Yet Another Mechanism System and click Install!

Congratulations you have now installed YAMS! 🎉
Lets make a Shooter move!
Simulate our FlyWheel!
We can use our FlyWheel in simulation, with the exact same code that will control the real robot!

Connect an Xbox controller to your system and drag and drop from System Joysticks to Joystick[0]
Open up the Simulated mechanism with NetworkTables -> SmartDashboard -> Shooter-> mechanism

Resize ShooterMech/mechanism to your liking
Press Teleoperated in Robot State then you can use your controller like its controlling the real robot!

Congratulations on successfully programming your Shooter!! 🎉🎉
Last updated
