添加intaker重力前馈(未启用)

This commit is contained in:
OnDYCLaptop
2026-03-03 14:18:44 +08:00
parent fd4fb39a50
commit 7606402980
4 changed files with 16 additions and 3 deletions
+1
View File
@@ -99,6 +99,7 @@ public final class Constants {
public static final double intakeRotaterUpLimit = 0.0; // rotator上限角度 public static final double intakeRotaterUpLimit = 0.0; // rotator上限角度
public static final double intakeRotaterDownLimit = 0.0; // rotator下限角度 public static final double intakeRotaterDownLimit = 0.0; // rotator下限角度
public static final double intakeRotaterVelocity = 10; // rotater的速度(如果你用速度控制的话) public static final double intakeRotaterVelocity = 10; // rotater的速度(如果你用速度控制的话)
public static final double IntakeRotaterGravityFF = 0.0; // 重力前馈增益(需要实测调整)
public static final Slot0Configs intakeGetterSlot0Configs = new Slot0Configs() public static final Slot0Configs intakeGetterSlot0Configs = new Slot0Configs()
.withKP(0.00).withKI(0.00).withKD(0.00) .withKP(0.00).withKI(0.00).withKD(0.00)
@@ -77,6 +77,7 @@ public class RobotContainer {
configueShooter(); configueShooter();
configueClimber(); configueClimber();
bingdingLED(); bingdingLED();
configueIntaker();
} }
/* ====================== */ /* ====================== */
@@ -13,7 +13,7 @@ public class IntakerControls {
private final IntakerSubsystem IntakerSubsystem; private final IntakerSubsystem IntakerSubsystem;
private final CommandXboxController controller; private final CommandXboxController controller;
private static final double ROTATER_STEP_PER_CYCLE = 0.00; //private static final double ROTATER_STEP_PER_CYCLE = 0.00;
public IntakerControls(IntakerSubsystem Intaker, CommandXboxController controller) { public IntakerControls(IntakerSubsystem Intaker, CommandXboxController controller) {
this.IntakerSubsystem = Intaker; this.IntakerSubsystem = Intaker;
@@ -4,6 +4,7 @@ import com.ctre.phoenix6.controls.PositionVoltage;
import com.ctre.phoenix6.controls.VelocityVoltage; import com.ctre.phoenix6.controls.VelocityVoltage;
import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.hardware.TalonFX;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants; import frc.robot.Constants;
@@ -18,6 +19,17 @@ public class IntakerSubsystem extends SubsystemBase{
private double intakeRotaterTargetPosition = 0.0; private double intakeRotaterTargetPosition = 0.0;
public double getGravityFFVolts(){
double intakerotaterPosition = getIntakerotaterPosition();
double gravityFFVolts = Constants.Intaker.IntakeRotaterGravityFF * intakerotaterPosition;
return gravityFFVolts;
}
public void setIntakerRotaterVelocityRps(double IntakeRotaterTargetVelocity) {
double gravityFeedforward = getGravityFFVolts();
intakerotater.setControl(velocityRequest.withVelocity(IntakeRotaterTargetVelocity).withFeedForward(gravityFeedforward));// 重力前馈);
}
public IntakerSubsystem() { public IntakerSubsystem() {
//初始化rotater&getter //初始化rotater&getter
intakegetter = new TalonFX(47); intakegetter = new TalonFX(47);
@@ -35,7 +47,6 @@ public class IntakerSubsystem extends SubsystemBase{
} }
intakeRotaterTargetPosition = targetPosition; intakeRotaterTargetPosition = targetPosition;
intakerotater.setControl(positionRequest.withPosition(targetPosition)); // 设置rotater位置(TalonFX 内部闭环 PID) intakerotater.setControl(positionRequest.withPosition(targetPosition)); // 设置rotater位置(TalonFX 内部闭环 PID)
} }