-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCTREConfigs.java
More file actions
61 lines (48 loc) · 3.22 KB
/
CTREConfigs.java
File metadata and controls
61 lines (48 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package frc.robot;
import com.ctre.phoenix6.configs.CANcoderConfiguration;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
public final class CTREConfigs {
public TalonFXConfiguration swerveAngleFXConfig = new TalonFXConfiguration();
public TalonFXConfiguration swerveDriveFXConfig = new TalonFXConfiguration();
public CANcoderConfiguration swerveCANcoderConfig = new CANcoderConfiguration();
public CTREConfigs() {
/** Swerve CANCoder Configuration */
swerveCANcoderConfig.MagnetSensor.SensorDirection = Constants.Swerve.cancoderInvert;
/** Swerve Angle Motor Configurations */
/* Motor Inverts and Neutral Mode */
swerveAngleFXConfig.MotorOutput.Inverted = Constants.Swerve.angleMotorInvert;
swerveAngleFXConfig.MotorOutput.NeutralMode = Constants.Swerve.angleNeutralMode;
/* Gear Ratio and Wrapping Config */
swerveAngleFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.angleGearRatio;
swerveAngleFXConfig.ClosedLoopGeneral.ContinuousWrap = true;
/* Current Limiting */
swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.angleEnableCurrentLimit;
swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.angleCurrentLimit;
//swerveAngleFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.angleCurrentThreshold;
//swerveAngleFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.angleCurrentThresholdTime;
/* PID Config */
swerveAngleFXConfig.Slot0.kP = Constants.Swerve.angleKP;
swerveAngleFXConfig.Slot0.kI = Constants.Swerve.angleKI;
swerveAngleFXConfig.Slot0.kD = Constants.Swerve.angleKD;
/** Swerve Drive Motor Configuration */
/* Motor Inverts and Neutral Mode */
swerveDriveFXConfig.MotorOutput.Inverted = Constants.Swerve.driveMotorInvert;
swerveDriveFXConfig.MotorOutput.NeutralMode = Constants.Swerve.driveNeutralMode;
/* Gear Ratio Config */
swerveDriveFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.driveGearRatio;
/* Current Limiting */
swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.driveEnableCurrentLimit;
swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.driveCurrentLimit;
//swerveDriveFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.driveCurrentThreshold;
//swerveDriveFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.driveCurrentThresholdTime;
/* PID Config */
swerveDriveFXConfig.Slot0.kP = Constants.Swerve.driveKP;
swerveDriveFXConfig.Slot0.kI = Constants.Swerve.driveKI;
swerveDriveFXConfig.Slot0.kD = Constants.Swerve.driveKD;
/* Open and Closed Loop Ramping */
swerveDriveFXConfig.OpenLoopRamps.DutyCycleOpenLoopRampPeriod = Constants.Swerve.openLoopRamp;
swerveDriveFXConfig.OpenLoopRamps.VoltageOpenLoopRampPeriod = Constants.Swerve.openLoopRamp;
swerveDriveFXConfig.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp;
swerveDriveFXConfig.ClosedLoopRamps.VoltageClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp;
}
}