[commands] Move GroupedCommands to CommandScheduler (#4728)

Move the command group checking functionality from CommandGroupBase into CommandScheduler.
Update references to grouping as composition for clarity (because explicitly grouping isn't the only way to do it).
Deprecate the static factory methods parallel, race, and deadline in CommandGroupBase in favor of the identical ones in Commands.
This commit is contained in:
Starlight220
2022-12-07 07:13:31 +02:00
committed by GitHub
parent f18fd41ac3
commit 4bbdbdfb48
46 changed files with 450 additions and 472 deletions

View File

@@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Claw;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Drivetrain;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Elevator;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Wrist;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
/** The main autonomous command to pickup and deliver the soda to the box. */
@@ -22,6 +23,6 @@ public class Autonomous extends SequentialCommandGroup {
new Place(claw, wrist, elevator),
new SetDistanceToBox(0.60, drive),
// new DriveStraight(-2), // Use Encoders if ultrasonic is broken
parallel(new SetWristSetpoint(-45, wrist), new CloseClaw(claw)));
Commands.parallel(new SetWristSetpoint(-45, wrist), new CloseClaw(claw)));
}
}

View File

@@ -7,6 +7,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Claw;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Elevator;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Wrist;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
/**
@@ -23,6 +24,7 @@ public class Pickup extends SequentialCommandGroup {
public Pickup(Claw claw, Wrist wrist, Elevator elevator) {
addCommands(
new CloseClaw(claw),
parallel(new SetWristSetpoint(-45, wrist), new SetElevatorSetpoint(0.25, elevator)));
Commands.parallel(
new SetWristSetpoint(-45, wrist), new SetElevatorSetpoint(0.25, elevator)));
}
}

View File

@@ -7,6 +7,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Claw;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Elevator;
import edu.wpi.first.wpilibj.examples.gearsbot.subsystems.Wrist;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
/** Make sure the robot is in a state to pickup soda cans. */
@@ -21,6 +22,6 @@ public class PrepareToPickup extends SequentialCommandGroup {
public PrepareToPickup(Claw claw, Wrist wrist, Elevator elevator) {
addCommands(
new OpenClaw(claw),
parallel(new SetWristSetpoint(0, wrist), new SetElevatorSetpoint(0, elevator)));
Commands.parallel(new SetWristSetpoint(0, wrist), new SetElevatorSetpoint(0, elevator)));
}
}

View File

@@ -4,7 +4,7 @@
package edu.wpi.first.wpilibj.examples.rapidreactcommandbot;
import static edu.wpi.first.wpilibj2.command.CommandGroupBase.parallel;
import static edu.wpi.first.wpilibj2.command.Commands.parallel;
import edu.wpi.first.wpilibj.examples.rapidreactcommandbot.Constants.AutoConstants;
import edu.wpi.first.wpilibj.examples.rapidreactcommandbot.Constants.OIConstants;