Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 16t adapter kit and FOC compatibility #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
id "edu.wpi.first.GradleRIO" version "2024.2.1"
}

java {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ public static final class driveRatios{
public static final double L2 = (6.75 / 1.0);
/** SDS MK4i - (6.12 : 1) */
public static final double L3 = (6.12 / 1.0);

/** SDS MK4i (with 16t adapter kit) - (7.13 : 1) */
// TODO: Could rename to L1_5
public static final double L1_16T = (7.13 / 1.0);
/** SDS MK4i (with 16t adapter kit) - (5.90 : 1) */
public static final double L2_16T = (5.90 / 1.0);
/** SDS MK4i (with 16t adapter kit) - (5.36 : 1) */
public static final double L3_16T = (5.36 / 1.0);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public final class Constants {

public static final class Swerve {
public static final int pigeonID = 1;
public static final boolean UseFOC = false; //CHANGE IF PRO LICENSED TALONS OR CANIVORE

public static final COTSTalonFXSwerveConstants chosenModule = //TODO: This must be tuned to specific robot
COTSTalonFXSwerveConstants.SDS.MK4i.Falcon500(COTSTalonFXSwerveConstants.SDS.MK4i.driveRatios.L2);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/SwerveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ public void setDesiredState(SwerveModuleState desiredState, boolean isOpenLoop){
private void setSpeed(SwerveModuleState desiredState, boolean isOpenLoop){
if(isOpenLoop){
driveDutyCycle.Output = desiredState.speedMetersPerSecond / Constants.Swerve.maxSpeed;
driveDutyCycle.EnableFOC = Constants.Swerve.UseFOC;
mDriveMotor.setControl(driveDutyCycle);
}
else {
driveVelocity.Velocity = Conversions.MPSToRPS(desiredState.speedMetersPerSecond, Constants.Swerve.wheelCircumference);
driveVelocity.FeedForward = driveFeedForward.calculate(desiredState.speedMetersPerSecond);
driveVelocity.EnableFOC = Constants.Swerve.UseFOC;
mDriveMotor.setControl(driveVelocity);
}
}
Expand Down