[commands] SubsystemBase: allow setting name in constructor (#6052)

This commit is contained in:
Eli Barnett
2023-12-16 14:05:53 -05:00
committed by GitHub
parent 0b4c6a1546
commit a004c9e05f
3 changed files with 26 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ import edu.wpi.first.util.sendable.SendableRegistry;
* <p>This class is provided by the NewCommands VendorDep
*/
public abstract class SubsystemBase implements Subsystem, Sendable {
/** Constructor. */
/** Constructor. Telemetry/log name defaults to the classname. */
@SuppressWarnings("this-escape")
public SubsystemBase() {
String name = this.getClass().getSimpleName();
@@ -24,6 +24,17 @@ public abstract class SubsystemBase implements Subsystem, Sendable {
CommandScheduler.getInstance().registerSubsystem(this);
}
/**
* Constructor.
*
* @param name Name of the subsystem for telemetry and logging.
*/
@SuppressWarnings("this-escape")
public SubsystemBase(String name) {
SendableRegistry.addLW(this, name, name);
CommandScheduler.getInstance().registerSubsystem(this);
}
/**
* Gets the name of this Subsystem.
*