若自动爬升 则手动阶段自动让钩子下降(待测试
This commit is contained in:
@@ -70,6 +70,7 @@ public class RobotContainer {
|
|||||||
private final SendableChooser<Command> autoChooser;
|
private final SendableChooser<Command> autoChooser;
|
||||||
|
|
||||||
private final Trigger enableTrigger = new Trigger(DriverStation::isEnabled);
|
private final Trigger enableTrigger = new Trigger(DriverStation::isEnabled);
|
||||||
|
private final Trigger teleopStartTrigger = new Trigger(DriverStation::isTeleopEnabled);
|
||||||
|
|
||||||
|
|
||||||
public RobotContainer() {
|
public RobotContainer() {
|
||||||
@@ -90,6 +91,7 @@ public class RobotContainer {
|
|||||||
configueClimber();
|
configueClimber();
|
||||||
bingdingLED();
|
bingdingLED();
|
||||||
configueIntaker();
|
configueIntaker();
|
||||||
|
configureBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ====================== */
|
/* ====================== */
|
||||||
@@ -200,4 +202,21 @@ public class RobotContainer {
|
|||||||
controllerupper.a().onTrue(intakerControls.resetIntakerRotaterEncoderCommand(IntakerSubsystem));
|
controllerupper.a().onTrue(intakerControls.resetIntakerRotaterEncoderCommand(IntakerSubsystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void configureBindings() {
|
||||||
|
teleopStartTrigger.onTrue(handleClimberAtTeleopStartCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Command handleClimberAtTeleopStartCommand() {
|
||||||
|
return new InstantCommand(() -> {
|
||||||
|
if (climberSubsystem.wasAutoClimbUsedInAuto()) {
|
||||||
|
climberSubsystem.climbUp();
|
||||||
|
climberSubsystem.clearAutoClimbUsedInAutoFlag();
|
||||||
|
}
|
||||||
|
}, climberSubsystem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClimberSubsystem getClimberSubsystem() {
|
||||||
|
return climberSubsystem;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,13 +56,17 @@ import frc.robot.Constants.RobotStatus;
|
|||||||
}, climber));
|
}, climber));
|
||||||
}
|
}
|
||||||
public static Command climb_down(ClimberSubsystem climber) {
|
public static Command climb_down(ClimberSubsystem climber) {
|
||||||
return new RunCommand(() -> {
|
return Commands.sequence(
|
||||||
climber.climbDownAuto(); // 控制爬升器下降
|
new InstantCommand(climber::markAutoClimbUsedInAuto),
|
||||||
}, climber).withTimeout(2.0) //
|
new RunCommand(() -> {
|
||||||
.andThen(new InstantCommand(() -> {
|
climber.climbDownAuto();
|
||||||
climber.holdPosition(); // 停止并锁定当前爬升器位置
|
}, climber).withTimeout(2.0),
|
||||||
}, climber));
|
new InstantCommand(() -> {
|
||||||
|
climber.holdPosition();
|
||||||
|
}, climber)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command start_intake(IntakerSubsystem intaker) {
|
public static Command start_intake(IntakerSubsystem intaker) {
|
||||||
return new RunCommand(() -> {
|
return new RunCommand(() -> {
|
||||||
intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球
|
intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球
|
||||||
|
|||||||
@@ -58,7 +58,5 @@ public class ClimberControls {
|
|||||||
public Command resetClimberEncoderCommand(ClimberSubsystem climber) {
|
public Command resetClimberEncoderCommand(ClimberSubsystem climber) {
|
||||||
return Commands.runOnce(climber::zeroEncoder, climber);
|
return Commands.runOnce(climber::zeroEncoder, climber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import frc.robot.Constants;
|
|||||||
|
|
||||||
public class ClimberSubsystem extends SubsystemBase {
|
public class ClimberSubsystem extends SubsystemBase {
|
||||||
|
|
||||||
|
private boolean autoClimbUsedInAuto = false;
|
||||||
|
|
||||||
private final TalonFX climberMotor;
|
private final TalonFX climberMotor;
|
||||||
private double targetPositionTicks;
|
private double targetPositionTicks;
|
||||||
|
|
||||||
@@ -100,6 +102,18 @@ public class ClimberSubsystem extends SubsystemBase {
|
|||||||
climberMotor.set(0);
|
climberMotor.set(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markAutoClimbUsedInAuto() {
|
||||||
|
autoClimbUsedInAuto = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean wasAutoClimbUsedInAuto() {
|
||||||
|
return autoClimbUsedInAuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAutoClimbUsedInAutoFlag() {
|
||||||
|
autoClimbUsedInAuto = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void periodic() {
|
public void periodic() {
|
||||||
climberTable.getEntry("velocityRps").setDouble(getVelocityRps());
|
climberTable.getEntry("velocityRps").setDouble(getVelocityRps());
|
||||||
|
|||||||
Reference in New Issue
Block a user