Class MotorResetMonitor

java.lang.Object
frc.spectrumLib.mechanism.MotorResetMonitor

public final class MotorResetMonitor extends Object
Tracks whether a motor has rebooted since its position was last set, so a homed mechanism stops trusting a position that restarted from the boot value.

A TalonFX that browns out or loses power keeps its flash config, but its position restarts from the boot value and its status-signal rates go back to defaults. Its Connected input comes back true, so nothing else notices.

Two halves, split at the log. filter(boolean, boolean) runs on the robot before the reading is logged, and turns Phoenix's raw flag into the logged ResetOccurred input. update(boolean, boolean) and positionRestored() run on that logged input, so they replay.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    filter(boolean connected, boolean rawReset)
    Turns Phoenix's raw reset flag into the logged input.
    int
    Resets seen since boot.
    boolean
    The motor rebooted since its position was last set.
    void
    The mechanism wrote a known position (it homed), so it can be trusted again.
    boolean
    update(boolean resetOccurred, boolean tracksPosition)
    Advances on this loop's logged reset input.

    Methods inherited from class Object

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

    • MotorResetMonitor

      public MotorResetMonitor()
  • Method Details

    • filter

      public boolean filter(boolean connected, boolean rawReset)
      Turns Phoenix's raw reset flag into the logged input. Robot side only: in replay the logged value replaces the result.
      Parameters:
      connected - the motor answered this loop
      rawReset - hasResetOccurred() this loop, which must be called every loop so a first-contact report is consumed
      Returns:
      the flag to log
    • update

      public boolean update(boolean resetOccurred, boolean tracksPosition)
      Advances on this loop's logged reset input.
      Parameters:
      resetOccurred - the logged ResetOccurred input
      tracksPosition - the mechanism relies on its position (it has soft limits)
      Returns:
      true on the loop a reset is seen
    • positionRestored

      public void positionRestored()
      The mechanism wrote a known position (it homed), so it can be trusted again.
    • isPositionLost

      public boolean isPositionLost()
      The motor rebooted since its position was last set.
    • getResets

      public int getResets()
      Resets seen since boot.