How do I shoot with a shooter?
Goal: hold a button to spin the shooter up, and have the feeder push the game piece in only once the wheel is at speed.
A shot has three parts:
Spin up: the shooter
FlyWheelgoes to a speed and holds it.Wait for speed: a
Triggerturns true once the wheel has been near that speed for 0.1 seconds.Feed: the feeder
FlyWheelpushes the game piece into the wheel while the trigger is true.
Before you start: build the shooter as in the Shooter/FlyWheels tutorial, and a feeder the same way as the intake in How do I set up an intake roller?, with its intake() command renamed feed(). The feeder keeps the intake's default command that stops it: stop() in Commands v2, idle() in Commands v3. The shooter and the feeder are separate subsystems, one YAMS mechanism each, so each can run its own command at the same time.

Spin up
Use the tutorial's shooter config as it is. Its gearing and gains are what let the wheel reach the shot speed: a NEO through a 1.5:1 reduction tops out near 3800 RPM at the wheel, kV of 0.19 volts per rotation per second gets it close to the target on feedforward alone, and kP of 0.2 fixes the rest and recovers after each shot. If your shooter has different gearing, find your own kV as in the tutorial's Tune it step: a first guess is 12 volts divided by the wheel's free speed in rotations per second.
Add these two methods to the shooter class:
The tutorial's atSpeed uses a 50 RPM tolerance and no debounce, which is fine for watching the wheel. Feeding needs the wider tolerance and the debounce: see the next step.
Check it: the code builds.
Wait for speed
Every shot takes speed out of the wheel, and the speed overshoots and rings as the closed loop brings it back. The 100 RPM tolerance keeps ready false while the wheel is too slow or too fast. The speed still passes through the tolerance for an instant on each swing, and the 0.1 second debounce ignores that: ready only turns true once the speed has stayed inside the tolerance. Without the debounce, the feeder pulses while the wheel is still ringing.
For a plain boolean outside of a Trigger, FlyWheel also has isNear(speed, tolerance).
Check it: you know the shot speed you will use, and it is well below the wheel's top speed of about 3800 RPM.
Check it
Start the simulation, and graph
NT:/Mechanisms/Shooter/ShooterMotor/mechanism/velocity(rotations per second; 3000 RPM is 50) and the feeder'sNT:/Mechanisms/Feeder/FeederMotor/motor/outputVoltagein AdvantageScope.FeederandFeederMotorare the telemetry names you gave the feeder's configs.Hold the right trigger. The shooter's speed should rise to about 50 rotations per second.
The feeder's voltage should go to 8 volts only after the shooter's speed has settled, not while it is still climbing.
If it did not work
The wheel settles below 3000 RPM and the feeder never runs.
kVis too low (or 0). Raise it until the wheel gets close on its own, then tunekP.The wheel never gets near 3000 RPM, even at full voltage. The gearing is too slow. Check
withGearing: the motor's free speed divided by the reduction must be well above the shot speed.The feeder pulses on and off. The tolerance is too tight, or the debounce is missing. Try 100 to 150 RPM and 0.1 seconds.
Something else. See Troubleshooting.
Last updated
Was this helpful?
