自动2.0

This commit is contained in:
OnDYCLaptop
2026-03-09 09:47:22 +08:00
parent 196b3ce77f
commit 8b2df6ce7c
15 changed files with 573 additions and 33 deletions
+92
View File
@@ -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
}
]
}
@@ -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
}
@@ -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
}
@@ -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
}
+1 -1
View File
@@ -7,7 +7,7 @@
{ {
"type": "path", "type": "path",
"data": { "data": {
"pathName": "Line" "pathName": "Climb Path step2"
} }
} }
] ]
@@ -7,7 +7,7 @@
{ {
"type": "path", "type": "path",
"data": { "data": {
"pathName": "Line" "pathName": "Climb Path step2"
} }
}, },
{ {
@@ -1,12 +0,0 @@
{
"version": "2025.0",
"command": {
"type": "sequential",
"data": {
"commands": []
}
},
"resetOdom": true,
"folder": null,
"choreoAuto": false
}
@@ -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
}
@@ -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
}
@@ -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
}
@@ -3,25 +3,25 @@
"waypoints": [ "waypoints": [
{ {
"anchor": { "anchor": {
"x": 14.314, "x": 15.7,
"y": 4.15 "y": 2.1
}, },
"prevControl": null, "prevControl": null,
"nextControl": { "nextControl": {
"x": 14.299415121255347, "x": 16.145956799790877,
"y": 4.61077032810271 "y": 1.9416406158462824
}, },
"isLocked": false, "isLocked": false,
"linkedName": null "linkedName": null
}, },
{ {
"anchor": { "anchor": {
"x": 14.314, "x": 13.5,
"y": 6.668017118402283 "y": 4.0
}, },
"prevControl": { "prevControl": {
"x": 14.247660485021397, "x": 13.28182215800934,
"y": 6.305734664764623 "y": 4.126069541450674
}, },
"nextControl": null, "nextControl": null,
"isLocked": false, "isLocked": false,
@@ -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
}
@@ -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
}
@@ -31,6 +31,7 @@ import frc.robot.Constants.RobotStatus;
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("stop_intake", stop_intake(intaker)); NamedCommands.registerCommand("stop_intake", stop_intake(intaker));
NamedCommands.registerCommand("intaker_down", intaker_down(intaker)); NamedCommands.registerCommand("intaker_down", intaker_down(intaker));
NamedCommands.registerCommand("intaker_up", intaker_up(intaker)); NamedCommands.registerCommand("intaker_up", intaker_up(intaker));
@@ -55,26 +56,33 @@ import frc.robot.Constants.RobotStatus;
}, climber)); }, climber));
} }
public static Command start_intake(IntakerSubsystem intaker) { public static Command start_intake(IntakerSubsystem intaker) {
return new InstantCommand(() -> { return new RunCommand(() -> {
intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球 intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球
}, intaker); }, 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) { public static Command stop_intake(IntakerSubsystem intaker) {
return new InstantCommand(() -> { return new InstantCommand(() -> {
intaker.setIntakerGetterSpeed(0); // 停止吸球 intaker.setIntakerGetterSpeed(0); // 停止吸球
}, intaker); }, intaker);
} }
public static Command intaker_down(IntakerSubsystem intaker) { public static Command intaker_down(IntakerSubsystem intaker) {
return new InstantCommand(() -> { return new RunCommand(() -> {
intaker.IntakerDownNonStop(); // 吸球机构下降 intaker.IntakerDownNonStop(); // 吸球机构下降
}, intaker).withTimeout(0.5).andThen(new InstantCommand(() -> { }, intaker).withTimeout(1.0).andThen(new InstantCommand(() -> {
intaker.stopIntakerotater();; // 停止旋转 intaker.stopIntakerotater(); // 停止旋转
}, intaker)); }, intaker));
} }
public static Command intaker_up(IntakerSubsystem intaker) { public static Command intaker_up(IntakerSubsystem intaker) {
return new InstantCommand(() -> { return new InstantCommand(() -> {
intaker.IntakerUpNonStop(); // 吸球机构上升 intaker.IntakerUpNonStop(); // 吸球机构上升
}, intaker).withTimeout(0.5).andThen(new InstantCommand(() -> { }, intaker).withTimeout(0.8).andThen(new InstantCommand(() -> {
intaker.stopIntakerotater();; // 停止旋转 intaker.stopIntakerotater();; // 停止旋转
}, intaker)); }, intaker));
} }
@@ -95,14 +103,26 @@ import frc.robot.Constants.RobotStatus;
} }
public static Command shoot(ShooterSubsystem shooter) { public static Command shoot(ShooterSubsystem shooter) {
return new InstantCommand(() -> { return new RunCommand(() -> {
shooter.setFlywheelSpeedByRPS(60); shooter.setFlywheelSpeedByRPS(64);
shooter.setBackboardPosition(200); // 设置自动射击转速 shooter.setBackboardPosition(175); // 设置自动射击转速
}, shooter).withTimeout(1.0).andThen(new InstantCommand(() -> { 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.setConveyorSpeedByRPS(25);
}, shooter).withTimeout(5.0).andThen(new InstantCommand(() -> { }, shooter).withTimeout(3.0).andThen(new InstantCommand(() -> {
shooter.setFlywheelSpeedByRPS(0); // 停止射击 shooter.setFlywheelSpeedByRPS(0); // 停止射击
shooter.setBackboardPosition(0); // 恢复背板位置 //shooter.setBackboardPosition(0); // 恢复背板位置
shooter.setConveyorSpeedByRPS(0); // 停止输送 shooter.setConveyorSpeedByRPS(0); // 停止输送
}, shooter))); }, shooter)));
@@ -42,6 +42,8 @@ public class DriveControls {
// 加速模式比例(按住 RB) // 加速模式比例(按住 RB)
private double boostDriveScale = 1.0; private double boostDriveScale = 1.0;
private double boostTurnScale = 1.0; private double boostTurnScale = 1.0;
//autoaim模式
private double slowDriveScale =0.1;
private boolean boostEnabled = false; private boolean boostEnabled = false;
@@ -142,6 +144,8 @@ public class DriveControls {
LimelightSupplier.setPipeline(Constants.Limelight.locatePipelineIndex); LimelightSupplier.setPipeline(Constants.Limelight.locatePipelineIndex);
vomega = calculateRotationSpeedFromRotationAngle(distanceAndRotation[1]); vomega = calculateRotationSpeedFromRotationAngle(distanceAndRotation[1]);
autoControlNetworkTable.getEntry("autoRotationRate").setDouble(vomega); autoControlNetworkTable.getEntry("autoRotationRate").setDouble(vomega);
vx = -driver.getLeftY() * maxSpeed * slowDriveScale;
vy = -driver.getLeftX() * maxSpeed * slowDriveScale;
break; break;
case AllTelop: case AllTelop:
autoControlNetworkTable.getEntry("autoRotationRate").setDouble(Double.NaN); autoControlNetworkTable.getEntry("autoRotationRate").setDouble(Double.NaN);