Class AbsoluteSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
ca.team4308.absolutelib.wrapper.AbsoluteSubsystem
All Implemented Interfaces:
Sendable, Subsystem
Direct Known Subclasses:
Arm, Elevator, EndEffector, MotoredSubsystem, Pivot, SimulationBase

public abstract class AbsoluteSubsystem extends SubsystemBase
Extends SubsystemBase to provide logging capabilities and more helper methods.
  • Constructor Details

    • AbsoluteSubsystem

      public AbsoluteSubsystem()
      Constructs a new AbsoluteSubsystem.
  • Method Details

    • log

      public abstract Sendable log()
      Provide a Sendable for telemetry/logging; may return null if unused.
      Returns:
      the Sendable associated with this subsystem
    • getLogChannelBase

      protected String getLogChannelBase()
      Gets the base log channel for this subsystem.
      Returns:
      the log channel string
    • recordOutput

      protected void recordOutput(String name, Object value)
      Record an output value for logging/telemetry. Uses AdvantageKit's Logger if available, otherwise falls back to SmartDashboard.
      Parameters:
      name - Key for the output
      value - The value to record
    • logInfo

      protected void logInfo(String message)
      Log info.
      Parameters:
      message - the message to log
    • logWarn

      protected void logWarn(String message)
      Log a warning.
      Parameters:
      message - the message to log
    • logError

      protected void logError(String message)
      Log an error.
      Parameters:
      message - the message to log
    • logError

      protected void logError(String message, Throwable t)
      Log an error with throwable
      Parameters:
      message - the message to log
      t - the throwable
    • logNumber

      protected void logNumber(String key, double value)
      Log a number value.
      Parameters:
      key - the key
      value - the number
    • logBoolean

      protected void logBoolean(String key, boolean value)
      Log a boolean value.
      Parameters:
      key - the key
      value - the boolean
    • logOnce

      protected void logOnce(String key, String message)
      Log a message only the first time for the given key.
      Parameters:
      key - the unique key for this log
      message - the message
    • logThrottle

      protected void logThrottle(String key, long minIntervalMs, String message)
      Throttled log: only logs if at least minIntervalMs since last time for the key.
      Parameters:
      key - the identifier
      minIntervalMs - the min interval
      message - the message
    • runSafely

      protected void runSafely(String label, Runnable body)
      Wrap a runnable and log any thrown exception with a label.
      Parameters:
      label - the log label
      body - the runnable action
    • setCustomLoggingBackend

      public void setCustomLoggingBackend(AbsoluteSubsystem.LoggingBackend custom)
      Allows external code to supply a custom backend implementation.
      Parameters:
      custom - the custom backend
    • initialize

      public void initialize()
      Initializes the subsystem.
    • onInitialize

      protected void onInitialize()
      Called during initialization.
    • onPrePeriodic

      protected void onPrePeriodic()
      Called before periodic execution.
    • onPostPeriodic

      protected void onPostPeriodic()
      Called after periodic execution.
    • runPeriodicWithHooks

      protected final void runPeriodicWithHooks(Runnable body)
      Helper to run a periodic body surrounded by pre/post hooks. Subclasses may call this from Subsystem.periodic().
      Parameters:
      body - the executable logic
    • stop

      public void stop()
      Stop the subsystem. Default implementation calls onStop().
    • onStop

      protected void onStop()
      Hook: called when the subsystem is requested to stop. Default no-op.