Class FlywheelFinderOpMode

java.lang.Object
com.qualcomm.robotcore.eventloop.opmode.OpMode
com.qualcomm.robotcore.eventloop.opmode.LinearOpMode
com.crossbotics.ftchelper.finders.FinderOpMode
com.crossbotics.ftchelper.finders.FlywheelFinderOpMode

public abstract class FlywheelFinderOpMode extends FinderOpMode
Finds a flywheel's speed-control numbers. Step 1 measures the top speed at full power and works out starting gains from it. Step 2 holds a speed you choose, so you can fine-tune the main gain (F), feed a piece (with the feeder or a stick, never fingers), and see how fast the wheel gets back to speed after a shot. No code to write: it lists every motor in the robot configuration.

It shows the code for Flywheel and, for the robot in five files, the line for Tunables.java: Tunables.Launcher: kP = 1.17, kI = 0.117, kD = 0, kF = 11.70, nominalVolts = 12.6. nominalVolts is the battery voltage while the top speed was measured: the gains are right for that voltage, and the launcher's battery compensation scales F from it. In step 2 the compensation is on too (from that voltage), so F changes are for the same voltage.

 Choose:  D-pad up/down = motor, A = use it (the list starts on Robot.java's flywheel motor, or a name like "flywheel")
 Step 1:  hold A = full power (at most 5 s). Release when the speed stops rising. Still rising at
          5 s (a heavy wheel)? It says so: the top speed may be higher, so F is a little high.
 Step 2:  B = hold a speed on/off. D-pad up/down = +/- 100 RPM, right/left = +/- 25 RPM.
          RB / LB = F gain +2% / -2%. Feed a piece with the feeder or a stick (never fingers): it shows the recovery time.
          From Tune and check with kP, kI and kF in Tunables.java: step 2 holds with THOSE gains (and their battery
          compensation), so step 1 is not needed and RB / LB fine-tune the kF the robot uses. Y = this finder's own
          gains from the top speed (after step 1), and back.
          X = the wheel spins the wrong way: reverse it (for both steps; adds .reversed())
          (From Tune and check, a motor starts the way Robot.java turns it: reversed() there = reversed here.)
          BACK = choose another motor
 Help: GUIDE (or hold START 1 s) = a help page with every button; everything pauses.
 
KEEP HANDS AND LOOSE CLOTHING AWAY from the wheel; wear eye protection. In your TeamCode: @TeleOp(name = "Flywheel Finder", group = "Finders") public class FlywheelFinder extends FlywheelFinderOpMode { }. If the encoder is not on the motor's own shaft at 28 counts per turn, override countsPerRev(). Docs: docs/modules/finders.md. Guide: docs/tuning/README.md
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    com.qualcomm.robotcore.hardware.Gamepad
     
    com.qualcomm.robotcore.hardware.Gamepad
     
    com.qualcomm.robotcore.hardware.HardwareMap
     
    static final double
    The longest full-power run in step 1, seconds.
    static final int
     
    int
    Deprecated.
    org.firstinspires.ftc.robotcore.external.Telemetry
     

    Fields inherited from class com.crossbotics.ftchelper.finders.FinderOpMode

    results, t

    Fields inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    blackboard, msStuckDetectInit, msStuckDetectInitLoop, msStuckDetectLoop, msStuckDetectStart, time
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Binds gamepad 1 buttons.
    protected double
    Encoder counts per ONE turn of the flywheel.
    protected String
    The finder's name, e.g.
    protected String[]
     
    protected Map<String,Boolean>
    The direction Robot.java gives each flywheel motor it knows (true = reversed() on the launcher).
    protected void
    Stops what moves, while the help page is open (the finder's buttons pause then).
    final void
     
    protected Map<String,double[]>
    The speed-control gains Tunables.java has for each flywheel motor: {kP, kI, kD, kF, nominalVolts} (nominalVolts NaN = no battery compensation).
    protected void
    Sets up the hardware, in INIT.
    protected void
    The finder's own screen lines, every loop.
    protected void
    What INIT shows (the controls, a safety note).
    protected void
    Runs once every loop after the buttons: moves things, measures.
    protected void
    Stops every motor and servo it moves.

    Methods inherited from class com.crossbotics.ftchelper.finders.FinderOpMode

    batteryMatters, helpKeyDown, inInit, inputsReady, openHelp, runInside, running, runOpMode

    Methods inherited from class com.qualcomm.robotcore.eventloop.opmode.LinearOpMode

    idle, init, init_loop, isStarted, isStopRequested, loop, opModeInInit, opModeIsActive, sleep, start, stop, waitForStart

    Methods inherited from class com.qualcomm.robotcore.eventloop.opmode.OpMode

    getRuntime, internalPostInitLoop, internalPostLoop, internalPreInit, internalUpdateTelemetryNow, resetRuntime, terminateOpModeNow, updateTelemetry

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_TOP_SPEED_SEC

      public static final double MAX_TOP_SPEED_SEC
      The longest full-power run in step 1, seconds.
      See Also:
    • MS_BEFORE_FORCE_STOP_AFTER_STOP_REQUESTED

      public static final int MS_BEFORE_FORCE_STOP_AFTER_STOP_REQUESTED
      See Also:
    • gamepad1

      public volatile com.qualcomm.robotcore.hardware.Gamepad gamepad1
    • gamepad2

      public volatile com.qualcomm.robotcore.hardware.Gamepad gamepad2
    • telemetry

      public org.firstinspires.ftc.robotcore.external.Telemetry telemetry
    • hardwareMap

      public volatile com.qualcomm.robotcore.hardware.HardwareMap hardwareMap
    • msStuckDetectStop

      @Deprecated public int msStuckDetectStop
      Deprecated.
  • Constructor Details

    • FlywheelFinderOpMode

      public FlywheelFinderOpMode()
  • Method Details

    • countsPerRev

      protected double countsPerRev()
      Encoder counts per ONE turn of the flywheel. Default 28: a goBILDA or REV motor's own encoder, with the wheel on the motor shaft (1:1). Geared? Multiply by the gear ratio.
    • motorDirections

      protected Map<String,Boolean> motorDirections()
      The direction Robot.java gives each flywheel motor it knows (true = reversed() on the launcher). The finder starts a motor in that direction, so the wheel spins the way it does in TeleOp, and the numbers fit Robot.java as it is. A motor not in the map starts forward. Default: none (your own finder; set it in a subclass). Tune and check fills it from Robot.java.
      Returns:
      motor name (as in the robot configuration) to reversed; never null
    • robotGains

      protected Map<String,double[]> robotGains()
      The speed-control gains Tunables.java has for each flywheel motor: {kP, kI, kD, kF, nominalVolts} (nominalVolts NaN = no battery compensation). The finder holds the wheel with them in step 2, so a fine-tuned F (RB/LB) fits the kP and kI the robot really uses; Y switches to the finder's own gains from the top speed. Default: none (your own finder). Tune and check fills it from Tunables.java.
      Returns:
      motor name to its gains; never null
    • finderName

      protected String finderName()
      Description copied from class: FinderOpMode
      The finder's name, e.g. "Servo finder".
      Specified by:
      finderName in class FinderOpMode
    • setup

      protected void setup()
      Description copied from class: FinderOpMode
      Sets up the hardware, in INIT. Nothing may move here.
      Specified by:
      setup in class FinderOpMode
    • showInit

      protected void showInit(RobotTelemetry t)
      Description copied from class: FinderOpMode
      What INIT shows (the controls, a safety note).
      Overrides:
      showInit in class FinderOpMode
    • bind

      protected void bind(ControllerBindings c)
      Description copied from class: FinderOpMode
      Binds gamepad 1 buttons. Actions must be quick: never wait.
      Specified by:
      bind in class FinderOpMode
    • step

      protected void step()
      Description copied from class: FinderOpMode
      Runs once every loop after the buttons: moves things, measures. Never waits.
      Specified by:
      step in class FinderOpMode
    • show

      protected void show(RobotTelemetry t)
      Description copied from class: FinderOpMode
      The finder's own screen lines, every loop.
      Specified by:
      show in class FinderOpMode
    • helpLines

      protected String[] helpLines()
      Overrides:
      helpLines in class FinderOpMode
    • pause

      protected void pause()
      Description copied from class: FinderOpMode
      Stops what moves, while the help page is open (the finder's buttons pause then). Default: FinderOpMode.stopAll(). A finder overrides it when stopAll() also closes something (a camera) that must keep working.
      Overrides:
      pause in class FinderOpMode
    • stopAll

      protected void stopAll()
      Description copied from class: FinderOpMode
      Stops every motor and servo it moves. Called at the end, always.
      Specified by:
      stopAll in class FinderOpMode
    • requestOpModeStop

      public final void requestOpModeStop()