[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:
Ryan Blue
2023-07-14 01:12:01 -04:00
committed by GitHub
parent 7ac932996a
commit aaea85ff16
176 changed files with 887 additions and 910 deletions

View File

@@ -5,12 +5,12 @@
package edu.wpi.first.wpilibj.templates.commandbased.commands;
import edu.wpi.first.wpilibj.templates.commandbased.subsystems.ExampleSubsystem;
import edu.wpi.first.wpilibj2.command.CommandBase;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
public final class Autos {
/** Example static factory for an autonomous command. */
public static CommandBase exampleAuto(ExampleSubsystem subsystem) {
public static Command exampleAuto(ExampleSubsystem subsystem) {
return Commands.sequence(subsystem.exampleMethodCommand(), new ExampleCommand(subsystem));
}

View File

@@ -5,10 +5,10 @@
package edu.wpi.first.wpilibj.templates.commandbased.commands;
import edu.wpi.first.wpilibj.templates.commandbased.subsystems.ExampleSubsystem;
import edu.wpi.first.wpilibj2.command.CommandBase;
import edu.wpi.first.wpilibj2.command.Command;
/** An example command that uses an example subsystem. */
public class ExampleCommand extends CommandBase {
public class ExampleCommand extends Command {
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
private final ExampleSubsystem m_subsystem;

View File

@@ -4,10 +4,10 @@
package edu.wpi.first.wpilibj.templates.commandbased.subsystems;
import edu.wpi.first.wpilibj2.command.CommandBase;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Subsystem;
public class ExampleSubsystem extends SubsystemBase {
public class ExampleSubsystem extends Subsystem {
/** Creates a new ExampleSubsystem. */
public ExampleSubsystem() {}
@@ -16,7 +16,7 @@ public class ExampleSubsystem extends SubsystemBase {
*
* @return a command
*/
public CommandBase exampleMethodCommand() {
public Command exampleMethodCommand() {
// Inline construction of command goes here.
// Subsystem::RunOnce implicitly requires `this` subsystem.
return runOnce(

View File

@@ -5,10 +5,10 @@
package edu.wpi.first.wpilibj.templates.romicommandbased.commands;
import edu.wpi.first.wpilibj.templates.romicommandbased.subsystems.RomiDrivetrain;
import edu.wpi.first.wpilibj2.command.CommandBase;
import edu.wpi.first.wpilibj2.command.Command;
/** An example command that uses an example subsystem. */
public class ExampleCommand extends CommandBase {
public class ExampleCommand extends Command {
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"})
private final RomiDrivetrain m_subsystem;

View File

@@ -7,9 +7,9 @@ package edu.wpi.first.wpilibj.templates.romicommandbased.subsystems;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.Spark;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.Subsystem;
public class RomiDrivetrain extends SubsystemBase {
public class RomiDrivetrain extends Subsystem {
private static final double kCountsPerRevolution = 1440.0;
private static final double kWheelDiameterInch = 2.75591; // 70 mm