Skip to content
Work in progress. This library and its docs are new and still changing, and some parts are not yet tested on a real robot. If something is wrong or unclear,tell us with a short GitHub form.

Tutorial 17: Launcher

With the five files, the Launcher module builds all of this from Tunables.java: Add a launcher. Build it by hand here to see how a flywheel shooter works inside, or for a shooter the module does not fit.

You will build: a shooter that spins a flywheel, sets the hood angle from the distance, and feeds a piece only when everything is ready.

You need: motor flywheel (with its encoder cable), servo hood, motor feeder. Wear safety glasses: a flywheel throws things.

Full program: Tut17Launcher.java


A spinning wheel grabs the game piece and throws it. Two things decide where the piece lands: the wheel’s speed (RPM: turns per minute) and the angle the piece leaves at (the hood). Both depend on distance. One rule matters more than any other: never feed a piece into a wheel that is not up to speed. Otherwise the piece falls short.

Flywheel flywheel = Flywheel.create(hardwareMap, "flywheel")
.countsPerRev(28) // encoder counts per ONE flywheel turn
.maxRpm(6000) // the motor's top speed
.startingGains() // the hub's speed control (a start)
.tolerance(75) // "at speed" = within 75 rpm...
.settleTime(0.15); // ...for 0.15 s

The hub holds the speed itself with four gains: P, I, D and F (like Tutorial 07). startingGains() calculates them from maxRpm and countsPerRev with REV’s formula. The Flywheel Finder measures better gains for .pidf(p, i, d, f).

“Ready” needs the speed to STAY in the band for 0.15 s. So one lucky reading during spin-up does not count.

countsPerRev: a bare goBILDA/REV motor encoder gives 28 counts per motor turn.

  • Flywheel turns at the motor’s speed: 28.
  • Geared: multiply 28 by the motor turns per flywheel turn.
  • Encoder on the flywheel shaft (plugged into this motor’s encoder port): that encoder’s own counts per turn.

Check the reading: run at 3000 rpm. Compare with a tachometer (a tool that measures turning speed), or count turns in a slow-motion video. When the two do not match, countsPerRev is wrong.

PositionServo hood = PositionServo.create(hardwareMap, "hood")
.degrees(0.10, 0, 0.90, 25) // measured: raw 0.10 = 0 deg, raw 0.90 = 25 deg
.travelTime(0.4);
MotorFeeder feeder = MotorFeeder.create(hardwareMap, "feeder").power(1.0).feedTime(0.25);
  1. The hood works in degrees: two measured points and a straight line in between.
  2. The servo needs about 0.4 s for a full move. A servo cannot report where it is. So the launcher uses this number to know when the hood has arrived.
  3. Full power (1.0) for 0.25 seconds pushes one piece into the flywheel.

Any part that goes to an angle can be the hood (an AngleDevice). To measure the two points: Hood Finder.

ShotTable table = new ShotTable()
.add(24, 2600, 6)
.add(48, 3100, 14)
.add(72, 3700, 21);

Each row is a distance (in), an rpm and a hood angle (degrees). Between the rows, the table draws straight lines. Outside them, it uses the nearest end, so it never guesses past what you tested.

To find the numbers by hand with this program:

  1. Press X on gamepad 1: manual rpm mode. D-pad left/right = rpm -/+ 100.
  2. Put the robot 24 in from the target. Measure with a tape, to the same edge of the robot every time.
  3. Find the rpm and hood angle where 5 shots in a row score. Write them down.
  4. Repeat at 3-5 distances, across the area you will shoot from.

The Shot Tuner does the same and prints the new ShotTable() lines: Shot Tuner. Different game pieces (2026-27: POLLEN and NECTAR) may need their own tables.

Launcher launcher = new Launcher(flywheel, feeder)
.hood(hood)
.table(table)
.shotInterval(0.3)
.readyTimeout(2.5);
...
launcher.setDistance(distanceIn); // every loop: rpm + hood from the table
launcher.update();
.bindPress(Pad.G2, Btn.A, launcher::spinUp)
.bindPress(Pad.G2, Btn.RB, () -> launcher.shoot(1))
.bindPress(Pad.G2, Btn.LB, () -> launcher.shoot(3))
.bindPress(Pad.G2, Btn.B, launcher::idle)

shoot() does not wait, so the robot keeps driving. launcher.update() feeds each piece when everything is ready. shotInterval(0.3) gives the flywheel 0.3 s to get back to speed between pieces. shoot(3) does these steps:

  1. Spin up, when the flywheel is not spinning yet.
  2. Wait until the flywheel is ready AND the hood has arrived (AND any requireReady checks, like an aimed turret).
  3. Feed one piece.
  4. Wait shotInterval, then repeat.

When it is not ready within readyTimeout, it gives up and says why: “gave up: flywheel”.

  1. Put on safety glasses. Start with no game piece. Press ▶ (start on the Driver Hub).
  2. Press A: telemetry shows about “2850 / 2850 rpm READY” (the program starts at 36 in).
  3. Press RB without a piece: the feeder runs once. LB: three times, 0.3 s apart.
  4. With pieces, D-pad up/down changes the distance, and the hood moves. Shoot.
  5. Stop the OpMode and unplug the flywheel’s encoder cable. Run again and shoot(1). The flywheel can never read “ready”, so the launcher waits, then shows “gave up: flywheel”. That is the safety rule at work. Plug the cable back in.
Problem Fix
Never READY countsPerRev is wrong (the speed reads wrong), or the F gain is too low (the wheel never reaches the speed).
Speed overshoots then settles slowly Lower P. Tune F first, so the speed gets close by itself.
Shots fall short when shooting fast shotInterval is too short: the wheel has not recovered.
Hood never “arrives” travelTime is too long. Measure it.
“gave up: hood” The hood’s travelTime is longer than readyTimeout.
  1. Add .requireReady("Driver", () -> gamepad2.right_trigger > 0.5): then the launcher shoots only while the driver holds the trigger.
  2. Add .idleRpm(1500): a slow idle makes spin-up faster. Measure the difference.
  3. Add a second table for another game piece, and switch tables with a button.

Next: Tutorial 18: Vision aiming Look it up: launcher.md

Something wrong on this page? Tell us with a short GitHub form.