Class TrackingStop

java.lang.Object
frc.spectrumLib.mechanism.TrackingStop

public final class TrackingStop extends Object
Latches a mechanism to a stop once it has stayed out of tolerance of its closed-loop goal for a debounce time: a jam, a slipped belt, a motor fighting a hard stop. The pattern is 6328's 2025 elevator, which stopped itself the same way rather than pushing into whatever held it.

Pure logic on values the caller reads from logged inputs, so it replays. The caller holds the motor in neutral while isStopped().

  • Constructor Summary

    Constructors
    Constructor
    Description
    TrackingStop(double tolerance, double debounceSeconds)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases the stop: the operator's override.
    double
     
    double
     
    boolean
    The error has been out of tolerance for the debounce time, whether or not that stops.
    boolean
    The mechanism is held in neutral until disabled or cleared.
    boolean
    update(double nowSeconds, boolean enabled, boolean connected, boolean closedLoop, double error, boolean act)
    Advances one loop.

    Methods inherited from class Object

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

    • TrackingStop

      public TrackingStop(double tolerance, double debounceSeconds)
      Parameters:
      tolerance - largest error that counts as tracking, in the units of the error passed to update(double, boolean, boolean, boolean, double, boolean)
      debounceSeconds - how long the error must stay out before it is a fault
  • Method Details

    • update

      public boolean update(double nowSeconds, boolean enabled, boolean connected, boolean closedLoop, double error, boolean act)
      Advances one loop.
      Parameters:
      nowSeconds - the robot clock
      enabled - the robot is enabled; disabling clears the stop
      connected - the motor answered this loop. A disconnected motor's readings are stale or zero, so they restart the debounce instead of counting toward it.
      closedLoop - the motor ran a closed-loop setpoint since the last loop
      error - measured minus goal
      act - latch the stop on a fault; false only reports the fault
      Returns:
      true on the loop the stop latches
    • clear

      public void clear()
      Releases the stop: the operator's override.
    • isFault

      public boolean isFault()
      The error has been out of tolerance for the debounce time, whether or not that stops.
    • isStopped

      public boolean isStopped()
      The mechanism is held in neutral until disabled or cleared.
    • getTolerance

      public double getTolerance()
    • getDebounceSeconds

      public double getDebounceSeconds()