Skip to content

Commit 72cf615

Browse files
committed
constants tweaks
1 parent 84bb43c commit 72cf615

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

src/main/java/org/frc6423/frc2025/Constants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import edu.wpi.first.wpilibj.Alert.AlertType;
1414
import org.frc6423.frc2025.util.swerveUtil.ModuleConfig;
1515
import org.frc6423.frc2025.util.swerveUtil.ModuleConfig.moduleType;
16+
17+
import com.ctre.phoenix6.configs.TalonFXConfiguration;
18+
1619
import org.frc6423.frc2025.util.swerveUtil.SwerveConfig;
1720

1821
/** A class */
@@ -64,6 +67,10 @@ public static DeployMode getDeployMode() {
6467

6568
// * SUBSYSTEM CONSTANTS
6669
public class KDriveConstants {
70+
71+
private static final TalonFXConfiguration kPivotMotorConfig = new TalonFXConfiguration()
72+
.
73+
6774
// Swerve Configs
6875
public static final SwerveConfig kDevBotConfig =
6976
new SwerveConfig(

src/main/java/org/frc6423/frc2025/subsystems/swerve/module/ModuleIO.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ public class ModuleIOInputs {
5252
public default void stop() {
5353
setPivotVolts(0);
5454
setDriveVolts(0);
55-
};
56-
}
55+
}
56+
;
57+
}

src/main/java/org/frc6423/frc2025/subsystems/swerve/module/ModuleIOSim.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
import static org.frc6423.frc2025.Constants.KDriveConstants.*;
1010

11+
import com.ctre.phoenix6.controls.VelocityTorqueCurrentFOC;
12+
import com.ctre.phoenix6.controls.VoltageOut;
13+
import com.ctre.phoenix6.hardware.TalonFX;
14+
import com.ctre.phoenix6.sim.ChassisReference;
15+
import com.ctre.phoenix6.sim.TalonFXSimState;
1116
import edu.wpi.first.math.MathUtil;
1217
import edu.wpi.first.math.controller.PIDController;
1318
import edu.wpi.first.math.geometry.Rotation2d;
@@ -16,12 +21,6 @@
1621
import edu.wpi.first.wpilibj.simulation.DCMotorSim;
1722
import org.frc6423.frc2025.util.swerveUtil.ModuleConfig;
1823

19-
import com.ctre.phoenix6.controls.VelocityTorqueCurrentFOC;
20-
import com.ctre.phoenix6.controls.VoltageOut;
21-
import com.ctre.phoenix6.hardware.TalonFX;
22-
import com.ctre.phoenix6.sim.ChassisReference;
23-
import com.ctre.phoenix6.sim.TalonFXSimState;
24-
2524
public class ModuleIOSim implements ModuleIO {
2625
private final DCMotorSim m_pivotSim, m_driveSim;
2726
private final TalonFX m_driveMotor;
@@ -76,23 +75,21 @@ public void periodic() {
7675
driveSimState.Orientation = ChassisReference.Clockwise_Positive;
7776

7877
m_driveSim.setInput(driveSimState.getMotorVoltage());
79-
78+
8079
m_pivotSim.update(0.02);
8180
m_driveSim.update(0.02);
82-
driveSimState.setRotorVelocity(
83-
(m_driveSim.getAngularVelocityRPM() / 60) * kDriveReduction
84-
);
81+
driveSimState.setRotorVelocity((m_driveSim.getAngularVelocityRPM() / 60) * kDriveReduction);
8582
}
8683

8784
@Override
8885
public void setPivotVolts(double volts) {
89-
pivotAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0);
86+
pivotAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0);
9087
m_pivotSim.setInputVoltage(pivotAppliedVolts);
9188
}
9289

9390
@Override
9491
public void setDriveVolts(double volts) {
95-
m_driveMotor.setControl(m_driveVoltage.withOutput(volts).withEnableFOC(true));
92+
m_driveMotor.setControl(m_driveVoltage.withOutput(volts).withEnableFOC(true));
9693
}
9794

9895
@Override
@@ -104,7 +101,8 @@ public void setPivotAngle(Rotation2d angle) {
104101

105102
@Override
106103
public void setDriveVelocity(double velMetersPerSec, double ff) {
107-
m_driveMotor.setControl(m_driveVelocityControl.withVelocity(velMetersPerSec).withFeedForward(ff)); // !
104+
m_driveMotor.setControl(
105+
m_driveVelocityControl.withVelocity(velMetersPerSec).withFeedForward(ff)); // !
108106
}
109107

110108
@Override

src/main/java/org/frc6423/frc2025/util/swerveUtil/ModuleConfig.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
package org.frc6423.frc2025.util.swerveUtil;
88

9+
import com.ctre.phoenix6.configs.TalonFXConfiguration;
10+
911
import edu.wpi.first.math.geometry.Rotation2d;
1012

1113
public class ModuleConfig {
@@ -19,11 +21,35 @@ public class ModuleConfig {
1921
public Rotation2d kPivotOffset;
2022
public boolean kPivotInverted;
2123

24+
public TalonFXConfiguration kPivotConfig, kDriveConfig;
25+
2226
public static enum moduleType {
2327
SPARKMAX,
2428
TALONFX
2529
}
2630

31+
public ModuleConfig(
32+
int index,
33+
moduleType type,
34+
int pivotID,
35+
int driveID,
36+
int pivotABSID,
37+
Rotation2d pivotOffset,
38+
boolean pivotInverted,
39+
TalonFXConfiguration pivotConfig,
40+
TalonFXConfiguration driveConfig) {
41+
this.kIndex = index;
42+
this.kModuletype = type;
43+
this.kPivotID = pivotID;
44+
this.kDriveID = driveID;
45+
this.kPivotABSID = pivotABSID;
46+
this.kPivotOffset = pivotOffset;
47+
this.kPivotInverted = pivotInverted;
48+
49+
this.kPivotConfig = pivotConfig;
50+
this.kDriveConfig = driveConfig;
51+
}
52+
2753
public ModuleConfig(
2854
int index,
2955
moduleType type,

0 commit comments

Comments
 (0)