mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Revert SubsystemBase deprecation/removal (#5634)
This commit is contained in:
@@ -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