mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] HatchbotInlined: Use Subsystem factories (#4765)
This commit is contained in:
@@ -73,13 +73,9 @@ public class RobotContainer {
|
||||
*/
|
||||
private void configureButtonBindings() {
|
||||
// Grab the hatch when the Circle button is pressed.
|
||||
m_driverController
|
||||
.circle()
|
||||
.onTrue(Commands.runOnce(m_hatchSubsystem::grabHatch, m_hatchSubsystem));
|
||||
m_driverController.circle().onTrue(m_hatchSubsystem.grabHatchCommand());
|
||||
// Release the hatch when the Square button is pressed.
|
||||
m_driverController
|
||||
.square()
|
||||
.onTrue(Commands.runOnce(m_hatchSubsystem::releaseHatch, m_hatchSubsystem));
|
||||
m_driverController.square().onTrue(m_hatchSubsystem.releaseHatchCommand());
|
||||
// While holding R1, drive at half speed
|
||||
m_driverController
|
||||
.R1()
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class Autos {
|
||||
driveSubsystem),
|
||||
|
||||
// Release the hatch
|
||||
Commands.runOnce(hatchSubsystem::releaseHatch, hatchSubsystem),
|
||||
hatchSubsystem.releaseHatchCommand(),
|
||||
|
||||
// Drive backward the specified distance
|
||||
new FunctionalCommand(
|
||||
|
||||
@@ -10,6 +10,7 @@ import static edu.wpi.first.wpilibj.DoubleSolenoid.Value.kReverse;
|
||||
import edu.wpi.first.wpilibj.DoubleSolenoid;
|
||||
import edu.wpi.first.wpilibj.PneumaticsModuleType;
|
||||
import edu.wpi.first.wpilibj.examples.hatchbotinlined.Constants.HatchConstants;
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
|
||||
/** A hatch mechanism actuated by a single {@link edu.wpi.first.wpilibj.DoubleSolenoid}. */
|
||||
@@ -21,12 +22,14 @@ public class HatchSubsystem extends SubsystemBase {
|
||||
HatchConstants.kHatchSolenoidPorts[1]);
|
||||
|
||||
/** Grabs the hatch. */
|
||||
public void grabHatch() {
|
||||
m_hatchSolenoid.set(kForward);
|
||||
public CommandBase grabHatchCommand() {
|
||||
// implicitly require `this`
|
||||
return this.runOnce(() -> m_hatchSolenoid.set(kForward));
|
||||
}
|
||||
|
||||
/** Releases the hatch. */
|
||||
public void releaseHatch() {
|
||||
m_hatchSolenoid.set(kReverse);
|
||||
public CommandBase releaseHatchCommand() {
|
||||
// implicitly require `this`
|
||||
return this.runOnce(() -> m_hatchSolenoid.set(kReverse));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user