mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[commands] Revert SubsystemBase deprecation/removal (#5634)
This commit is contained in:
@@ -14,7 +14,7 @@ import edu.wpi.first.math.controller.PIDController;
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
public abstract class PIDSubsystem extends Subsystem {
|
||||
public abstract class PIDSubsystem extends SubsystemBase {
|
||||
protected final PIDController m_controller;
|
||||
protected boolean m_enabled;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile;
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
public abstract class ProfiledPIDSubsystem extends Subsystem {
|
||||
public abstract class ProfiledPIDSubsystem extends SubsystemBase {
|
||||
protected final ProfiledPIDController m_controller;
|
||||
protected boolean m_enabled;
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj2.command;
|
||||
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.util.sendable.SendableRegistry;
|
||||
|
||||
/**
|
||||
* A robot subsystem. Subsystems are the basic unit of robot organization in the Command-based
|
||||
* framework; they encapsulate low-level hardware objects (motor controllers, sensors, etc.) and
|
||||
@@ -17,34 +13,29 @@ import edu.wpi.first.util.sendable.SendableRegistry;
|
||||
* their {@link Command#getRequirements()} method, and resources used within a subsystem should
|
||||
* generally remain encapsulated and not be shared by other parts of the robot.
|
||||
*
|
||||
* <p>Subsystems are automatically registered with the default scheduler in order for the {@link
|
||||
* Subsystem#periodic()} method to be called.
|
||||
* <p>Subsystems must be registered with the scheduler with the {@link
|
||||
* CommandScheduler#registerSubsystem(Subsystem...)} method in order for the {@link
|
||||
* Subsystem#periodic()} method to be called. It is recommended that this method be called from the
|
||||
* constructor of users' Subsystem implementations. The {@link SubsystemBase} class offers a simple
|
||||
* base for user implementations that handles this.
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
public abstract class Subsystem implements Sendable {
|
||||
/** Constructor. */
|
||||
public Subsystem() {
|
||||
String name = this.getClass().getSimpleName();
|
||||
name = name.substring(name.lastIndexOf('.') + 1);
|
||||
SendableRegistry.addLW(this, name, name);
|
||||
CommandScheduler.getInstance().registerSubsystem(this);
|
||||
}
|
||||
|
||||
public interface Subsystem {
|
||||
/**
|
||||
* This method is called periodically by the {@link CommandScheduler}. Useful for updating
|
||||
* subsystem-specific state that you don't want to offload to a {@link Command}. Teams should try
|
||||
* to be consistent within their own codebases about which responsibilities will be handled by
|
||||
* Commands, and which will be handled here.
|
||||
*/
|
||||
public void periodic() {}
|
||||
default void periodic() {}
|
||||
|
||||
/**
|
||||
* This method is called periodically by the {@link CommandScheduler}. Useful for updating
|
||||
* subsystem-specific state that needs to be maintained for simulations, such as for updating
|
||||
* {@link edu.wpi.first.wpilibj.simulation} classes and setting simulated sensor readings.
|
||||
*/
|
||||
public void simulationPeriodic() {}
|
||||
default void simulationPeriodic() {}
|
||||
|
||||
/**
|
||||
* Sets the default {@link Command} of the subsystem. The default command will be automatically
|
||||
@@ -55,7 +46,7 @@ public abstract class Subsystem implements Sendable {
|
||||
*
|
||||
* @param defaultCommand the default command to associate with this subsystem
|
||||
*/
|
||||
public void setDefaultCommand(Command defaultCommand) {
|
||||
default void setDefaultCommand(Command defaultCommand) {
|
||||
CommandScheduler.getInstance().setDefaultCommand(this, defaultCommand);
|
||||
}
|
||||
|
||||
@@ -63,7 +54,7 @@ public abstract class Subsystem implements Sendable {
|
||||
* Removes the default command for the subsystem. This will not cancel the default command if it
|
||||
* is currently running.
|
||||
*/
|
||||
public void removeDefaultCommand() {
|
||||
default void removeDefaultCommand() {
|
||||
CommandScheduler.getInstance().removeDefaultCommand(this);
|
||||
}
|
||||
|
||||
@@ -73,7 +64,7 @@ public abstract class Subsystem implements Sendable {
|
||||
*
|
||||
* @return the default command associated with this subsystem
|
||||
*/
|
||||
public Command getDefaultCommand() {
|
||||
default Command getDefaultCommand() {
|
||||
return CommandScheduler.getInstance().getDefaultCommand(this);
|
||||
}
|
||||
|
||||
@@ -83,51 +74,15 @@ public abstract class Subsystem implements Sendable {
|
||||
*
|
||||
* @return the scheduled command currently requiring this subsystem
|
||||
*/
|
||||
public Command getCurrentCommand() {
|
||||
default Command getCurrentCommand() {
|
||||
return CommandScheduler.getInstance().requiring(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
public String getName() {
|
||||
return SendableRegistry.getName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this Subsystem.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
SendableRegistry.setName(this, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
public String getSubsystem() {
|
||||
return SendableRegistry.getSubsystem(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
public void setSubsystem(String subsystem) {
|
||||
SendableRegistry.setSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this subsystem with the {@link CommandScheduler}, allowing its {@link
|
||||
* Subsystem#periodic()} method to be called when the scheduler runs.
|
||||
*/
|
||||
public void register() {
|
||||
default void register() {
|
||||
CommandScheduler.getInstance().registerSubsystem(this);
|
||||
}
|
||||
|
||||
@@ -138,7 +93,7 @@ public abstract class Subsystem implements Sendable {
|
||||
* @return the command
|
||||
* @see InstantCommand
|
||||
*/
|
||||
public Command runOnce(Runnable action) {
|
||||
default Command runOnce(Runnable action) {
|
||||
return Commands.runOnce(action, this);
|
||||
}
|
||||
|
||||
@@ -150,7 +105,7 @@ public abstract class Subsystem implements Sendable {
|
||||
* @return the command
|
||||
* @see RunCommand
|
||||
*/
|
||||
public Command run(Runnable action) {
|
||||
default Command run(Runnable action) {
|
||||
return Commands.run(action, this);
|
||||
}
|
||||
|
||||
@@ -163,7 +118,7 @@ public abstract class Subsystem implements Sendable {
|
||||
* @return the command
|
||||
* @see StartEndCommand
|
||||
*/
|
||||
public Command startEnd(Runnable start, Runnable end) {
|
||||
default Command startEnd(Runnable start, Runnable end) {
|
||||
return Commands.startEnd(start, end, this);
|
||||
}
|
||||
|
||||
@@ -175,33 +130,7 @@ public abstract class Subsystem implements Sendable {
|
||||
* @param end the action to run on interrupt
|
||||
* @return the command
|
||||
*/
|
||||
public Command runEnd(Runnable run, Runnable end) {
|
||||
default Command runEnd(Runnable run, Runnable end) {
|
||||
return Commands.runEnd(run, end, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates a {@link Sendable} with this Subsystem. Also update the child's name.
|
||||
*
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
public void addChild(String name, Sendable child) {
|
||||
SendableRegistry.addLW(child, getSubsystem(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("Subsystem");
|
||||
|
||||
builder.addBooleanProperty(".hasDefault", () -> getDefaultCommand() != null, null);
|
||||
builder.addStringProperty(
|
||||
".default",
|
||||
() -> getDefaultCommand() != null ? getDefaultCommand().getName() : "none",
|
||||
null);
|
||||
builder.addBooleanProperty(".hasCommand", () -> getCurrentCommand() != null, null);
|
||||
builder.addStringProperty(
|
||||
".command",
|
||||
() -> getCurrentCommand() != null ? getCurrentCommand().getName() : "none",
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,84 @@
|
||||
|
||||
package edu.wpi.first.wpilibj2.command;
|
||||
|
||||
import edu.wpi.first.util.sendable.Sendable;
|
||||
import edu.wpi.first.util.sendable.SendableBuilder;
|
||||
import edu.wpi.first.util.sendable.SendableRegistry;
|
||||
|
||||
/**
|
||||
* A base for subsystems that handles registration in the constructor, and provides a more intuitive
|
||||
* method for setting the default command.
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*
|
||||
* @deprecated All functionality provided by {@link SubsystemBase} has been merged into {@link
|
||||
* Subsystem}. Use {@link Subsystem} instead.
|
||||
*/
|
||||
@Deprecated(since = "2024", forRemoval = true)
|
||||
@SuppressWarnings("PMD.AbstractClassWithoutAnyMethod")
|
||||
public abstract class SubsystemBase extends Subsystem {}
|
||||
public abstract class SubsystemBase implements Subsystem, Sendable {
|
||||
/** Constructor. */
|
||||
public SubsystemBase() {
|
||||
String name = this.getClass().getSimpleName();
|
||||
name = name.substring(name.lastIndexOf('.') + 1);
|
||||
SendableRegistry.addLW(this, name, name);
|
||||
CommandScheduler.getInstance().registerSubsystem(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this Subsystem.
|
||||
*
|
||||
* @return Name
|
||||
*/
|
||||
public String getName() {
|
||||
return SendableRegistry.getName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this Subsystem.
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
SendableRegistry.setName(this, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @return Subsystem name
|
||||
*/
|
||||
public String getSubsystem() {
|
||||
return SendableRegistry.getSubsystem(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subsystem name of this Subsystem.
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
public void setSubsystem(String subsystem) {
|
||||
SendableRegistry.setSubsystem(this, subsystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Associates a {@link Sendable} with this Subsystem. Also update the child's name.
|
||||
*
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
public void addChild(String name, Sendable child) {
|
||||
SendableRegistry.addLW(child, getSubsystem(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("Subsystem");
|
||||
|
||||
builder.addBooleanProperty(".hasDefault", () -> getDefaultCommand() != null, null);
|
||||
builder.addStringProperty(
|
||||
".default",
|
||||
() -> getDefaultCommand() != null ? getDefaultCommand().getName() : "none",
|
||||
null);
|
||||
builder.addBooleanProperty(".hasCommand", () -> getCurrentCommand() != null, null);
|
||||
builder.addStringProperty(
|
||||
".command",
|
||||
() -> getCurrentCommand() != null ? getCurrentCommand().getName() : "none",
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import edu.wpi.first.math.trajectory.TrapezoidProfile;
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
public abstract class TrapezoidProfileSubsystem extends Subsystem {
|
||||
public abstract class TrapezoidProfileSubsystem extends SubsystemBase {
|
||||
private final double m_period;
|
||||
private final TrapezoidProfile m_profile;
|
||||
|
||||
|
||||
@@ -8,12 +8,6 @@
|
||||
#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);
|
||||
}
|
||||
@@ -39,26 +33,6 @@ 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);
|
||||
}
|
||||
@@ -80,33 +54,3 @@ 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,4 +12,57 @@
|
||||
|
||||
using namespace frc2;
|
||||
|
||||
SubsystemBase::SubsystemBase() {}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <frc/controller/PIDController.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ namespace frc2 {
|
||||
*
|
||||
* @see PIDController
|
||||
*/
|
||||
class PIDSubsystem : public Subsystem {
|
||||
class PIDSubsystem : public SubsystemBase {
|
||||
public:
|
||||
/**
|
||||
* Creates a new PIDSubsystem.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ namespace frc2 {
|
||||
* @see ProfiledPIDController
|
||||
*/
|
||||
template <class Distance>
|
||||
class ProfiledPIDSubsystem : public Subsystem {
|
||||
class ProfiledPIDSubsystem : public SubsystemBase {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
|
||||
#include <concepts>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
|
||||
namespace frc2 {
|
||||
@@ -27,19 +24,22 @@ class CommandPtr;
|
||||
* subsystem should generally remain encapsulated and not be shared by other
|
||||
* parts of the robot.
|
||||
*
|
||||
* <p>Subsystems are automatically registered with the scheduler with the
|
||||
* <p>Subsystems must be registered with the scheduler with the
|
||||
* CommandScheduler.RegisterSubsystem() method in order for the
|
||||
* Periodic() method to be called.
|
||||
* 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.
|
||||
*
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*
|
||||
* @see Command
|
||||
* @see CommandScheduler
|
||||
* @see SubsystemBase
|
||||
*/
|
||||
class Subsystem : public wpi::Sendable, public wpi::SendableHelper<Subsystem> {
|
||||
class Subsystem {
|
||||
public:
|
||||
~Subsystem() override;
|
||||
|
||||
virtual ~Subsystem();
|
||||
/**
|
||||
* This method is called periodically by the CommandScheduler. Useful for
|
||||
* updating subsystem-specific state that you don't want to offload to a
|
||||
@@ -111,43 +111,6 @@ class Subsystem : public wpi::Sendable, public wpi::SendableHelper<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.
|
||||
@@ -185,10 +148,5 @@ class Subsystem : public wpi::Sendable, public wpi::SendableHelper<Subsystem> {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
protected:
|
||||
Subsystem();
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/deprecated.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
|
||||
@@ -14,13 +18,51 @@ 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 [[deprecated("Use Subsystem instead")]] SubsystemBase : public Subsystem {
|
||||
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);
|
||||
|
||||
protected:
|
||||
WPI_DEPRECATED("Use Subsystem instead")
|
||||
SubsystemBase();
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "frc2/command/Subsystem.h"
|
||||
#include "frc2/command/SubsystemBase.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ namespace frc2 {
|
||||
* This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
template <class Distance>
|
||||
class TrapezoidProfileSubsystem : public Subsystem {
|
||||
class TrapezoidProfileSubsystem : public SubsystemBase {
|
||||
using Distance_t = units::unit_t<Distance>;
|
||||
using Velocity =
|
||||
units::compound_unit<Distance, units::inverse<units::seconds>>;
|
||||
|
||||
Reference in New Issue
Block a user