一个手柄的安全演示版

This commit is contained in:
OnDYCLaptop
2026-05-19 15:37:54 +08:00
parent dd83652411
commit 0b6cf55dc0
3 changed files with 20 additions and 12 deletions
+12 -10
View File
@@ -36,9 +36,9 @@ public class RobotContainer {
/* 手柄 */ /* 手柄 */
/* ====================== */ /* ====================== */
// 使用2个 Xbox 手柄(端口 0,1) // Demo mode uses one Xbox controller on port 0.
private final CommandXboxController controllerlower = new CommandXboxController(0); private final CommandXboxController controllerlower = new CommandXboxController(0);
private final CommandXboxController controllerupper = new CommandXboxController(1); private final CommandXboxController controllerupper = controllerlower;
/* ====================== */ /* ====================== */
/* 子系统 */ /* 子系统 */
@@ -124,6 +124,8 @@ public class RobotContainer {
// Disabled 时进入 idle(防止模块乱动) // Disabled 时进入 idle(防止模块乱动)
RobotModeTriggers.disabled().whileTrue(driveControls.idleCommand()); RobotModeTriggers.disabled().whileTrue(driveControls.idleCommand());
if (!Constants.DemoMode.ENABLED) {
//左保险:按住刹车 //左保险:按住刹车
controllerlower.leftBumper() controllerlower.leftBumper()
@@ -139,13 +141,7 @@ public class RobotContainer {
controllerlower.back().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric)); controllerlower.back().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric));
// Start:强行使用metaTag2全场定位 // Start:强行使用metaTag2全场定位
if (Constants.DemoMode.ENABLED) { controllerlower.start().whileTrue(drivetrain.run(drivetrain::forceUsingLimelightmt2));
controllerlower.start()
.onTrue(Commands.runOnce(driveControls::emergencyStop)
.andThen(robotStatusManager.setStatusCommand(RobotStatus.Stopped)))
.onFalse(robotStatusManager.setStatusCommand(RobotStatus.AllTelop));
} else {
controllerlower.start().whileTrue(drivetrain.run(drivetrain::forceUsingLimelightmt2));
controllerlower.a().whileTrue(drivetrain.run(()->{drivetrain.forceUsingLimelightmt2WithllName(Constants.Limelight.LIMELIGHT_NAME_Shooter); controllerlower.a().whileTrue(drivetrain.run(()->{drivetrain.forceUsingLimelightmt2WithllName(Constants.Limelight.LIMELIGHT_NAME_Shooter);
System.out.println("Try using shooter for metatag2"); System.out.println("Try using shooter for metatag2");
@@ -188,7 +184,13 @@ public class RobotContainer {
controllerupper.povUp().onTrue(Commands.runOnce(() -> shooterControls.adjustBackboardRateOffset(100))); controllerupper.povUp().onTrue(Commands.runOnce(() -> shooterControls.adjustBackboardRateOffset(100)));
controllerupper.povDown().onTrue(Commands.runOnce(() -> shooterControls.adjustBackboardRateOffset(-100))); controllerupper.povDown().onTrue(Commands.runOnce(() -> shooterControls.adjustBackboardRateOffset(-100)));
controllerupper.back().onTrue(Commands.runOnce(() -> shooterControls.resetOffsets())); controllerupper.back().onTrue(Commands.runOnce(() -> shooterControls.resetOffsets()));
controllerupper.start().onTrue(shooterControls.resetBackboardCommand()); if (Constants.DemoMode.ENABLED) {
controllerupper.rightTrigger()
.onTrue(robotStatusManager.setStatusCommand(RobotStatus.AutoAimming))
.onFalse(robotStatusManager.setStatusCommand(RobotStatus.AllTelop));
} else {
controllerupper.start().onTrue(shooterControls.resetBackboardCommand());
}
} }
@@ -81,6 +81,12 @@ public class IntakerControls {
IntakerSubsystem.setIntakerGetterSpeed(getterspeed); IntakerSubsystem.setIntakerGetterSpeed(getterspeed);
boolean demoModeEnabled = Constants.DemoMode.ENABLED;
if (demoModeEnabled) {
IntakerSubsystem.stopIntakerotater();
return;
}
if(controller.getLeftY() < -0.5){ if(controller.getLeftY() < -0.5){
IntakerSubsystem.IntakerUpNonStop(); IntakerSubsystem.IntakerUpNonStop();
} else if(controller.getLeftY() > 0.5){ } else if(controller.getLeftY() > 0.5){
@@ -93,4 +99,4 @@ public class IntakerControls {
public Command resetIntakerRotaterEncoderCommand(IntakerSubsystem intakerSubsystem) { public Command resetIntakerRotaterEncoderCommand(IntakerSubsystem intakerSubsystem) {
return Commands.runOnce(intakerSubsystem::zeroEncoder, intakerSubsystem); return Commands.runOnce(intakerSubsystem::zeroEncoder, intakerSubsystem);
} }
} }
@@ -48,7 +48,7 @@ public class ShooterControls {
shooterSubsystem.outputBackboard(); shooterSubsystem.outputBackboard();
} }
shooterSubsystem.setFlywheelSpeedByRPS(0); shooterSubsystem.setFlywheelSpeedByRPS(0);
if(controller.a().getAsBoolean()) { shooterSubsystem.setConveyorSpeedByRPS(Constants.Shooter.conveyorSpeed);} if(!Constants.DemoMode.ENABLED && controller.a().getAsBoolean()) { shooterSubsystem.setConveyorSpeedByRPS(Constants.Shooter.conveyorSpeed);}
else{shooterSubsystem.setConveyorSpeedByRPS(0);} else{shooterSubsystem.setConveyorSpeedByRPS(0);}
break; break;
case PassingBall: case PassingBall: