Class MotorResetMonitor
java.lang.Object
frc.spectrumLib.mechanism.MotorResetMonitor
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanfilter(boolean connected, boolean rawReset) Turns Phoenix's raw reset flag into the logged input.intResets seen since boot.booleanThe motor rebooted since its position was last set.voidThe mechanism wrote a known position (it homed), so it can be trusted again.booleanupdate(boolean resetOccurred, boolean tracksPosition) Advances on this loop's logged reset input.
-
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 looprawReset-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 loggedResetOccurredinputtracksPosition- the mechanism relies on its position (it has soft limits)- Returns:
trueon 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.
-