From f7eb1d7d26afe67e5b8014dfd7111463b0480528 Mon Sep 17 00:00:00 2001 From: OnDYCLaptop Date: Thu, 5 Mar 2026 19:29:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E7=9B=98=E4=BF=AE=E6=AD=A3ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/frc/robot/Constants.java | 6 +- .../subsystems/CommandSwerveDrivetrain.java | 75 +------------------ .../robot/subsystems/ShooterSubsystem.java | 5 ++ 3 files changed, 9 insertions(+), 77 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index a05d6dc..06a788c 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -26,15 +26,15 @@ public final class Constants { public static final Slot0Configs backboardSlot0Configs = new Slot0Configs() .withKP(0.01).withKI(0).withKD(0) - .withKV(0.008).withKA(0.0).withKS(0.010); + .withKV(0.03).withKA(0.0).withKS(0.010); public class backboardPositionPID { - public static final double kP = 0.1; + public static final double kP = 0.3; public static final double kI = 0.0; public static final double kD = 0.0; } - public static final double backboardSpeedMax = 30; //也就是output + public static final double backboardSpeedMax = 60; //也就是output // 背板的上下限位角度 public static final double backboardUpLimit = 3000.0; // 背板上限角度(根据实际需求设置) public static final double backboardDownLimit = 0.0; // 背板下限角度(根据实际需求设置) diff --git a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java index ffda559..3189e76 100644 --- a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java +++ b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java @@ -130,80 +130,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su new SwerveRequest.ApplyRobotSpeeds().withSpeeds(scaled) ); } - - // public String driveToAprilTagOfClimber(double speed) { - // // 记录当前方向,作为目标方向,避免在驱动过程中偏航 - // Rotation2d TargetHeading=getPose().getRotation(); - // // 设置 Limelight pipeline(25赛季只有一条,直接设置) - // LimelightHelpers.setPipelineIndex(Constants.Limelight.LIMELIGHT_NAME_Intaker,Constants.Limelight.Pipeline); - - // // 如果 Limelight 没有检测到目标,直接返回 - // if (!LimelightSupplier.isTargetVisible()) { - // return "No Target"; - // } - // // 获取检测到的 AprilTag ID - // int trueId = LimelightSupplier.getAprilTagID(); - - // // 只有特定的 Tag ID 被认为是目标 - // int[] validTagIDs = {16,32}; - // boolean isValidTag = false; - // for (int id : validTagIDs) { - // if (id == trueId) { - // isValidTag = true; - // break; - // } - // } - // if (!isValidTag) { - // return "No Target"; - // } - - // // 获取 Limelight 的偏移数据 - // double tx = LimelightSupplier.getTX(); // 水平偏移角度 - // double targetTz = -LimelightSupplier.getTargetTZ(); // 目标与底盘前方的距离,取负方便坐标系 - // double ry = LimelightSupplier.getTargetRotationY(); // 目标旋转角 - - // // 根据速度参数计算实际驱动速度 - // double multiply = Constants.Swerve.maxSpeed * speed; - - // // 水平偏移死区处理 - // if (Math.abs(tx) < Constants.Limelight.TXDeadHand) { - // tx = 0; - // } else { - // tx *= multiply; - // } - - // // 前进距离死区处理 - // if (Math.abs(targetTz) < Constants.Limelight.TZDeadHand) { - // targetTz = 0; - // } else { - // targetTz *= multiply; - // targetTz *= 5; // 放大系数,增加前进响应 - // } - - // // 旋转角度死区处理 - // if (Math.abs(ry) < Constants.Swerve.reefCorrection.roatationYDeadHand) { - // ry = 0; - // } else { - // ry /= 10; // 缩小旋转响应 - // ry = Math.min(ry, Constants.Swerve.maxAngularVelocity); - // ry = Math.max(ry, -Constants.Swerve.maxAngularVelocity); - // } - - // // 输出到 SmartDashboard 方便调试 - // SmartDashboard.putNumber("driveTx_r", tx); - // SmartDashboard.putNumber("driveTz_r", targetTz); - // SmartDashboard.putNumber("driveRy_r", ry); - - // // 调用底盘驱动方法 - // drive( - // new Translation2d(tx, targetTz), // x = 水平, y = 前进 - // ry, // 旋转速度 - // false, // 是否相对场地驱动 - // false // 是否速度保持为绝对速度 - // ); - // return "Driving to AprilTag"; - // } - + private static final double kMaxVisionJumpMeters = 1.0; private static final double kMaxOmegaDegPerSec = 360.0; diff --git a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java index 2bf1cf0..68e49a9 100644 --- a/src/main/java/frc/robot/subsystems/ShooterSubsystem.java +++ b/src/main/java/frc/robot/subsystems/ShooterSubsystem.java @@ -98,6 +98,11 @@ public class ShooterSubsystem extends SubsystemBase { //调试用 public void setBackboardSpeedByRPS(double speed){ + if (speed > 0 && speed < 10) { + speed = 10; + } else if (speed < 0 && speed > -10) { + speed = -10; + } backboardMotor.setControl(velocityRequest.withVelocity(speed)); }