Class AbstractSubsystem<TConfig extends AbstractSubsystemConfig>
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable,edu.wpi.first.wpilibj2.command.Subsystem
- Direct Known Subclasses:
AbstractMotorSubsystem,AprilTagVisionSubsystem,DriveBaseSubsystem,GameplayStateSubsystem,RobotPoseSubsystem
Extend this class to gain a shared logger, access to the loaded configuration, and convenience helpers for checking whether the subsystem should
run on real hardware. The enabled flag should gate any device actions in concrete subclasses.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringCached class name used for logging prefixes.protected TConfigSubsystem configuration bundle loaded from JSON.protected booleanTrue when the subsystem is allowed to run hardware actions.protected static doubleNominal loop period in seconds for controller updates.protected LoggerLogger instance scoped to the subsystem.protected booleanTrue when verbose logging is enabled for this subsystem. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSubsystem(TConfig config) Creates a subsystem base with shared configuration and logging support. -
Method Summary
Modifier and TypeMethodDescriptionReturns the subsystem configuration bundle for command factories and external consumers that need access to subsystem-specific settings.protected booleanReports whether the robot is attached to the FMS at call time.protected booleanReports whether the code is running in WPILib simulation.booleanStates whether this subsystem is marked as disabled in configuration.booleanReports whether verbose telemetry and debug output are enabled for this subsystem.booleanReports whether verbose AdvantageKit output should be recorded this cycle.protected voidlogDisabled(String methodName) Logs a standardized message when a call is skipped due to disable state.protected voidreportWarning(String message, boolean printStackTrace) Reports a recoverable warning to the Driver Station console.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
-
Field Details
-
kDt
protected static double kDtNominal loop period in seconds for controller updates. -
config
Subsystem configuration bundle loaded from JSON. -
className
Cached class name used for logging prefixes. -
verbose
protected boolean verboseTrue when verbose logging is enabled for this subsystem. -
log
Logger instance scoped to the subsystem. -
enabled
protected boolean enabledTrue when the subsystem is allowed to run hardware actions.
-
-
Constructor Details
-
AbstractSubsystem
Creates a subsystem base with shared configuration and logging support.- Parameters:
config- Configuration object for the subsystem; supplies enable/verbose flags and any hardware identifiers.
-
-
Method Details
-
getConfig
Returns the subsystem configuration bundle for command factories and external consumers that need access to subsystem-specific settings.- Returns:
- subsystem configuration
-
isSubsystemDisabled
public boolean isSubsystemDisabled()States whether this subsystem is marked as disabled in configuration.- Returns:
- True when the subsystem should not execute any hardware interactions.
-
isVerbose
public boolean isVerbose()Reports whether verbose telemetry and debug output are enabled for this subsystem.The value is read from the tunable config each call so it can be toggled at runtime from SmartDashboard without redeploying.
- Returns:
- True when verbose logging is enabled in the subsystem configuration.
-
isVerboseLoggingEnabled
public boolean isVerboseLoggingEnabled()Reports whether verbose AdvantageKit output should be recorded this cycle.Combines two checks: the robot must not be attached to the FMS, and the subsystem's verbose config flag must be enabled. Use this to guard expensive pre-computation (array allocations, object construction) before calling
log.recordVerboseOutput(...). The logger's own verbose gate handles the actual suppression, but calling this first avoids unnecessary work.- Returns:
- true when verbose AdvantageKit output is active for this subsystem
-
isSimulation
protected boolean isSimulation()Reports whether the code is running in WPILib simulation.- Returns:
- True when running in simulation rather than on a real robot.
-
isFMSAttached
protected boolean isFMSAttached()Reports whether the robot is attached to the FMS at call time.Uses the per-cycle cached value from
RobotEnvironment.refreshCycle().- Returns:
- True when running on a real robot that is currently FMS attached.
-
reportWarning
Reports a recoverable warning to the Driver Station console.Use this for situations like a missing starting pose or a non-critical fallback.
- Parameters:
message- warning descriptionprintStackTrace- true to include a stack trace in the output
-
logDisabled
Logs a standardized message when a call is skipped due to disable state.Call this from public APIs to make skipped actions visible to operators.
- Parameters:
methodName- name of the method that was skipped
-