[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

@@ -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(

View File

@@ -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