Skip to content

Commit

Permalink
Add Kraken constants (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ACat701 authored Feb 3, 2024
1 parent a92d3e9 commit 40b971d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
* as well as a constructor for custom constants.
* </p>
* <p>
* Currently, there are presets for all MK4I Falcon 500 modules, with and
* without FOC. Values are taken directly from their website.
* Values are taken directly from their website.
* (https://www.swervedrivespecialties.com/products/mk4i-swerve-module)
* </p>
*/
Expand Down Expand Up @@ -45,42 +44,91 @@ public SN_SwerveConstants(double steerGearRatio, double wheelCircumference, doub
this.driveGearRatio = driveGearRatio;
this.maxSpeedMeters = maxSpeedMeters;
}
public static class MK4I {
/**
* Constants for modules that have a Kraken as the drive motor (the steer motor
* type doesn't matter here)
*/
public static class KRAKEN {
/**
* Preset Constants for a MK4I with L1 gearing and a Kraken Drive motor
*/
public static final SN_SwerveConstants L1 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
8.14, Units.feetToMeters(12.9));

/**
* Preset Constants for a MK4I with L1 gearing and Falcon 500 Motors
*/
public static final SN_SwerveConstants MK4I_L1 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE, 8.14,
Units.feetToMeters(13.7));
/**
* Preset Constants for a MK4I with L2 gearing and a Kraken Drive motor
*/
public static final SN_SwerveConstants L2 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.75, Units.feetToMeters(15.5));

/**
* Preset Constants for a MK4I with L2 gearing and Falcon 500 Motors
*/
public static final SN_SwerveConstants MK4I_L2 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE, 6.75,
Units.feetToMeters(16.5));
/**
* Preset Constants for a MK4I with L3 gearing and a Kraken Drive motor
*/
public static final SN_SwerveConstants L3 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.12, Units.feetToMeters(17.1));

/**
* Preset Constants for a MK4I with L3 gearing and Falcon 500 Motors
*/
public static final SN_SwerveConstants MK4I_L3 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE, 6.12,
Units.feetToMeters(18.2));
/**
* Preset Constants for a MK4I with L1 gearing, a Kraken Drive motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L1_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 8.14, Units.feetToMeters(12.4));
/**
* Preset Constants for a MK4I with L2 gearing, a Kraken Drive motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L2_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 6.75, Units.feetToMeters(15.0));
/**
* Preset Constants for a MK4I with L3 gearing, a Kraken Drive motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L3_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 6.12, Units.feetToMeters(16.5));
}

/**
* Preset Constants for a MK4I with L1 gearing, Falcon 500 Motors, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants MK4I_L1_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
8.14, Units.feetToMeters(13.0));
/**
* Preset Constants for a MK4I with L2 gearing, Falcon 500 Motors, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants MK4I_L2_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.75, Units.feetToMeters(15.7));
/**
* Preset Constants for a MK4I with L3 gearing, Falcon 500 Motors, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants MK4I_L3_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.12, Units.feetToMeters(17.3));
/**
* Constants for modules that have a Falcon as the drive motor (the steer motor
* type doesn't matter here)
*/
public static class FALCON {
/**
* Preset Constants for a MK4I with L1 gearing and a Falcon 500 Motor
*/
public static final SN_SwerveConstants L1 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
8.14, Units.feetToMeters(13.7));

/**
* Preset Constants for a MK4I with L2 gearing and a Falcon 500 Motor
*/
public static final SN_SwerveConstants L2 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.75, Units.feetToMeters(16.5));

/**
* Preset Constants for a MK4I with L3 gearing and a Falcon 500 Motor
*/
public static final SN_SwerveConstants L3 = new SN_SwerveConstants(STEER_GEAR_RATIO, WHEEL_CIRCUMFERENCE,
6.12, Units.feetToMeters(18.2));

/**
* Preset Constants for a MK4I with L1 gearing, a Falcon 500 Motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L1_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 8.14, Units.feetToMeters(13.0));
/**
* Preset Constants for a MK4I with L2 gearing, a Falcon 500 Motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L2_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 6.75, Units.feetToMeters(15.7));
/**
* Preset Constants for a MK4I with L3 gearing, a Falcon 500 Motor, and FOC
* (Field Oriented Control, a Phoenix Pro Feature) enabled
*/
public static final SN_SwerveConstants L3_FOC = new SN_SwerveConstants(STEER_GEAR_RATIO,
WHEEL_CIRCUMFERENCE, 6.12, Units.feetToMeters(17.3));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public class SN_SwerveModule extends SubsystemBase {

// -*- Static Physical Constants -*-
// These default to L2s, but should be overridden
public static double driveGearRatio = SN_SwerveConstants.MK4I_L2.driveGearRatio;
public static double steerGearRatio = SN_SwerveConstants.MK4I_L2.steerGearRatio;
public static double wheelCircumference = SN_SwerveConstants.MK4I_L2.wheelCircumference;
public static double maxModuleSpeedMeters = SN_SwerveConstants.MK4I_L2.maxSpeedMeters;
public static double driveGearRatio = SN_SwerveConstants.MK4I.FALCON.L2.driveGearRatio;
public static double steerGearRatio = SN_SwerveConstants.MK4I.FALCON.L2.steerGearRatio;
public static double wheelCircumference = SN_SwerveConstants.MK4I.FALCON.L2.wheelCircumference;
public static double maxModuleSpeedMeters = SN_SwerveConstants.MK4I.FALCON.L2.maxSpeedMeters;

// -*- Sim -*-
public static boolean isSimulation = false;
Expand Down

0 comments on commit 40b971d

Please sign in to comment.