自动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
@@ -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",
"data": {
"pathName": "Line"
"pathName": "Climb Path step2"
}
}
]
@@ -7,7 +7,7 @@
{
"type": "path",
"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": [
{
"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,
@@ -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_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)));
@@ -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);