Stage 9: Closed-Loop Flywheel Velocity
Apply encoder feedback in Launcher.java. setPower() is still useful for many mechanisms, but a flywheel needs a measured velocity target that stays consistent as conditions change.
Your Task
- Change the flywheel to
DcMotorExand map it with the exact configured launcher name. - Select
RUN_USING_ENCODERand set reasonable velocity PIDF coefficients. - Scale the right trigger into a target velocity and call
setVelocity(). - Read
getVelocity()and report both target and measured values through telemetry.
Make the conversion readable enough that a teammate can change wheel size without rewriting the routine.
The simulator's small battery readout starts at 13.0 V and drains only while the OpMode is running. Compare an open-loop setPower() launcher with setVelocity(): the measured open-loop speed will fall with voltage, while a reachable velocity target should remain steady. If that loss continues long enough, the normal code-hint area will explain what the motor command is doing.
Coding Challenge Simulator
Passed every challenge check?
Mark the unit mastered to record every lesson objective and continue directly to the next unit. Your progress will be saved in this browser.
Stuck on this lesson?
Ask about anything on this page. It can see which lesson you have open and which part you are reading.