mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[commands] Merge CommandBase into Command and SubsystemBase into Subsystem (#5392)
Moves all CommandBase functionality into Command and deprecates CommandBase for removal. Moves all SubsystemBase functionality into Subsystem and deprecates SubsystemBase for removal. Adds a function to CommandScheduler to remove all registered Subsystems.
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "frc2/command/Command.h"
|
||||
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
#include "frc2/command/ConditionalCommand.h"
|
||||
@@ -19,6 +22,10 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
Command::Command() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
Command::~Command() {
|
||||
CommandScheduler::GetInstance().Cancel(this);
|
||||
}
|
||||
@@ -32,6 +39,42 @@ void Command::Initialize() {}
|
||||
void Command::Execute() {}
|
||||
void Command::End(bool interrupted) {}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> Command::GetRequirements() const {
|
||||
return m_requirements;
|
||||
}
|
||||
|
||||
void Command::AddRequirements(std::initializer_list<Subsystem*> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void Command::AddRequirements(std::span<Subsystem* const> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void Command::AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void Command::AddRequirements(Subsystem* requirement) {
|
||||
m_requirements.insert(requirement);
|
||||
}
|
||||
|
||||
void Command::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Command::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
std::string Command::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Command::SetSubsystem(std::string_view subsystem) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
CommandPtr Command::WithTimeout(units::second_t duration) && {
|
||||
return std::move(*this).ToPtr().WithTimeout(duration);
|
||||
}
|
||||
@@ -125,12 +168,6 @@ bool Command::HasRequirement(Subsystem* requirement) const {
|
||||
return hasRequirement;
|
||||
}
|
||||
|
||||
std::string Command::GetName() const {
|
||||
return GetTypeName(*this);
|
||||
}
|
||||
|
||||
void Command::SetName(std::string_view name) {}
|
||||
|
||||
bool Command::IsComposed() const {
|
||||
return m_isComposed;
|
||||
}
|
||||
@@ -139,6 +176,39 @@ void Command::SetComposed(bool isComposed) {
|
||||
m_isComposed = isComposed;
|
||||
}
|
||||
|
||||
void Command::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(
|
||||
".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"running", [this] { return IsScheduled(); },
|
||||
[this](bool value) {
|
||||
bool isScheduled = IsScheduled();
|
||||
if (value && !isScheduled) {
|
||||
Schedule();
|
||||
} else if (!value && isScheduled) {
|
||||
Cancel();
|
||||
}
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
".isParented", [this] { return IsComposed(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
"interruptBehavior",
|
||||
[this] {
|
||||
switch (GetInterruptionBehavior()) {
|
||||
case Command::InterruptionBehavior::kCancelIncoming:
|
||||
return "kCancelIncoming";
|
||||
case Command::InterruptionBehavior::kCancelSelf:
|
||||
return "kCancelSelf";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"runsWhenDisabled", [this] { return RunsWhenDisabled(); }, nullptr);
|
||||
}
|
||||
|
||||
namespace frc2 {
|
||||
bool RequirementsDisjoint(Command* first, Command* second) {
|
||||
bool disjoint = true;
|
||||
|
||||
@@ -3,82 +3,3 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
CommandBase::CommandBase() {
|
||||
wpi::SendableRegistry::Add(this, GetTypeName(*this));
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(
|
||||
std::initializer_list<Subsystem*> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(std::span<Subsystem* const> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements) {
|
||||
m_requirements.insert(requirements.begin(), requirements.end());
|
||||
}
|
||||
|
||||
void CommandBase::AddRequirements(Subsystem* requirement) {
|
||||
m_requirements.insert(requirement);
|
||||
}
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> CommandBase::GetRequirements() const {
|
||||
return m_requirements;
|
||||
}
|
||||
|
||||
void CommandBase::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
std::string CommandBase::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void CommandBase::SetSubsystem(std::string_view subsystem) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
void CommandBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Command");
|
||||
builder.AddStringProperty(
|
||||
".name", [this] { return GetName(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"running", [this] { return IsScheduled(); },
|
||||
[this](bool value) {
|
||||
bool isScheduled = IsScheduled();
|
||||
if (value && !isScheduled) {
|
||||
Schedule();
|
||||
} else if (!value && isScheduled) {
|
||||
Cancel();
|
||||
}
|
||||
});
|
||||
builder.AddBooleanProperty(
|
||||
".isParented", [this] { return IsComposed(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
"interruptBehavior",
|
||||
[this] {
|
||||
switch (GetInterruptionBehavior()) {
|
||||
case Command::InterruptionBehavior::kCancelIncoming:
|
||||
return "kCancelIncoming";
|
||||
case Command::InterruptionBehavior::kCancelSelf:
|
||||
return "kCancelSelf";
|
||||
default:
|
||||
return "Invalid";
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"runsWhenDisabled", [this] { return RunsWhenDisabled(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -236,12 +236,12 @@ CommandPtr CommandPtr::WithName(std::string_view name) && {
|
||||
return std::move(wrapper).ToPtr();
|
||||
}
|
||||
|
||||
CommandBase* CommandPtr::get() const& {
|
||||
Command* CommandPtr::get() const& {
|
||||
AssertValid();
|
||||
return m_ptr.get();
|
||||
}
|
||||
|
||||
std::unique_ptr<CommandBase> CommandPtr::Unwrap() && {
|
||||
std::unique_ptr<Command> CommandPtr::Unwrap() && {
|
||||
AssertValid();
|
||||
return std::move(m_ptr);
|
||||
}
|
||||
|
||||
@@ -291,6 +291,10 @@ void CommandScheduler::UnregisterSubsystem(
|
||||
}
|
||||
}
|
||||
|
||||
void CommandScheduler::UnregisterAllSubsystems() {
|
||||
m_impl->subsystems.clear();
|
||||
}
|
||||
|
||||
void CommandScheduler::SetDefaultCommand(Subsystem* subsystem,
|
||||
CommandPtr&& defaultCommand) {
|
||||
if (!defaultCommand.get()->HasRequirement(subsystem)) {
|
||||
|
||||
@@ -66,7 +66,7 @@ Command::InterruptionBehavior ConditionalCommand::GetInterruptionBehavior()
|
||||
}
|
||||
|
||||
void ConditionalCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"onTrue", [this] { return m_onTrue->GetName(); }, nullptr);
|
||||
builder.AddStringProperty(
|
||||
|
||||
@@ -97,7 +97,7 @@ void ParallelDeadlineGroup::SetDeadline(std::unique_ptr<Command>&& deadline) {
|
||||
}
|
||||
|
||||
void ParallelDeadlineGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
"deadline", [this] { return m_deadline->GetName(); }, nullptr);
|
||||
|
||||
@@ -41,7 +41,7 @@ bool ProxyCommand::IsFinished() {
|
||||
}
|
||||
|
||||
void ProxyCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"proxied",
|
||||
[this] {
|
||||
|
||||
@@ -161,7 +161,7 @@ bool RamseteCommand::IsFinished() {
|
||||
}
|
||||
|
||||
void RamseteCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddDoubleProperty(
|
||||
"leftVelocity", [this] { return m_prevSpeeds.left.value(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
|
||||
@@ -56,7 +56,7 @@ Command::InterruptionBehavior RepeatCommand::GetInterruptionBehavior() const {
|
||||
}
|
||||
|
||||
void RepeatCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddStringProperty(
|
||||
"command", [this] { return m_command->GetName(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ void SequentialCommandGroup::AddCommands(
|
||||
}
|
||||
|
||||
void SequentialCommandGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddIntegerProperty(
|
||||
"index", [this] { return m_currentCommandIndex; }, nullptr);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
#include "frc2/command/Commands.h"
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
Subsystem::Subsystem() {
|
||||
wpi::SendableRegistry::AddLW(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
Subsystem::~Subsystem() {
|
||||
CommandScheduler::GetInstance().UnregisterSubsystem(this);
|
||||
}
|
||||
@@ -33,6 +39,26 @@ Command* Subsystem::GetCurrentCommand() const {
|
||||
return CommandScheduler::GetInstance().Requiring(this);
|
||||
}
|
||||
|
||||
std::string Subsystem::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string Subsystem::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetSubsystem(std::string_view name) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(std::string name, wpi::Sendable* child) {
|
||||
wpi::SendableRegistry::AddLW(child, GetSubsystem(), name);
|
||||
}
|
||||
|
||||
void Subsystem::Register() {
|
||||
return CommandScheduler::GetInstance().RegisterSubsystem(this);
|
||||
}
|
||||
@@ -54,3 +80,33 @@ CommandPtr Subsystem::RunEnd(std::function<void()> run,
|
||||
std::function<void()> end) {
|
||||
return cmd::RunEnd(std::move(run), std::move(end), {this});
|
||||
}
|
||||
|
||||
void Subsystem::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".default",
|
||||
[this]() -> std::string {
|
||||
auto command = GetDefaultCommand();
|
||||
if (command == nullptr) {
|
||||
return "none";
|
||||
}
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
".hasCommand", [this] { return GetCurrentCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".command",
|
||||
[this]() -> std::string {
|
||||
auto command = GetCurrentCommand();
|
||||
if (command == nullptr) {
|
||||
return "none";
|
||||
}
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
@@ -12,57 +12,4 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
SubsystemBase::SubsystemBase() {
|
||||
wpi::SendableRegistry::AddLW(this, GetTypeName(*this));
|
||||
CommandScheduler::GetInstance().RegisterSubsystem({this});
|
||||
}
|
||||
|
||||
void SubsystemBase::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Subsystem");
|
||||
builder.AddBooleanProperty(
|
||||
".hasDefault", [this] { return GetDefaultCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".default",
|
||||
[this]() -> std::string {
|
||||
auto command = GetDefaultCommand();
|
||||
if (command == nullptr) {
|
||||
return "none";
|
||||
}
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
".hasCommand", [this] { return GetCurrentCommand() != nullptr; },
|
||||
nullptr);
|
||||
builder.AddStringProperty(
|
||||
".command",
|
||||
[this]() -> std::string {
|
||||
auto command = GetCurrentCommand();
|
||||
if (command == nullptr) {
|
||||
return "none";
|
||||
}
|
||||
return command->GetName();
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetName() const {
|
||||
return wpi::SendableRegistry::GetName(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetName(std::string_view name) {
|
||||
wpi::SendableRegistry::SetName(this, name);
|
||||
}
|
||||
|
||||
std::string SubsystemBase::GetSubsystem() const {
|
||||
return wpi::SendableRegistry::GetSubsystem(this);
|
||||
}
|
||||
|
||||
void SubsystemBase::SetSubsystem(std::string_view name) {
|
||||
wpi::SendableRegistry::SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void SubsystemBase::AddChild(std::string name, wpi::Sendable* child) {
|
||||
wpi::SendableRegistry::AddLW(child, GetSubsystem(), name);
|
||||
}
|
||||
SubsystemBase::SubsystemBase() {}
|
||||
|
||||
@@ -30,7 +30,7 @@ bool WaitCommand::RunsWhenDisabled() const {
|
||||
}
|
||||
|
||||
void WaitCommand::InitSendable(wpi::SendableBuilder& builder) {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
builder.AddDoubleProperty(
|
||||
"duration", [this] { return m_duration.value(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <units/time.h>
|
||||
#include <wpi/Demangle.h>
|
||||
#include <wpi/SmallSet.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
@@ -41,10 +42,9 @@ std::string GetTypeName(const T& type) {
|
||||
* @see CommandScheduler
|
||||
* @see CommandHelper
|
||||
*/
|
||||
class Command {
|
||||
class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
public:
|
||||
Command() = default;
|
||||
virtual ~Command();
|
||||
~Command() override;
|
||||
|
||||
Command(const Command&) = default;
|
||||
Command& operator=(const Command& rhs);
|
||||
@@ -92,7 +92,91 @@ class Command {
|
||||
* @return the set of subsystems that are required
|
||||
* @see InterruptionBehavior
|
||||
*/
|
||||
virtual wpi::SmallSet<Subsystem*, 4> GetRequirements() const = 0;
|
||||
virtual wpi::SmallSet<Subsystem*, 4> GetRequirements() const;
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(std::span<Subsystem* const> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirement to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirement the Subsystem requirement to add
|
||||
*/
|
||||
void AddRequirements(Subsystem* requirement);
|
||||
|
||||
/**
|
||||
* Gets the name of this Command.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Command.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Command.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Command.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(std::string_view subsystem);
|
||||
|
||||
/**
|
||||
* An enum describing the command's behavior when another command with a
|
||||
@@ -345,28 +429,19 @@ class Command {
|
||||
return InterruptionBehavior::kCancelSelf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this Command. Defaults to the simple class name if not
|
||||
* overridden.
|
||||
*
|
||||
* @return The display name of the Command
|
||||
*/
|
||||
virtual std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Command. Nullop if not overridden.
|
||||
*
|
||||
* @param name The display name of the Command.
|
||||
*/
|
||||
virtual void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Transfers ownership of this command to a unique pointer. Used for
|
||||
* decorator methods.
|
||||
*/
|
||||
virtual CommandPtr ToPtr() && = 0;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
Command();
|
||||
|
||||
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
||||
|
||||
/**
|
||||
* Transfers ownership of this command to a unique pointer. Used for
|
||||
* decorator methods.
|
||||
|
||||
@@ -4,14 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/SmallSet.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc2/command/Command.h"
|
||||
|
||||
@@ -20,106 +13,13 @@ namespace frc2 {
|
||||
* A Sendable base class for Commands.
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*
|
||||
* @deprecated All functionality provided by CommandBase has been merged into
|
||||
* Command. Use Command instead.
|
||||
*/
|
||||
class CommandBase : public Command,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<CommandBase> {
|
||||
public:
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(std::initializer_list<Subsystem*> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(std::span<Subsystem* const> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirements to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @param requirements the Subsystem requirements to add
|
||||
*/
|
||||
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
||||
|
||||
/**
|
||||
* Adds the specified Subsystem requirement to the command.
|
||||
*
|
||||
* The scheduler will prevent two commands that require the same subsystem
|
||||
* from being scheduled simultaneously.
|
||||
*
|
||||
* Note that the scheduler determines the requirements of a command when it
|
||||
* is scheduled, so this method should normally be called from the command's
|
||||
* constructor.
|
||||
*
|
||||
* @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<Subsystem*, 4> GetRequirements() const override;
|
||||
|
||||
/**
|
||||
* Sets the name of this Command.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(std::string_view name) override;
|
||||
|
||||
/**
|
||||
* Gets the name of this Command.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const override;
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Command.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Command.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(std::string_view subsystem);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
class [[deprecated("Use Command instead")]] CommandBase : public Command {
|
||||
protected:
|
||||
WPI_DEPRECATED("Use Command instead")
|
||||
CommandBase();
|
||||
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ namespace frc2 {
|
||||
*/
|
||||
class CommandPtr final {
|
||||
public:
|
||||
explicit CommandPtr(std::unique_ptr<CommandBase>&& command)
|
||||
explicit CommandPtr(std::unique_ptr<Command>&& command)
|
||||
: m_ptr(std::move(command)) {}
|
||||
|
||||
template <std::derived_from<Command> T>
|
||||
@@ -269,15 +269,15 @@ class CommandPtr final {
|
||||
/**
|
||||
* Get a raw pointer to the held command.
|
||||
*/
|
||||
CommandBase* get() const&;
|
||||
Command* get() const&;
|
||||
|
||||
// Prevent calls on a temporary, as the returned pointer would be invalid
|
||||
CommandBase* get() && = delete;
|
||||
Command* get() && = delete;
|
||||
|
||||
/**
|
||||
* Convert to the underlying unique_ptr.
|
||||
*/
|
||||
std::unique_ptr<CommandBase> Unwrap() &&;
|
||||
std::unique_ptr<Command> Unwrap() &&;
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
@@ -336,7 +336,7 @@ class CommandPtr final {
|
||||
std::vector<CommandPtr>&& vec);
|
||||
|
||||
private:
|
||||
std::unique_ptr<CommandBase> m_ptr;
|
||||
std::unique_ptr<Command> m_ptr;
|
||||
void AssertValid() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -158,6 +158,13 @@ class CommandScheduler final : public nt::NTSendable,
|
||||
void UnregisterSubsystem(std::initializer_list<Subsystem*> subsystems);
|
||||
void UnregisterSubsystem(std::span<Subsystem* const> subsystems);
|
||||
|
||||
/**
|
||||
* Un-registers all registered Subsystems with the scheduler. All currently
|
||||
* registered subsystems will no longer have their periodic block called, and
|
||||
* will not have their default command scheduled.
|
||||
*/
|
||||
void UnregisterAllSubsystems();
|
||||
|
||||
/**
|
||||
* Sets the default command for a subsystem. Registers that subsystem if it
|
||||
* is not already registered. Default commands will run whenever there is no
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -26,8 +26,7 @@ namespace frc2 {
|
||||
*
|
||||
* @see ScheduleCommand
|
||||
*/
|
||||
class ConditionalCommand
|
||||
: public CommandHelper<CommandBase, ConditionalCommand> {
|
||||
class ConditionalCommand : public CommandHelper<Command, ConditionalCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ConditionalCommand.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -21,7 +21,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class FunctionalCommand : public CommandHelper<CommandBase, FunctionalCommand> {
|
||||
class FunctionalCommand : public CommandHelper<Command, FunctionalCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new FunctionalCommand.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
|
||||
#include "CommandBase.h"
|
||||
#include "Command.h"
|
||||
#include "CommandHelper.h"
|
||||
|
||||
#pragma once
|
||||
@@ -51,7 +51,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class MecanumControllerCommand
|
||||
: public CommandHelper<CommandBase, MecanumControllerCommand> {
|
||||
: public CommandHelper<Command, MecanumControllerCommand> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new MecanumControllerCommand that when executed will follow
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <frc/Notifier.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -27,7 +27,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class NotifierCommand : public CommandHelper<CommandBase, NotifierCommand> {
|
||||
class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new NotifierCommand.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <frc/controller/PIDController.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -24,7 +24,7 @@ namespace frc2 {
|
||||
*
|
||||
* @see PIDController
|
||||
*/
|
||||
class PIDCommand : public CommandHelper<CommandBase, PIDCommand> {
|
||||
class PIDCommand : public CommandHelper<Command, PIDCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new PIDCommand, which controls the given output with a
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc/controller/PIDController.h>
|
||||
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ namespace frc2 {
|
||||
*
|
||||
* @see PIDController
|
||||
*/
|
||||
class PIDSubsystem : public SubsystemBase {
|
||||
class PIDSubsystem : public Subsystem {
|
||||
public:
|
||||
/**
|
||||
* Creates a new PIDSubsystem.
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class ParallelCommandGroup
|
||||
: public CommandHelper<CommandBase, ParallelCommandGroup> {
|
||||
: public CommandHelper<Command, ParallelCommandGroup> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ParallelCommandGroup. The given commands will be executed
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class ParallelDeadlineGroup
|
||||
: public CommandHelper<CommandBase, ParallelDeadlineGroup> {
|
||||
: public CommandHelper<Command, ParallelDeadlineGroup> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ParallelDeadlineGroup. The given commands (including the
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class ParallelRaceGroup : public CommandHelper<CommandBase, ParallelRaceGroup> {
|
||||
class ParallelRaceGroup : public CommandHelper<Command, ParallelRaceGroup> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ParallelCommandRace. The given commands will be executed
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -28,7 +28,7 @@ namespace frc2 {
|
||||
*/
|
||||
template <class Distance>
|
||||
class ProfiledPIDCommand
|
||||
: public CommandHelper<CommandBase, ProfiledPIDCommand<Distance>> {
|
||||
: public CommandHelper<Command, ProfiledPIDCommand<Distance>> {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ namespace frc2 {
|
||||
* @see ProfiledPIDController
|
||||
*/
|
||||
template <class Distance>
|
||||
class ProfiledPIDSubsystem : public SubsystemBase {
|
||||
class ProfiledPIDSubsystem : public Subsystem {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <wpi/FunctionExtras.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
#include "frc2/command/SetUtilities.h"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace frc2 {
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class ProxyCommand : public CommandHelper<CommandBase, ProxyCommand> {
|
||||
class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <units/length.h>
|
||||
#include <units/voltage.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -42,7 +42,7 @@ namespace frc2 {
|
||||
* @see RamseteController
|
||||
* @see Trajectory
|
||||
*/
|
||||
class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
|
||||
class RamseteCommand : public CommandHelper<Command, RamseteCommand> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new RamseteCommand that, when executed, will follow the
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -29,7 +29,7 @@ namespace frc2 {
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class RepeatCommand : public CommandHelper<CommandBase, RepeatCommand> {
|
||||
class RepeatCommand : public CommandHelper<Command, RepeatCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new RepeatCommand. Will run another command repeatedly,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <wpi/SmallVector.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
#include "frc2/command/SetUtilities.h"
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class ScheduleCommand : public CommandHelper<CommandBase, ScheduleCommand> {
|
||||
class ScheduleCommand : public CommandHelper<Command, ScheduleCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ScheduleCommand that schedules the given commands when
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/PrintCommand.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -35,7 +35,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
template <typename Key>
|
||||
class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
class SelectCommand : public CommandHelper<Command, SelectCommand<Key>> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new SelectCommand.
|
||||
@@ -113,7 +113,7 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
}
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override {
|
||||
CommandBase::InitSendable(builder);
|
||||
Command::InitSendable(builder);
|
||||
|
||||
builder.AddStringProperty(
|
||||
"selected",
|
||||
|
||||
@@ -37,7 +37,7 @@ const size_t invalid_index = std::numeric_limits<size_t>::max();
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class SequentialCommandGroup
|
||||
: public CommandHelper<CommandBase, SequentialCommandGroup> {
|
||||
: public CommandHelper<Command, SequentialCommandGroup> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new SequentialCommandGroup. The given commands will be run
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <concepts>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -23,22 +26,19 @@ class CommandPtr;
|
||||
* subsystem should generally remain encapsulated and not be shared by other
|
||||
* parts of the robot.
|
||||
*
|
||||
* <p>Subsystems must be registered with the scheduler with the
|
||||
* <p>Subsystems are automatically registered with the scheduler with the
|
||||
* CommandScheduler.RegisterSubsystem() method in order for the
|
||||
* Periodic() method to be called. It is recommended that this method be called
|
||||
* from the constructor of users' Subsystem implementations. The
|
||||
* SubsystemBase class offers a simple base for user implementations
|
||||
* that handles this.
|
||||
* Periodic() method to be called.
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*
|
||||
* @see Command
|
||||
* @see CommandScheduler
|
||||
* @see SubsystemBase
|
||||
*/
|
||||
class Subsystem {
|
||||
class Subsystem : public wpi::Sendable, public wpi::SendableHelper<Subsystem> {
|
||||
public:
|
||||
virtual ~Subsystem();
|
||||
~Subsystem() override;
|
||||
|
||||
/**
|
||||
* This method is called periodically by the CommandScheduler. Useful for
|
||||
* updating subsystem-specific state that you don't want to offload to a
|
||||
@@ -110,6 +110,43 @@ class Subsystem {
|
||||
*/
|
||||
void Register();
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Subsystem.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @param name subsystem name
|
||||
*/
|
||||
void SetSubsystem(std::string_view name);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
* Also update the child's name.
|
||||
*
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(std::string name, wpi::Sendable* child);
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and finishes. Requires this
|
||||
* subsystem.
|
||||
@@ -147,5 +184,10 @@ class Subsystem {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
Subsystem();
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -4,11 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
@@ -18,51 +14,13 @@ namespace frc2 {
|
||||
* provides a more intuitive method for setting the default command.
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*
|
||||
* @deprecated All functionality provided by SubsystemBase has been merged into
|
||||
* Subsystem. Use Subsystem instead.
|
||||
*/
|
||||
class SubsystemBase : public Subsystem,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<SubsystemBase> {
|
||||
public:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
std::string GetName() const;
|
||||
|
||||
/**
|
||||
* Sets the name of this Subsystem.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
std::string GetSubsystem() const;
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @param name subsystem name
|
||||
*/
|
||||
void SetSubsystem(std::string_view name);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
* Also update the child's name.
|
||||
*
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(std::string name, wpi::Sendable* child);
|
||||
|
||||
class [[deprecated("Use Subsystem instead")]] SubsystemBase : public Subsystem {
|
||||
protected:
|
||||
WPI_DEPRECATED("Use Subsystem instead")
|
||||
SubsystemBase();
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <units/time.h>
|
||||
#include <units/voltage.h>
|
||||
|
||||
#include "CommandBase.h"
|
||||
#include "Command.h"
|
||||
#include "CommandHelper.h"
|
||||
|
||||
#pragma once
|
||||
@@ -51,7 +51,7 @@ namespace frc2 {
|
||||
*/
|
||||
template <size_t NumModules>
|
||||
class SwerveControllerCommand
|
||||
: public CommandHelper<CommandBase, SwerveControllerCommand<NumModules>> {
|
||||
: public CommandHelper<Command, SwerveControllerCommand<NumModules>> {
|
||||
using voltsecondspermeter =
|
||||
units::compound_unit<units::voltage::volt, units::second,
|
||||
units::inverse<units::meter>>;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <frc/Timer.h>
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -25,7 +25,7 @@ namespace frc2 {
|
||||
*/
|
||||
template <class Distance>
|
||||
class TrapezoidProfileCommand
|
||||
: public CommandHelper<CommandBase, TrapezoidProfileCommand<Distance>> {
|
||||
: public CommandHelper<Command, TrapezoidProfileCommand<Distance>> {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
template <class Distance>
|
||||
class TrapezoidProfileSubsystem : public SubsystemBase {
|
||||
class TrapezoidProfileSubsystem : public Subsystem {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/Timer.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -16,7 +16,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class WaitCommand : public CommandHelper<CommandBase, WaitCommand> {
|
||||
class WaitCommand : public CommandHelper<Command, WaitCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new WaitCommand. This command will do nothing, and end after the
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -18,7 +18,7 @@ namespace frc2 {
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
class WaitUntilCommand : public CommandHelper<CommandBase, WaitUntilCommand> {
|
||||
class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new WaitUntilCommand that ends after a given condition becomes
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "frc2/command/CommandBase.h"
|
||||
#include "frc2/command/Command.h"
|
||||
#include "frc2/command/CommandHelper.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -24,7 +24,7 @@ namespace frc2 {
|
||||
* <p>Wrapped commands may only be used through the wrapper, trying to directly
|
||||
* schedule them or add them to a group will throw an exception.
|
||||
*/
|
||||
class WrapperCommand : public CommandHelper<CommandBase, WrapperCommand> {
|
||||
class WrapperCommand : public CommandHelper<Command, WrapperCommand> {
|
||||
public:
|
||||
/**
|
||||
* Wrap a command.
|
||||
|
||||
Reference in New Issue
Block a user