mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11: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:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user