mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Allow unsetting a subsystem's default command (#4621)
This commit is contained in:
@@ -367,6 +367,10 @@ public final class CommandScheduler implements NTSendable, AutoCloseable {
|
||||
DriverStation.reportWarning("Tried to register a null subsystem", true);
|
||||
continue;
|
||||
}
|
||||
if (m_subsystems.containsKey(subsystem)) {
|
||||
DriverStation.reportWarning("Tried to register an already-registered subsystem", true);
|
||||
continue;
|
||||
}
|
||||
m_subsystems.put(subsystem, null);
|
||||
}
|
||||
}
|
||||
@@ -416,6 +420,22 @@ public final class CommandScheduler implements NTSendable, AutoCloseable {
|
||||
m_subsystems.put(subsystem, defaultCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the default command for a subsystem. The current default command will run until another
|
||||
* command is scheduled that requires the subsystem, at which point the current default command
|
||||
* will not be re-scheduled.
|
||||
*
|
||||
* @param subsystem the subsystem whose default command will be removed
|
||||
*/
|
||||
public void removeDefaultCommand(Subsystem subsystem) {
|
||||
if (subsystem == null) {
|
||||
DriverStation.reportWarning("Tried to remove a default command for a null subsystem", true);
|
||||
return;
|
||||
}
|
||||
|
||||
m_subsystems.put(subsystem, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default command associated with this subsystem. Null if this subsystem has no default
|
||||
* command associated with it.
|
||||
|
||||
Reference in New Issue
Block a user