Skip to content

Fix three wheel tuners ignoring custom drive motor names - #121

Merged
BaronClaps merged 1 commit into
Pedro-Pathing:masterfrom
jaxley:fix/three-wheel-tuner-custom-names
Oct 15, 2026
Merged

BaronClaps merged 1 commit into
Pedro-Pathing:masterfrom
jaxley:fix/three-wheel-tuner-custom-names

Conversation

@jaxley

@jaxley jaxley commented Oct 15, 2026

Copy link
Copy Markdown

Problem

The Three Wheel and Three Wheel + IMU tuners prompt for custom odometry encoder names, but localizer() in both procedures looks up the drive motors to float by the hardcoded defaults lf, lr, rf, rr:

for (String name : new String[]{"lf", "lr", "rf", "rr"}) {
    DcMotorEx motor = map.get(DcMotorEx.class, name);   // throws if absent
    motor.setPower(0);
    motor.setDirection(name.equals("lf") || name.equals("lr")
            ? DcMotorSimple.Direction.REVERSE : DcMotorSimple.Direction.FORWARD);
    motor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.FLOAT);
}

Two consequences:

  1. Robots with custom drive motor names crash the moment tuning starts. HardwareMap.get throws for missing names, killing the procedure on the default names — which looks exactly like "the tuner only uses the default names." The Mecanum tuner does not have this problem because it spins exactly the motors you enter.
  2. setDirection() silently perturbs measured encoder polarity. Encoder.getMultiplier() folds in the motor's direction, so forcing REVERSE on the lf/lr ports flips the sign of any encoder sharing that port mid-procedure — baking a reversal into the tuned config that does not exist in the robot's real setup.

The generated ThreeWheelConfig/ThreeWheelIMUConfig encoder names themselves are applied correctly (the input plumbing is fine); the bug is this hardcoded float loop.

Fix

In both ThreeWheelTuner and ThreeWheelIMUTuner:

  • Add four drive motor name inputs to the setup screen (defaults lf, lr, rf, rr), mirroring the existing encoder-name fields.
  • Use the entered names in the float loop via HardwareMap.tryGet, skipping motors that are not present instead of crashing the procedure.
  • Drop the setDirection() call — power 0 + FLOAT is all the measurements need.

Affected tuners

  • ThreeWheelTuner — fixed
  • ThreeWheelIMUTuner — fixed (identical loop)
  • TwoWheelTuner, PinpointTuner, OTOSTuner, OctoQuadTuner, MecanumTuner — audited, clean (no hardcoded device lookups)

Both changed files compile cleanly against the published artifacts (com.pedropathing:core/revhub 3.0.1, tuning 1.0.1, FTC RobotCore/Hardware), and HardwareMap.tryGet is confirmed present in the SDK.

The ThreeWheelTuner and ThreeWheelIMUTuner prompted for custom odometry
encoder names, but the localizer() helper still looked up drive motors
by the hardcoded defaults lf/lr/rf/rr. Robots whose drive motors have
custom HardwareMap names crashed the moment tuning started, and the
forced setDirection() on the lf/lr ports silently perturbed the encoder
polarity measured during tuning.

- Add four drive motor name inputs (defaults lf, lr, rf, rr) to the
  setup screens of both tuners
- Use the entered names in the float loop via HardwareMap.tryGet so
  missing motors are skipped instead of crashing the procedure
- Drop the setDirection() call: power 0 + FLOAT is all the
  measurements need, and mutating motor direction flips the sign of
  any encoder sharing that port
@BaronClaps
BaronClaps merged commit 14eaf70 into Pedro-Pathing:master Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants