Skip to content

Commit 8f516bc

Browse files
committed
drive tuning
1 parent 732740f commit 8f516bc

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

src/main/java/frc/robot/constants/AlgaeConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class AlgaeConstants {
3232
public static final double kIntakingSpeed = -1;
3333

3434
public static final double kHasAlgaeVelThreshold = 10;
35-
public static final double kHasAlgaeCounts = 3;
35+
public static final double kHasAlgaeCounts = 2;
3636

3737
// Example Talon FX Config
3838
public static TalonFXSConfiguration getFXConfig() {

src/main/java/frc/robot/constants/DriveConstants.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public static TalonFXConfiguration getDriveTalonConfig() {
166166

167167
CurrentLimitsConfigs currentConfig = new CurrentLimitsConfigs();
168168
currentConfig.SupplyCurrentLimit = 60;
169-
169+
currentConfig.SupplyCurrentLowerLimit = 60;
170+
currentConfig.SupplyCurrentLowerTime = 1.0;
170171
currentConfig.StatorCurrentLimit = 140;
171172

172173
currentConfig.SupplyCurrentLimitEnable = true;
@@ -175,10 +176,13 @@ public static TalonFXConfiguration getDriveTalonConfig() {
175176
driveConfig.CurrentLimits = currentConfig;
176177

177178
Slot0Configs slot0Config = new Slot0Configs();
178-
slot0Config.kP = 0.5; // 0.16 using phoenix 6 migrate
179-
slot0Config.kI = 0.5; // 0.0002 using phoenix 6 migrate
179+
slot0Config.kP = 0.2;
180+
slot0Config.kI = 0.0;
180181
slot0Config.kD = 0.0;
181-
slot0Config.kV = 0.12; // 0.047 using phoenix 6 migrate
182+
slot0Config.kV = 0.117;
183+
slot0Config.kS = 0.0;
184+
slot0Config.kA = 0.0;
185+
slot0Config.kG = 0.0;
182186
driveConfig.Slot0 = slot0Config;
183187

184188
MotorOutputConfigs motorConfigs = new MotorOutputConfigs();

src/main/java/frc/robot/constants/TagServoingConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class TagServoingConstants {
5454
public static final double kAlgaeStopXDriveRadius =
5555
kAlgaeInitialDriveRadius; // Should be closer to reef than target pose
5656
public static final double kCoralDriveCloseEnough = 0.1;
57-
public static final double kAlgaeDriveCloseEnough = 0.2;
57+
public static final double kAlgaeDriveCloseEnough = 0.1;
5858
public static final double kMinVelX = 0.85;
5959

6060
// Reef

src/main/java/frc/robot/subsystems/drive/Swerve.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,7 @@ private ChassisSpeeds getRobotRelSpeed() {
161161
return kinematics.toChassisSpeeds(swerveModuleStates);
162162
}
163163

164-
private ChassisSpeeds getFieldRelSpeed() {
165-
// SwerveDriveKinematics kinematics = swerveDrive.getKinematics();
166-
// SwerveModule[] swerveModules = swerveDrive.getSwerveModules();
167-
SwerveModuleState[] swerveModuleStates = new SwerveModuleState[4];
168-
for (int i = 0; i < 4; ++i) {
169-
swerveModuleStates[i] = swerveModules[i].getState();
170-
}
171-
ChassisSpeeds roboRelSpeed = kinematics.toChassisSpeeds(swerveModuleStates);
172-
164+
private ChassisSpeeds getFieldRelSpeed(ChassisSpeeds roboRelSpeed) {
173165
Rotation2d heading = swerveDrive.getHeading().unaryMinus();
174166
fieldX =
175167
roboRelSpeed.vxMetersPerSecond * heading.getCos()
@@ -268,7 +260,8 @@ public void updateInputs(SwerveIOInputs inputs) {
268260
inputs.azimuthVels[i] = azimuths[i].getSelectedSensorVelocity();
269261
inputs.azimuthCurrent[i] = azimuths[i].getSupplyCurrent();
270262
}
271-
inputs.fieldRelSpeed = getFieldRelSpeed();
263+
inputs.robotRelSpeed = getRobotRelSpeed();
264+
inputs.fieldRelSpeed = getFieldRelSpeed(inputs.robotRelSpeed);
272265
inputs.fieldY = fieldY;
273266
inputs.fieldX = fieldX;
274267
}

src/main/java/frc/robot/subsystems/drive/SwerveIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static class SwerveIOInputs {
3535
public double pigeonTemp = 0;
3636
public double fieldX = 0;
3737
public double fieldY = 0;
38+
public ChassisSpeeds robotRelSpeed = new ChassisSpeeds();
3839
public ChassisSpeeds fieldRelSpeed = new ChassisSpeeds();
3940
public double[] azimuthVels = {0, 0, 0, 0};
4041
public double[] azimuthCurrent = {0, 0, 0, 0};

src/main/java/frc/robot/subsystems/tagAlign/TagAlignSubsystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public TagAlignSubsystem(DriveSubsystem driveSubsystem, VisionSubsystem visionSu
6262
new ProfiledPIDController(0.0017, 0, 0, TagServoingConstants.alignXConstraints); // 0.0015
6363
this.alignY = new ProfiledPIDController(0.00195, 0, 0, TagServoingConstants.alignYConstraints);
6464
this.alignOmega =
65-
new ProfiledPIDController(6, 0, 0, TagServoingConstants.alignOmegaConstraints);
65+
new ProfiledPIDController(5.5, 0, 0, TagServoingConstants.alignOmegaConstraints);
6666
this.alignOmega.enableContinuousInput(Math.toRadians(-180), Math.toRadians(180));
6767

6868
Logger.recordOutput("TagAlignSubsystem/TargetDiag", -1);
@@ -357,8 +357,8 @@ public void periodic() {
357357
double vX = -alignX.calculate(goalTargetDiag - diag, 0);
358358
double vY = -alignY.calculate(TagServoingConstants.kHorizontalTarget - center.x(), 0);
359359

360-
Logger.recordOutput("TagAlignSubsystem/Tag Align X Error", alignX.getPositionError());
361-
Logger.recordOutput("TagAlignSubsystem/Tag Align Y Error", alignY.getPositionError());
360+
Logger.recordOutput("TagAlignSubsystem/Diag Error", alignX.getPositionError());
361+
Logger.recordOutput("TagAlignSubsystem/Horizontal Error", alignY.getPositionError());
362362
Logger.recordOutput(
363363
"TagAlignSubsystem/Last result delay",
364364
(RobotController.getFPGATime() - result.getTimeStamp()) / 1000);

0 commit comments

Comments
 (0)