diff --git a/simgui-ds.json b/simgui-ds.json new file mode 100644 index 0000000..73cc713 --- /dev/null +++ b/simgui-ds.json @@ -0,0 +1,92 @@ +{ + "keyboardJoysticks": [ + { + "axisConfig": [ + { + "decKey": 65, + "incKey": 68 + }, + { + "decKey": 87, + "incKey": 83 + }, + { + "decKey": 69, + "decayRate": 0.0, + "incKey": 82, + "keyRate": 0.009999999776482582 + } + ], + "axisCount": 3, + "buttonCount": 4, + "buttonKeys": [ + 90, + 88, + 67, + 86 + ], + "povConfig": [ + { + "key0": 328, + "key135": 323, + "key180": 322, + "key225": 321, + "key270": 324, + "key315": 327, + "key45": 329, + "key90": 326 + } + ], + "povCount": 1 + }, + { + "axisConfig": [ + { + "decKey": 74, + "incKey": 76 + }, + { + "decKey": 73, + "incKey": 75 + } + ], + "axisCount": 2, + "buttonCount": 4, + "buttonKeys": [ + 77, + 44, + 46, + 47 + ], + "povCount": 0 + }, + { + "axisConfig": [ + { + "decKey": 263, + "incKey": 262 + }, + { + "decKey": 265, + "incKey": 264 + } + ], + "axisCount": 2, + "buttonCount": 6, + "buttonKeys": [ + 260, + 268, + 266, + 261, + 269, + 267 + ], + "povCount": 0 + }, + { + "axisCount": 0, + "buttonCount": 0, + "povCount": 0 + } + ] +} diff --git a/src/main/deploy/pathplanner/autos/8 Balls Auto Middle Start Point.auto b/src/main/deploy/pathplanner/autos/8 Balls Auto Middle Start Point.auto new file mode 100644 index 0000000..337a25e --- /dev/null +++ b/src/main/deploy/pathplanner/autos/8 Balls Auto Middle Start Point.auto @@ -0,0 +1,25 @@ +{ + "version": "2025.0", + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "path", + "data": { + "pathName": "redBackAndShoot" + } + }, + { + "type": "named", + "data": { + "name": "shoot" + } + } + ] + } + }, + "resetOdom": true, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/8 Balls and Climb Middle Start.auto b/src/main/deploy/pathplanner/autos/8 Balls and Climb Middle Start.auto new file mode 100644 index 0000000..7414ac5 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/8 Balls and Climb Middle Start.auto @@ -0,0 +1,37 @@ +{ + "version": "2025.0", + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "path", + "data": { + "pathName": "redBackAndShoot" + } + }, + { + "type": "named", + "data": { + "name": "shoot" + } + }, + { + "type": "path", + "data": { + "pathName": "Climb Path step1" + } + }, + { + "type": "path", + "data": { + "pathName": "Climb Path step2" + } + } + ] + } + }, + "resetOdom": true, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/Depot Auto.auto b/src/main/deploy/pathplanner/autos/Depot Auto.auto new file mode 100644 index 0000000..4033630 --- /dev/null +++ b/src/main/deploy/pathplanner/autos/Depot Auto.auto @@ -0,0 +1,88 @@ +{ + "version": "2025.0", + "command": { + "type": "sequential", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "intaker_down" + } + }, + { + "type": "parallel", + "data": { + "commands": [ + { + "type": "path", + "data": { + "pathName": "redDepotPath" + } + } + ] + } + }, + { + "type": "named", + "data": { + "name": "start_intake_timelimit" + } + }, + { + "type": "parallel", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "start_intake_timelimit" + } + }, + { + "type": "path", + "data": { + "pathName": "depotIntakePath" + } + } + ] + } + }, + { + "type": "wait", + "data": { + "waitTime": 2.0 + } + }, + { + "type": "parallel", + "data": { + "commands": [ + { + "type": "named", + "data": { + "name": "intaker_up" + } + }, + { + "type": "path", + "data": { + "pathName": "depotShootPath" + } + } + ] + } + }, + { + "type": "named", + "data": { + "name": "shoot" + } + } + ] + } + }, + "resetOdom": true, + "folder": null, + "choreoAuto": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/autos/Line.auto b/src/main/deploy/pathplanner/autos/Line.auto index 9bc829a..85713c6 100644 --- a/src/main/deploy/pathplanner/autos/Line.auto +++ b/src/main/deploy/pathplanner/autos/Line.auto @@ -7,7 +7,7 @@ { "type": "path", "data": { - "pathName": "Line" + "pathName": "Climb Path step2" } } ] diff --git a/src/main/deploy/pathplanner/autos/LineGoAndBack.auto b/src/main/deploy/pathplanner/autos/LineGoAndBack.auto index 986c90a..1ad38ed 100644 --- a/src/main/deploy/pathplanner/autos/LineGoAndBack.auto +++ b/src/main/deploy/pathplanner/autos/LineGoAndBack.auto @@ -7,7 +7,7 @@ { "type": "path", "data": { - "pathName": "Line" + "pathName": "Climb Path step2" } }, { diff --git a/src/main/deploy/pathplanner/autos/New Auto.auto b/src/main/deploy/pathplanner/autos/New Auto.auto deleted file mode 100644 index 440a1ea..0000000 --- a/src/main/deploy/pathplanner/autos/New Auto.auto +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "2025.0", - "command": { - "type": "sequential", - "data": { - "commands": [] - } - }, - "resetOdom": true, - "folder": null, - "choreoAuto": false -} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/Climb Path step1.path b/src/main/deploy/pathplanner/paths/Climb Path step1.path new file mode 100644 index 0000000..f997ea9 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/Climb Path step1.path @@ -0,0 +1,70 @@ +{ + "version": "2025.0", + "waypoints": [ + { + "anchor": { + "x": 13.59, + "y": 4.12 + }, + "prevControl": null, + "nextControl": { + "x": 14.266378040870812, + "y": 3.6432882001482505 + }, + "isLocked": true, + "linkedName": null + }, + { + "anchor": { + "x": 14.567, + "y": 3.3650694444444444 + }, + "prevControl": { + "x": 14.336543591648573, + "y": 3.4619706510920394 + }, + "nextControl": { + "x": 14.797456408351428, + "y": 3.2681682377968495 + }, + "isLocked": true, + "linkedName": null + }, + { + "anchor": { + "x": 15.9, + "y": 3.365 + }, + "prevControl": { + "x": 15.652649792454762, + "y": 3.401302545741686 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "pointTowardsZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 1.5, + "maxAcceleration": 3.0, + "maxAngularVelocity": 360.0, + "maxAngularAcceleration": 720.0, + "nominalVoltage": 12.0, + "unlimited": false + }, + "goalEndState": { + "velocity": 0, + "rotation": 180.0 + }, + "reversed": false, + "folder": null, + "idealStartingState": { + "velocity": 0, + "rotation": 180.0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/Climb Path step2.path b/src/main/deploy/pathplanner/paths/Climb Path step2.path new file mode 100644 index 0000000..fb829dd --- /dev/null +++ b/src/main/deploy/pathplanner/paths/Climb Path step2.path @@ -0,0 +1,54 @@ +{ + "version": "2025.0", + "waypoints": [ + { + "anchor": { + "x": 15.9, + "y": 3.365 + }, + "prevControl": null, + "nextControl": { + "x": 15.650000000000002, + "y": 3.365 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 15.467, + "y": 3.365 + }, + "prevControl": { + "x": 15.935706120733446, + "y": 3.365 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "pointTowardsZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 0.5, + "maxAcceleration": 1.0, + "maxAngularVelocity": 360.0, + "maxAngularAcceleration": 720.0, + "nominalVoltage": 12.0, + "unlimited": false + }, + "goalEndState": { + "velocity": 0, + "rotation": 180.0 + }, + "reversed": false, + "folder": null, + "idealStartingState": { + "velocity": 0, + "rotation": 180.0 + }, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/depotIntakePath.path b/src/main/deploy/pathplanner/paths/depotIntakePath.path new file mode 100644 index 0000000..9759181 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/depotIntakePath.path @@ -0,0 +1,54 @@ +{ + "version": "2025.0", + "waypoints": [ + { + "anchor": { + "x": 15.4, + "y": 2.1 + }, + "prevControl": null, + "nextControl": { + "x": 15.65, + "y": 2.1 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 16.0, + "y": 2.1 + }, + "prevControl": { + "x": 15.75, + "y": 2.1 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "pointTowardsZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 0.5, + "maxAcceleration": 3.0, + "maxAngularVelocity": 360.0, + "maxAngularAcceleration": 720.0, + "nominalVoltage": 12.0, + "unlimited": false + }, + "goalEndState": { + "velocity": 0, + "rotation": 180.0 + }, + "reversed": false, + "folder": null, + "idealStartingState": { + "velocity": 0, + "rotation": 180.0 + }, + "useDefaultConstraints": false +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/Line.path b/src/main/deploy/pathplanner/paths/depotShootPath.path similarity index 79% rename from src/main/deploy/pathplanner/paths/Line.path rename to src/main/deploy/pathplanner/paths/depotShootPath.path index 8726d5c..5e81694 100644 --- a/src/main/deploy/pathplanner/paths/Line.path +++ b/src/main/deploy/pathplanner/paths/depotShootPath.path @@ -3,25 +3,25 @@ "waypoints": [ { "anchor": { - "x": 14.314, - "y": 4.15 + "x": 15.7, + "y": 2.1 }, "prevControl": null, "nextControl": { - "x": 14.299415121255347, - "y": 4.61077032810271 + "x": 16.145956799790877, + "y": 1.9416406158462824 }, "isLocked": false, "linkedName": null }, { "anchor": { - "x": 14.314, - "y": 6.668017118402283 + "x": 13.5, + "y": 4.0 }, "prevControl": { - "x": 14.247660485021397, - "y": 6.305734664764623 + "x": 13.28182215800934, + "y": 4.126069541450674 }, "nextControl": null, "isLocked": false, diff --git a/src/main/deploy/pathplanner/paths/redBackAndShoot.path b/src/main/deploy/pathplanner/paths/redBackAndShoot.path new file mode 100644 index 0000000..504e0c2 --- /dev/null +++ b/src/main/deploy/pathplanner/paths/redBackAndShoot.path @@ -0,0 +1,54 @@ +{ + "version": "2025.0", + "waypoints": [ + { + "anchor": { + "x": 13.01022182786158, + "y": 4.119503105590061 + }, + "prevControl": null, + "nextControl": { + "x": 13.865906250551847, + "y": 4.119503105590061 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 13.59, + "y": 4.12 + }, + "prevControl": { + "x": 13.321071353115471, + "y": 4.12 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "pointTowardsZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 1.5, + "maxAcceleration": 3.0, + "maxAngularVelocity": 360.0, + "maxAngularAcceleration": 720.0, + "nominalVoltage": 12.0, + "unlimited": false + }, + "goalEndState": { + "velocity": 0, + "rotation": 180.0 + }, + "reversed": false, + "folder": null, + "idealStartingState": { + "velocity": 0, + "rotation": 180.0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/deploy/pathplanner/paths/redDepotPath.path b/src/main/deploy/pathplanner/paths/redDepotPath.path new file mode 100644 index 0000000..7da48cb --- /dev/null +++ b/src/main/deploy/pathplanner/paths/redDepotPath.path @@ -0,0 +1,54 @@ +{ + "version": "2025.0", + "waypoints": [ + { + "anchor": { + "x": 13.0, + "y": 4.0 + }, + "prevControl": null, + "nextControl": { + "x": 14.000000000000002, + "y": 4.0 + }, + "isLocked": false, + "linkedName": null + }, + { + "anchor": { + "x": 15.400452528841061, + "y": 2.1 + }, + "prevControl": { + "x": 14.400452528841061, + "y": 2.1 + }, + "nextControl": null, + "isLocked": false, + "linkedName": null + } + ], + "rotationTargets": [], + "constraintZones": [], + "pointTowardsZones": [], + "eventMarkers": [], + "globalConstraints": { + "maxVelocity": 1.5, + "maxAcceleration": 3.0, + "maxAngularVelocity": 360.0, + "maxAngularAcceleration": 720.0, + "nominalVoltage": 12.0, + "unlimited": false + }, + "goalEndState": { + "velocity": 0, + "rotation": 180.0 + }, + "reversed": false, + "folder": null, + "idealStartingState": { + "velocity": 0, + "rotation": 180.0 + }, + "useDefaultConstraints": true +} \ No newline at end of file diff --git a/src/main/java/frc/robot/controls/Autocommand.java b/src/main/java/frc/robot/controls/Autocommand.java index 769702e..e004191 100644 --- a/src/main/java/frc/robot/controls/Autocommand.java +++ b/src/main/java/frc/robot/controls/Autocommand.java @@ -31,6 +31,7 @@ import frc.robot.Constants.RobotStatus; NamedCommands.registerCommand("climb_up", climb_up(climber)); NamedCommands.registerCommand("climb_down", climb_down(climber)); NamedCommands.registerCommand("start_intake", start_intake(intaker)); + NamedCommands.registerCommand("start_intake_timelimit", start_intake_timelimit(intaker)); NamedCommands.registerCommand("stop_intake", stop_intake(intaker)); NamedCommands.registerCommand("intaker_down", intaker_down(intaker)); NamedCommands.registerCommand("intaker_up", intaker_up(intaker)); @@ -55,26 +56,33 @@ import frc.robot.Constants.RobotStatus; }, climber)); } public static Command start_intake(IntakerSubsystem intaker) { - return new InstantCommand(() -> { + return new RunCommand(() -> { intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球 }, intaker); } + public static Command start_intake_timelimit(IntakerSubsystem intaker) { + return new RunCommand(() -> { + intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 吸球机构下降 + }, intaker).withTimeout(3).andThen(new InstantCommand(() -> { + intaker.setIntakerGetterSpeed(0); // 停止旋转 + }, intaker)); + } public static Command stop_intake(IntakerSubsystem intaker) { return new InstantCommand(() -> { intaker.setIntakerGetterSpeed(0); // 停止吸球 }, intaker); } public static Command intaker_down(IntakerSubsystem intaker) { - return new InstantCommand(() -> { + return new RunCommand(() -> { intaker.IntakerDownNonStop(); // 吸球机构下降 - }, intaker).withTimeout(0.5).andThen(new InstantCommand(() -> { - intaker.stopIntakerotater();; // 停止旋转 + }, intaker).withTimeout(1.0).andThen(new InstantCommand(() -> { + intaker.stopIntakerotater(); // 停止旋转 }, intaker)); } public static Command intaker_up(IntakerSubsystem intaker) { return new InstantCommand(() -> { intaker.IntakerUpNonStop(); // 吸球机构上升 - }, intaker).withTimeout(0.5).andThen(new InstantCommand(() -> { + }, intaker).withTimeout(0.8).andThen(new InstantCommand(() -> { intaker.stopIntakerotater();; // 停止旋转 }, intaker)); } @@ -95,14 +103,26 @@ import frc.robot.Constants.RobotStatus; } public static Command shoot(ShooterSubsystem shooter) { - return new InstantCommand(() -> { - shooter.setFlywheelSpeedByRPS(60); - shooter.setBackboardPosition(200); // 设置自动射击转速 - }, shooter).withTimeout(1.0).andThen(new InstantCommand(() -> { + return new RunCommand(() -> { + shooter.setFlywheelSpeedByRPS(64); + shooter.setBackboardPosition(175); // 设置自动射击转速 + if(shooter.isBackboardAtTarget()){ + shooter.backboardMotor.set(0); + }else{ + shooter.outputBackboard(); + } + }, shooter).withTimeout(1.0).andThen(new RunCommand(() -> { + shooter.setFlywheelSpeedByRPS(64); + shooter.setBackboardPosition(175); + if(shooter.isBackboardAtTarget()){ + shooter.backboardMotor.set(0); + }else{ + shooter.outputBackboard(); + } shooter.setConveyorSpeedByRPS(25); - }, shooter).withTimeout(5.0).andThen(new InstantCommand(() -> { + }, shooter).withTimeout(3.0).andThen(new InstantCommand(() -> { shooter.setFlywheelSpeedByRPS(0); // 停止射击 - shooter.setBackboardPosition(0); // 恢复背板位置 + //shooter.setBackboardPosition(0); // 恢复背板位置 shooter.setConveyorSpeedByRPS(0); // 停止输送 }, shooter))); diff --git a/src/main/java/frc/robot/controls/DriveControls.java b/src/main/java/frc/robot/controls/DriveControls.java index a9cb59b..7676dde 100644 --- a/src/main/java/frc/robot/controls/DriveControls.java +++ b/src/main/java/frc/robot/controls/DriveControls.java @@ -42,6 +42,8 @@ public class DriveControls { // 加速模式比例(按住 RB) private double boostDriveScale = 1.0; private double boostTurnScale = 1.0; + //autoaim模式 + private double slowDriveScale =0.1; private boolean boostEnabled = false; @@ -142,6 +144,8 @@ public class DriveControls { LimelightSupplier.setPipeline(Constants.Limelight.locatePipelineIndex); vomega = calculateRotationSpeedFromRotationAngle(distanceAndRotation[1]); autoControlNetworkTable.getEntry("autoRotationRate").setDouble(vomega); + vx = -driver.getLeftY() * maxSpeed * slowDriveScale; + vy = -driver.getLeftX() * maxSpeed * slowDriveScale; break; case AllTelop: autoControlNetworkTable.getEntry("autoRotationRate").setDouble(Double.NaN);