autocommand

This commit is contained in:
OnDYCLaptop
2026-03-03 14:40:21 +08:00
parent 7606402980
commit cae3810ef5
4 changed files with 28 additions and 3 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ public final class Constants {
.withKV(0.00).withKA(0.00).withKS(0.00); .withKV(0.00).withKA(0.00).withKS(0.00);
//如果 rotater 受重力影响明显,可能需要用 withKG/withGravityType/withGravityArmPositionOffset(看机构形式)(这句fromAI) //如果 rotater 受重力影响明显,可能需要用 withKG/withGravityType/withGravityArmPositionOffset(看机构形式)(这句fromAI)
public static final double IntakeGetterSpeed = 0.0; public static final double IntakeGetterSpeedforAuto = 0.0;
// 单位RPS // 单位RPS
public static final double positionToleranceRotations = 0.00; public static final double positionToleranceRotations = 0.00;
//rotater容差 //rotater容差
@@ -17,6 +17,7 @@ import frc.robot.Constants;
import frc.robot.Constants.RobotStatus; import frc.robot.Constants.RobotStatus;
public class Autocommand extends SequentialCommandGroup{ public class Autocommand extends SequentialCommandGroup{
public static Command climb_up(ClimberSubsystem climber) { public static Command climb_up(ClimberSubsystem climber) {
return new RunCommand(() -> { return new RunCommand(() -> {
climber.climbUp(); // 控制爬升器上升 climber.climbUp(); // 控制爬升器上升
@@ -33,6 +34,31 @@ import frc.robot.Constants.RobotStatus;
climber.holdPosition(); // 停止并锁定当前爬升器位置 climber.holdPosition(); // 停止并锁定当前爬升器位置
}, climber)); }, climber));
} }
public static Command start_intake(IntakerSubsystem intaker) {
return new InstantCommand(() -> {
intaker.setIntakerGetterSpeed(Constants.Intaker.IntakeGetterSpeedforAuto); // 启动吸球
}, 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(() -> {
intaker.IntakerDownNonStop(); // 吸球机构下降
}, intaker).withTimeout(0.5).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.stopIntakerotater();; // 吸球机构保持当前位置
}, intaker));
}
} }
@@ -74,7 +74,7 @@ public class IntakerControls {
getterspeed = 0; getterspeed = 0;
} }
IntakerSubsystem.setIntakerGetterSpeed(getterspeed); IntakerSubsystem.setIntakerGetterSpeed(getterspeed);
if(controller.getLeftY() < -0.5){ if(controller.getLeftY() < -0.5){
IntakerSubsystem.IntakerDownNonStop(); IntakerSubsystem.IntakerDownNonStop();
} else if(controller.getLeftY() > 0.5){ } else if(controller.getLeftY() > 0.5){
@@ -67,7 +67,6 @@ public class ShooterControls {
} }
break; break;
case AutoAimming: case AutoAimming:
var x = shooterSubsystem.getDistance(); var x = shooterSubsystem.getDistance();
x = Math.max(1.2, Math.min(4.5, x)); x = Math.max(1.2, Math.min(4.5, x));
flywheelSpeed = 0.6956596811733782*x*x*x*x*x*x*x-14.164408860183267*x*x*x*x*x*x+119.7115375240918*x*x*x*x*x-543.0984876677477*x*x*x*x+1425.1928543240738*x*x*x-2156.199296490315*x*x+1736.568139600292*x-516.097598057351; flywheelSpeed = 0.6956596811733782*x*x*x*x*x*x*x-14.164408860183267*x*x*x*x*x*x+119.7115375240918*x*x*x*x*x-543.0984876677477*x*x*x*x+1425.1928543240738*x*x*x-2156.199296490315*x*x+1736.568139600292*x-516.097598057351;