Skip to content

BrakelessReset

CaedmonM edited this page Jan 12, 2026 · 6 revisions

Static Badge

Usage

import com.btwrobotics.WhatTime.frc.BrakelessReset;

BrakelessReset is a WPILib Command that temporarily disables brake mode on a list of motors, allowing them to coast to a natural resting position. This is useful for recalibrating or zeroing encoders after the motors have moved freely.

Constructor

public BrakelessReset(double duration, List<BrakelessReset.MotorResetPair> pairs)
  • duration: How long (in seconds) to wait before running the reset actions.
  • pairs: A list of motor/action pairs that define which motors to set to coast and what reset action to run.

MotorResetPair

public static class MotorResetPair {
    public final MotorWrapper motor;
    public final Runnable resetAction;
}

Each motor is bundled with a Runnable that executes when the duration ends. This allows encoder zeroing or any custom logic.

Lifecycle Methods

initialize(): Sets all motors to Coast mode and starts a timer.

isFinished(): Returns true once the specified duration has elapsed.

end(): Runs each resetAction when the command finishes or is interrupted.

Example Usage

MotorWrapper armMotor = new MotorWrapper(new TalonFX(3), false);
Runnable zeroEncoder = () -> armMotor.getMotor().setPosition(0);

BrakelessReset.MotorResetPair pair = new BrakelessReset.MotorResetPair(armMotor, zeroEncoder);
BrakelessReset resetCommand = new BrakelessReset(1.5, List.of(pair));

This command disables braking on armMotor for 1.5 seconds, allowing the arm to drop to its lowest point, and then zeroes the encoder.

Clone this wiki locally