diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp index 99a5d18a37..b6f76f365f 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandBase.cpp @@ -26,6 +26,10 @@ void CommandBase::AddRequirements(wpi::SmallSet requirements) { m_requirements.insert(requirements.begin(), requirements.end()); } +void CommandBase::AddRequirements(Subsystem* requirement) { + m_requirements.insert(requirement); +} + wpi::SmallSet CommandBase::GetRequirements() const { return m_requirements; } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h index c187ceede6..9a498bc49e 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandBase.h @@ -24,21 +24,38 @@ class CommandBase : public Command, public wpi::SendableHelper { public: /** - * Adds the specified requirements to the command. + * Adds the specified Subsystem requirements to the command. * - * @param requirements the requirements to add + * @param requirements the Subsystem requirements to add */ void AddRequirements(std::initializer_list requirements); /** - * Adds the specified requirements to the command. + * Adds the specified Subsystem requirements to the command. * - * @param requirements the requirements to add + * @param requirements the Subsystem requirements to add */ void AddRequirements(wpi::span requirements); + /** + * Adds the specified Subsystem requirements to the command. + * + * @param requirements the Subsystem requirements to add + */ void AddRequirements(wpi::SmallSet requirements); + /** + * Adds the specified Subsystem requirement to the command. + * + * @param requirement the Subsystem requirement to add + */ + void AddRequirements(Subsystem* requirement); + + /** + * Gets the Subsystem requirements of the command. + * + * @return the Command's Subsystem requirements + */ wpi::SmallSet GetRequirements() const override; /** diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp index 96ebbcb3f0..e769cbdb32 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp @@ -5,7 +5,7 @@ #include "commands/GrabHatch.h" GrabHatch::GrabHatch(HatchSubsystem* subsystem) : m_hatch(subsystem) { - AddRequirements({subsystem}); + AddRequirements(subsystem); } void GrabHatch::Initialize() {