Package ca.team4308.absolutelib.wrapper
Class AbsoluteSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
ca.team4308.absolutelib.wrapper.AbsoluteSubsystem
- Direct Known Subclasses:
Arm,Elevator,EndEffector,MotoredSubsystem,Pivot,SimulationBase
Extends SubsystemBase to provide logging capabilities and more helper
methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceInterface for custom logging backends. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringGets the base log channel for this subsystem.voidInitializes the subsystem.abstract Sendablelog()Provide a Sendable for telemetry/logging; may return null if unused.protected voidlogBoolean(String key, boolean value) Log a boolean value.protected voidLog an error.protected voidLog an error with throwableprotected voidLog info.protected voidLog a number value.protected voidLog a message only the first time for the given key.protected voidlogThrottle(String key, long minIntervalMs, String message) Throttled log: only logs if at least minIntervalMs since last time for the key.protected voidLog a warning.protected voidCalled during initialization.protected voidCalled after periodic execution.protected voidCalled before periodic execution.protected voidonStop()Hook: called when the subsystem is requested to stop.protected voidrecordOutput(String name, Object value) Record an output value for logging/telemetry.protected final voidrunPeriodicWithHooks(Runnable body) Helper to run a periodic body surrounded by pre/post hooks.protected voidWrap a runnable and log any thrown exception with a label.voidAllows external code to supply a custom backend implementation.voidstop()Stop the subsystem.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, periodic, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
AbsoluteSubsystem
public AbsoluteSubsystem()Constructs a new AbsoluteSubsystem.
-
-
Method Details
-
log
Provide a Sendable for telemetry/logging; may return null if unused.- Returns:
- the Sendable associated with this subsystem
-
getLogChannelBase
Gets the base log channel for this subsystem.- Returns:
- the log channel string
-
recordOutput
Record an output value for logging/telemetry. Uses AdvantageKit's Logger if available, otherwise falls back to SmartDashboard.- Parameters:
name- Key for the outputvalue- The value to record
-
logInfo
Log info.- Parameters:
message- the message to log
-
logWarn
Log a warning.- Parameters:
message- the message to log
-
logError
Log an error.- Parameters:
message- the message to log
-
logError
Log an error with throwable- Parameters:
message- the message to logt- the throwable
-
logNumber
Log a number value.- Parameters:
key- the keyvalue- the number
-
logBoolean
Log a boolean value.- Parameters:
key- the keyvalue- the boolean
-
logOnce
Log a message only the first time for the given key.- Parameters:
key- the unique key for this logmessage- the message
-
logThrottle
Throttled log: only logs if at least minIntervalMs since last time for the key.- Parameters:
key- the identifierminIntervalMs- the min intervalmessage- the message
-
runSafely
Wrap a runnable and log any thrown exception with a label.- Parameters:
label- the log labelbody- the runnable action
-
setCustomLoggingBackend
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
Helper to run a periodic body surrounded by pre/post hooks. Subclasses may call this fromSubsystem.periodic().- Parameters:
body- the executable logic
-
stop
public void stop()Stop the subsystem. Default implementation callsonStop(). -
onStop
protected void onStop()Hook: called when the subsystem is requested to stop. Default no-op.
-