[commands] Revert SubsystemBase deprecation/removal (#5634)

This commit is contained in:
Ryan Blue
2023-09-14 23:56:48 -04:00
committed by GitHub
parent bc7f23a632
commit 3b79cb6ed3
80 changed files with 370 additions and 375 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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.

View File

@@ -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>>;

View File

@@ -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

View File

@@ -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

View File

@@ -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>>;

View File

@@ -15,7 +15,7 @@ class CommandRequirementsTest extends CommandTestBase {
@Test
void requirementInterruptTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
MockCommandHolder interruptedHolder = new MockCommandHolder(true, requirement);
Command interrupted = interruptedHolder.getMock();
@@ -42,7 +42,7 @@ class CommandRequirementsTest extends CommandTestBase {
@Test
void requirementUninterruptibleTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
Command notInterrupted =
new RunCommand(() -> {}, requirement)
@@ -61,7 +61,7 @@ class CommandRequirementsTest extends CommandTestBase {
@Test
void defaultCommandRequirementErrorTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem system = new Subsystem() {};
Subsystem system = new SubsystemBase() {};
Command missingRequirement = new WaitUntilCommand(() -> false);

View File

@@ -46,9 +46,9 @@ class ConditionalCommandTest extends CommandTestBase {
@Test
void conditionalCommandRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);

View File

@@ -14,7 +14,7 @@ class DefaultCommandTest extends CommandTestBase {
@Test
void defaultCommandScheduleTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem hasDefaultCommand = new Subsystem() {};
Subsystem hasDefaultCommand = new SubsystemBase() {};
MockCommandHolder defaultHolder = new MockCommandHolder(true, hasDefaultCommand);
Command defaultCommand = defaultHolder.getMock();
@@ -29,7 +29,7 @@ class DefaultCommandTest extends CommandTestBase {
@Test
void defaultCommandInterruptResumeTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem hasDefaultCommand = new Subsystem() {};
Subsystem hasDefaultCommand = new SubsystemBase() {};
MockCommandHolder defaultHolder = new MockCommandHolder(true, hasDefaultCommand);
Command defaultCommand = defaultHolder.getMock();
@@ -54,7 +54,7 @@ class DefaultCommandTest extends CommandTestBase {
@Test
void defaultCommandDisableResumeTest() {
try (CommandScheduler scheduler = new CommandScheduler()) {
Subsystem hasDefaultCommand = new Subsystem() {};
Subsystem hasDefaultCommand = new SubsystemBase() {};
MockCommandHolder defaultHolder = new MockCommandHolder(false, hasDefaultCommand);
Command defaultCommand = defaultHolder.getMock();

View File

@@ -90,10 +90,10 @@ class ParallelCommandGroupTest extends CommandTestBase
@Test
void parallelGroupRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system4 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
Subsystem system4 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
@@ -115,9 +115,9 @@ class ParallelCommandGroupTest extends CommandTestBase
@Test
void parallelGroupRequirementErrorTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
Command command1 = command1Holder.getMock();

View File

@@ -87,10 +87,10 @@ class ParallelDeadlineGroupTest extends CommandTestBase
@Test
void parallelDeadlineRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system4 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
Subsystem system4 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
@@ -112,9 +112,9 @@ class ParallelDeadlineGroupTest extends CommandTestBase
@Test
void parallelDeadlineRequirementErrorTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
Command command1 = command1Holder.getMock();

View File

@@ -92,10 +92,10 @@ class ParallelRaceGroupTest extends CommandTestBase
@Test
void parallelRaceRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system4 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
Subsystem system4 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
@@ -117,9 +117,9 @@ class ParallelRaceGroupTest extends CommandTestBase
@Test
void parallelRaceRequirementErrorTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);
Command command1 = command1Holder.getMock();
@@ -131,8 +131,8 @@ class ParallelRaceGroupTest extends CommandTestBase
@Test
void parallelRaceOnlyCallsEndOnceTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
MockCommandHolder command1Holder = new MockCommandHolder(true, system1);
Command command1 = command1Holder.getMock();

View File

@@ -48,7 +48,7 @@ class SchedulerTest extends CommandTestBase {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicInteger counter = new AtomicInteger(0);
Subsystem system =
new Subsystem() {
new SubsystemBase() {
@Override
public void periodic() {
counter.incrementAndGet();
@@ -67,7 +67,7 @@ class SchedulerTest extends CommandTestBase {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicInteger counter = new AtomicInteger(0);
Subsystem system =
new Subsystem() {
new SubsystemBase() {
@Override
public void periodic() {
counter.incrementAndGet();

View File

@@ -25,7 +25,7 @@ class SchedulingRecursionTest extends CommandTestBase {
void cancelFromInitialize(InterruptionBehavior interruptionBehavior) {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicBoolean hasOtherRun = new AtomicBoolean();
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
Command selfCancels =
new Command() {
{
@@ -62,7 +62,7 @@ class SchedulingRecursionTest extends CommandTestBase {
void defaultCommandGetsRescheduledAfterSelfCanceling(InterruptionBehavior interruptionBehavior) {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicBoolean hasOtherRun = new AtomicBoolean();
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
Command selfCancels =
new Command() {
{
@@ -119,7 +119,7 @@ class SchedulingRecursionTest extends CommandTestBase {
void scheduleFromEndCancel() {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicInteger counter = new AtomicInteger();
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
InstantCommand other = new InstantCommand(() -> {}, requirement);
Command selfCancels =
new Command() {
@@ -146,7 +146,7 @@ class SchedulingRecursionTest extends CommandTestBase {
void scheduleFromEndInterrupt() {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicInteger counter = new AtomicInteger();
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
InstantCommand other = new InstantCommand(() -> {}, requirement);
Command selfCancels =
new Command() {
@@ -175,7 +175,7 @@ class SchedulingRecursionTest extends CommandTestBase {
void scheduleInitializeFromDefaultCommand(InterruptionBehavior interruptionBehavior) {
try (CommandScheduler scheduler = new CommandScheduler()) {
AtomicInteger counter = new AtomicInteger();
Subsystem requirement = new Subsystem() {};
Subsystem requirement = new SubsystemBase() {};
Command other =
new InstantCommand(() -> {}, requirement).withInterruptBehavior(interruptionBehavior);
Command defaultCommand =

View File

@@ -75,10 +75,10 @@ class SelectCommandTest extends CommandTestBase implements MultiCompositionTestB
@Test
void selectCommandRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system4 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
Subsystem system4 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);

View File

@@ -100,10 +100,10 @@ class SequentialCommandGroupTest extends CommandTestBase
@Test
void sequentialGroupRequirementTest() {
Subsystem system1 = new Subsystem() {};
Subsystem system2 = new Subsystem() {};
Subsystem system3 = new Subsystem() {};
Subsystem system4 = new Subsystem() {};
Subsystem system1 = new SubsystemBase() {};
Subsystem system2 = new SubsystemBase() {};
Subsystem system3 = new SubsystemBase() {};
Subsystem system4 = new SubsystemBase() {};
try (CommandScheduler scheduler = new CommandScheduler()) {
MockCommandHolder command1Holder = new MockCommandHolder(true, system1, system2);

View File

@@ -13,13 +13,13 @@
#include "frc2/command/CommandHelper.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/Subsystem.h"
#include "frc2/command/SubsystemBase.h"
#include "gmock/gmock.h"
#include "make_vector.h"
namespace frc2 {
class TestSubsystem : public Subsystem {
class TestSubsystem : public SubsystemBase {
public:
explicit TestSubsystem(std::function<void()> periodic = [] {})
: m_periodic{periodic} {}