This commit is contained in:
OnDYCLaptop
2026-03-10 21:01:01 +08:00
parent 50c9af952c
commit 1f397e6b6e
10 changed files with 115 additions and 70 deletions
@@ -0,0 +1,19 @@
{
"version": "2025.0",
"command": {
"type": "sequential",
"data": {
"commands": [
{
"type": "named",
"data": {
"name": "start_intake_timelimit"
}
}
]
}
},
"resetOdom": true,
"folder": "Red Middle",
"choreoAuto": false
}
@@ -22,12 +22,30 @@
"pathName": "Shoot to Climb Step1 Red" "pathName": "Shoot to Climb Step1 Red"
} }
}, },
{
"type": "wait",
"data": {
"waitTime": 1.0
}
},
{ {
"type": "path", "type": "path",
"data": { "data": {
"pathName": "Climb Step2 Red" "pathName": "Climb Step2 Red"
} }
}, },
{
"type": "wait",
"data": {
"waitTime": 1.0
}
},
{
"type": "named",
"data": {
"name": "climb_up"
}
},
{ {
"type": "path", "type": "path",
"data": { "data": {
@@ -8,20 +8,20 @@
}, },
"prevControl": null, "prevControl": null,
"nextControl": { "nextControl": {
"x": 15.610835339716738, "x": 15.522355156858092,
"y": 3.3590426144037364 "y": 3.365
}, },
"isLocked": false, "isLocked": false,
"linkedName": null "linkedName": null
}, },
{ {
"anchor": { "anchor": {
"x": 15.467, "x": 15.517,
"y": 3.365 "y": 3.365
}, },
"prevControl": { "prevControl": {
"x": 15.743555432745389, "x": 15.77785583456356,
"y": 3.3550226257587115 "y": 3.365
}, },
"nextControl": null, "nextControl": null,
"isLocked": false, "isLocked": false,
@@ -3,25 +3,25 @@
"waypoints": [ "waypoints": [
{ {
"anchor": { "anchor": {
"x": 15.467, "x": 15.517,
"y": 3.365 "y": 3.365
}, },
"prevControl": null, "prevControl": null,
"nextControl": { "nextControl": {
"x": 15.716589593303949, "x": 15.767,
"y": 3.3506809597259686 "y": 3.365
}, },
"isLocked": false, "isLocked": false,
"linkedName": null "linkedName": null
}, },
{ {
"anchor": { "anchor": {
"x": 15.467, "x": 15.517,
"y": 3.465 "y": 3.465
}, },
"prevControl": { "prevControl": {
"x": 15.191301517038063, "x": 15.239842716853756,
"y": 3.4933990509259307 "y": 3.465
}, },
"nextControl": null, "nextControl": null,
"isLocked": false, "isLocked": false,
+2 -2
View File
@@ -42,7 +42,7 @@ public final class Constants {
public static final double backboardDownLimit = 0.0; // 背板下限角度(根据实际需求设置) public static final double backboardDownLimit = 0.0; // 背板下限角度(根据实际需求设置)
} }
public class AutoPositioning { public class AutoPositioning {
public static final double autoRotationkP = 0.1; public static final double autoRotationkP = 0.08;
public static final double autoRotationForBumpTargetDegrees = 45; public static final double autoRotationForBumpTargetDegrees = 45;
public static final double autoRotationForTrenchTargetDegrees = 0; public static final double autoRotationForTrenchTargetDegrees = 0;
public static final boolean teleopOffsetEnabled = true; public static final boolean teleopOffsetEnabled = true;
@@ -149,7 +149,7 @@ public final class Constants {
public static double climbUpTicks = 94; // TODO: 实测后调整 public static double climbUpTicks = 94; // TODO: 实测后调整
public static double climbDownTicks = 0; // TODO: 实测后调整 public static double climbDownTicks = 0; // TODO: 实测后调整
public static double climbDownAutoTicks = -5; // TODO: 实测后调整,自动爬时可能不需要完全降到底 public static double climbDownAutoTicks = 0; // TODO: 实测后调整,自动爬时可能不需要完全降到底
public static final double climbVelocity = -200; public static final double climbVelocity = -200;
public static final double holdToleranceRot = 0.5; public static final double holdToleranceRot = 0.5;
public static final double deltaDownTicks = 1; public static final double deltaDownTicks = 1;
+15 -15
View File
@@ -91,7 +91,7 @@ public class RobotContainer {
configueClimber(); configueClimber();
bingdingLED(); bingdingLED();
configueIntaker(); configueIntaker();
configureBindings(); //configureBindings();
} }
/* ====================== */ /* ====================== */
@@ -202,21 +202,21 @@ public class RobotContainer {
controllerupper.a().onTrue(intakerControls.resetIntakerRotaterEncoderCommand(IntakerSubsystem)); controllerupper.a().onTrue(intakerControls.resetIntakerRotaterEncoderCommand(IntakerSubsystem));
} }
private void configureBindings() { // private void configureBindings() {
teleopStartTrigger.onTrue(handleClimberAtTeleopStartCommand()); // teleopStartTrigger.onTrue(handleClimberAtTeleopStartCommand());
} // }
private Command handleClimberAtTeleopStartCommand() { // private Command handleClimberAtTeleopStartCommand() {
return new InstantCommand(() -> { // return new InstantCommand(() -> {
if (climberSubsystem.wasAutoClimbUsedInAuto()) { // if (climberSubsystem.wasAutoClimbUsedInAuto()) {
climberSubsystem.climbUp(); // climberSubsystem.climbUp();
climberSubsystem.clearAutoClimbUsedInAutoFlag(); // climberSubsystem.clearAutoClimbUsedInAutoFlag();
} // }
}, climberSubsystem); // }, climberSubsystem);
} // }
public ClimberSubsystem getClimberSubsystem() { // public ClimberSubsystem getClimberSubsystem() {
return climberSubsystem; // return climberSubsystem;
} // }
} }
@@ -32,7 +32,7 @@ import frc.robot.Constants.RobotStatus;
ShooterControls shooterControls ShooterControls shooterControls
) { ) {
NamedCommands.registerCommand("climb_up", climb_up(climber)); NamedCommands.registerCommand("climb_up", climb_up(climber));
NamedCommands.registerCommand("climb_down", climb_down(climber)); //NamedCommands.registerCommand("climb_down", climb_down(climber));
NamedCommands.registerCommand("start_intake", start_intake(intaker)); NamedCommands.registerCommand("start_intake", start_intake(intaker));
NamedCommands.registerCommand("start_intake_timelimit", start_intake_timelimit(intaker)); NamedCommands.registerCommand("start_intake_timelimit", start_intake_timelimit(intaker));
NamedCommands.registerCommand("stop_intake", stop_intake(intaker)); NamedCommands.registerCommand("stop_intake", stop_intake(intaker));
@@ -40,32 +40,30 @@ import frc.robot.Constants.RobotStatus;
NamedCommands.registerCommand("intaker_up", intaker_up(intaker)); NamedCommands.registerCommand("intaker_up", intaker_up(intaker));
NamedCommands.registerCommand("auto_align_to_climb", autoAlignToClimb(drivetrain)); NamedCommands.registerCommand("auto_align_to_climb", autoAlignToClimb(drivetrain));
NamedCommands.registerCommand("shoot", shoot(shooter)); NamedCommands.registerCommand("shoot", shoot(shooter));
NamedCommands.registerCommand("Shake", Autocommand.shake(driveControls)); // NamedCommands.registerCommand("Shake", Autocommand.shake(driveControls));
NamedCommands.registerCommand("AutoAim", Autocommand.autoAim(driveControls)); // NamedCommands.registerCommand("AutoAim", Autocommand.autoAim(driveControls));
NamedCommands.registerCommand("AutoShoot", Autocommand.autoShoot(shooterControls)); // NamedCommands.registerCommand("AutoShoot", Autocommand.autoShoot(shooterControls));
} }
public static Command climb_up(ClimberSubsystem climber) { public static Command climb_up(ClimberSubsystem climber) {
return new RunCommand(() -> { return new RunCommand(() -> {
climber.climbUp(); // 控制爬升器上升 climber.climbUp(); // 控制爬升器上升
}, climber).withTimeout(1.0).andThen(new RunCommand(() -> { }, climber).withTimeout(1.0).andThen(new InstantCommand(() -> {
climber.climbUpNonStopforAuto();
}, climber).withTimeout(0.5)).andThen(new InstantCommand(() -> {
climber.holdPosition(); // 停止并锁定当前爬升器位置 climber.holdPosition(); // 停止并锁定当前爬升器位置
}, climber)); }, climber));
} }
public static Command climb_down(ClimberSubsystem climber) { // public static Command climb_down(ClimberSubsystem climber) {
return Commands.sequence( // return Commands.sequence(
new InstantCommand(climber::markAutoClimbUsedInAuto), // new InstantCommand(climber::markAutoClimbUsedInAuto),
new RunCommand(() -> { // new RunCommand(() -> {
climber.climbDownAuto(); // climber.climbDownAuto();
}, climber).withTimeout(2.0), // }, climber).withTimeout(2.0),
new InstantCommand(() -> { // new InstantCommand(() -> {
climber.holdPosition(); // climber.holdPosition();
}, climber) // }, climber)
); // );
} // }
public static Command start_intake(IntakerSubsystem intaker) { public static Command start_intake(IntakerSubsystem intaker) {
return new RunCommand(() -> { return new RunCommand(() -> {
@@ -138,15 +136,15 @@ import frc.robot.Constants.RobotStatus;
shooter.setConveyorSpeedByRPS(0); // 停止输送 shooter.setConveyorSpeedByRPS(0); // 停止输送
}, shooter))); }, shooter)));
} }
public static Command autoAim(DriveControls driveControls) { // public static Command autoAim(DriveControls driveControls) {
return driveControls.autoAimCommand(); // return driveControls.autoAimCommand();
} // }
public static Command autoShoot(ShooterControls shooterControl) { // public static Command autoShoot(ShooterControls shooterControl) {
return shooterControl.autoShootToHubCommand(); // return shooterControl.autoShootToHubCommand();
} // }
public static Command shake(DriveControls driveControls) { // public static Command shake(DriveControls driveControls) {
return driveControls.shakeCommand(); // return driveControls.shakeCommand();
} // }
} }
@@ -66,7 +66,17 @@ public class TunerConstants {
); );
private static final CANcoderConfiguration encoderInitialConfigs = new CANcoderConfiguration(); private static final CANcoderConfiguration encoderInitialConfigs = new CANcoderConfiguration();
// Configs for the Pigeon 2; leave this null to skip applying Pigeon 2 configs // Configs for the Pigeon 2; leave this null to skip applying Pigeon 2 configs
private static final Pigeon2Configuration pigeonConfigs = null; private static final Pigeon2Configuration pigeonConfigs =
new Pigeon2Configuration()
.withGyroTrim(
new GyroTrimConfigs()
.withGyroScalarZ(-5.0)
)
.withPigeon2Features(
new Pigeon2FeaturesConfigs()
.withEnableCompass(false)
);
// CAN bus that the devices are located on; // CAN bus that the devices are located on;
// All swerve devices must share the same CAN bus // All swerve devices must share the same CAN bus
@@ -16,7 +16,7 @@ import frc.robot.Constants;
public class ClimberSubsystem extends SubsystemBase { public class ClimberSubsystem extends SubsystemBase {
private boolean autoClimbUsedInAuto = false; // private boolean autoClimbUsedInAuto = false;
private final TalonFX climberMotor; private final TalonFX climberMotor;
private double targetPositionTicks; private double targetPositionTicks;
@@ -102,17 +102,17 @@ public class ClimberSubsystem extends SubsystemBase {
climberMotor.set(0); climberMotor.set(0);
} }
public void markAutoClimbUsedInAuto() { // public void markAutoClimbUsedInAuto() {
autoClimbUsedInAuto = true; // autoClimbUsedInAuto = true;
} // }
public boolean wasAutoClimbUsedInAuto() { // public boolean wasAutoClimbUsedInAuto() {
return autoClimbUsedInAuto; // return autoClimbUsedInAuto;
} // }
public void clearAutoClimbUsedInAutoFlag() { // public void clearAutoClimbUsedInAutoFlag() {
autoClimbUsedInAuto = false; // autoClimbUsedInAuto = false;
} // }
@Override @Override
public void periodic() { public void periodic() {
@@ -163,7 +163,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
public void forceUsingLimelightmt2() { public void forceUsingLimelightmt2() {
LimelightHelpers.PoseEstimate mt2 = LimelightHelpers.PoseEstimate mt2 =
LimelightHelpers.getBotPoseEstimate_wpiBlue(Constants.Limelight.LIMELIGHT_NAME_Shooter); LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(Constants.Limelight.LIMELIGHT_NAME_Shooter);
if (mt2 == null || mt2.tagCount == 0) { if (mt2 == null || mt2.tagCount == 0) {
return; return;
@@ -258,7 +258,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
private LimelightHelpers.PoseEstimate getLimelightPoseEstimate(String limelightName) { private LimelightHelpers.PoseEstimate getLimelightPoseEstimate(String limelightName) {
if (Constants.Limelight.UsingMetaTag2) { if (Constants.Limelight.UsingMetaTag2) {
return LimelightHelpers.getBotPoseEstimate_wpiBlue(limelightName); return LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(limelightName);
} }
return LimelightHelpers.getBotPoseEstimate_wpiBlue(limelightName); return LimelightHelpers.getBotPoseEstimate_wpiBlue(limelightName);
} }
@@ -415,8 +415,8 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
Pose2d pose = getState().Pose; Pose2d pose = getState().Pose;
m_field.setRobotPose(pose); m_field.setRobotPose(pose);
posePub.set(pose); posePub.set(pose);
shooter_ll_field.setRobotPose(LimelightHelpers.getBotPoseEstimate_wpiBlue(Constants.Limelight.LIMELIGHT_NAME_Shooter).pose); shooter_ll_field.setRobotPose(LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(Constants.Limelight.LIMELIGHT_NAME_Shooter).pose);
intaker_ll_field.setRobotPose(LimelightHelpers.getBotPoseEstimate_wpiBlue(Constants.Limelight.LIMELIGHT_NAME_Intaker).pose); intaker_ll_field.setRobotPose(LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(Constants.Limelight.LIMELIGHT_NAME_Intaker).pose);
driveNetworkTable.getEntry("YawFromState").setDouble(getState().Pose.getRotation().getDegrees()); driveNetworkTable.getEntry("YawFromState").setDouble(getState().Pose.getRotation().getDegrees());
driveNetworkTable.getEntry("DriveMode").setString(m_driveMode.name()); driveNetworkTable.getEntry("DriveMode").setString(m_driveMode.name());
driveNetworkTable.getEntry("IsFieldCentric").setBoolean(m_driveMode == DriveMode.FIELD_CENTRIC); driveNetworkTable.getEntry("IsFieldCentric").setBoolean(m_driveMode == DriveMode.FIELD_CENTRIC);