diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java index 4ab64b7cc57..3a024e5f665 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/SubsystemBase.java @@ -15,7 +15,7 @@ *

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 SubsystemBase() { 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. * diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp index 8216a075828..e5a40388e4a 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/SubsystemBase.cpp @@ -17,6 +17,11 @@ SubsystemBase::SubsystemBase() { CommandScheduler::GetInstance().RegisterSubsystem({this}); } +SubsystemBase::SubsystemBase(std::string_view name) { + wpi::SendableRegistry::AddLW(this, name); + CommandScheduler::GetInstance().RegisterSubsystem({this}); +} + void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Subsystem"); builder.AddBooleanProperty( diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h index cc9eeb35a5a..444aca5d78c 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SubsystemBase.h @@ -63,6 +63,15 @@ class SubsystemBase : public Subsystem, void AddChild(std::string name, wpi::Sendable* child); protected: + /** + * Constructor. Telemetry/log name defaults to the classname. + */ SubsystemBase(); + /** + * Constructor. + * + * @param name Name of the subsystem for telemetry and logging. + */ + explicit SubsystemBase(std::string_view name); }; } // namespace frc2