Package frc.robot

Class SwerveConstants

java.lang.Object
frc.robot.SwerveConstants

public final class SwerveConstants extends Object
Central constants for the MARSLib swerve drivetrain.

Students: Modify these values to match your physical robot. All distances are in meters, all angles are in radians, and all speeds are in m/s or rad/s.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Derivative gain for autonomous rotation path following.
    static final double
    Proportional gain for autonomous rotation path following.
    static final double
    Derivative gain for autonomous translation path following.
    static final double
    Proportional gain for autonomous translation path following.
    static final double
    Outer dimensions of the robot with bumpers, used for bounding boxes and MoI approximation (m)
    static final double
     
    static final double
    Drive motor gear ratio (motor rotations per output rotation).
    static final double
    Nominal stator current limit for drive motors (amps).
    static final double
    Standard gravitational acceleration (m/s²).
    static final double
    Lateral slip relaxation length (m/s).
    static final double
    Maximum achievable angular robot speed (rad/s).
    static final double
    Maximum achievable linear robot speed (m/s).
    static final double
    Minimum current limit during load shedding (amps).
    static final edu.wpi.first.math.geometry.Translation2d[]
    Positions of each swerve module relative to robot center (FL, FR, BL, BR).
    static final double
    Nominal battery voltage used for drive feedforward normalization (V).
    static final double
    Mass of the robot inclusive of battery and bumpers (kg).
    static final double
    Approximate moment of inertia of the robot based on a solid block model (kg*m^2)
    static final double
    Slip velocity threshold (m/s) at which static friction transitions to kinetic.
    static final double
    Distance between left and right module centers (meters).
    static final double
    Turn motor gear ratio (motor rotations per module rotation).
    static final double
    Proportional gain for the module turn voltage controller.
    static final double
    Nominal stator current limit for turn motors (amps).
    static final double
    Coefficient of friction for robot bumpers scraping against field walls.
    static final double
    Coefficient of restitution (bounciness) for robot-to-wall collisions.
    static final double
    Kinetic coefficient of friction once the wheel breaks traction (wheel slip/burnout).
    static final double
    Static coefficient of friction of the tread against standard FRC carpet.
    static final double
    Effective rotational inertia of a single driven wheel assembly including the Kraken X60 rotor reflected through the DRIVE_GEAR_RATIO (kg·m²).
    static final double
    Radius of the swerve drive wheels (meters).
    static final double
    Distance between front and rear module centers (meters).
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TRACK_WIDTH_METERS

      public static final double TRACK_WIDTH_METERS
      Distance between left and right module centers (meters).
      See Also:
    • WHEELBASE_METERS

      public static final double WHEELBASE_METERS
      Distance between front and rear module centers (meters).
      See Also:
    • MODULE_LOCATIONS

      public static final edu.wpi.first.math.geometry.Translation2d[] MODULE_LOCATIONS
      Positions of each swerve module relative to robot center (FL, FR, BL, BR).
    • ROBOT_MASS_KG

      public static final double ROBOT_MASS_KG
      Mass of the robot inclusive of battery and bumpers (kg). 140lbs.
      See Also:
    • BUMPER_LENGTH_METERS

      public static final double BUMPER_LENGTH_METERS
      Outer dimensions of the robot with bumpers, used for bounding boxes and MoI approximation (m)
      See Also:
    • BUMPER_WIDTH_METERS

      public static final double BUMPER_WIDTH_METERS
      See Also:
    • ROBOT_MOI_KG_M2

      public static final double ROBOT_MOI_KG_M2
      Approximate moment of inertia of the robot based on a solid block model (kg*m^2)
    • WHEEL_COF_STATIC

      public static final double WHEEL_COF_STATIC
      Static coefficient of friction of the tread against standard FRC carpet.
      See Also:
    • WHEEL_COF_KINETIC

      public static final double WHEEL_COF_KINETIC
      Kinetic coefficient of friction once the wheel breaks traction (wheel slip/burnout).
      See Also:
    • SLIP_TRANSITION_VELOCITY_MPS

      public static final double SLIP_TRANSITION_VELOCITY_MPS
      Slip velocity threshold (m/s) at which static friction transitions to kinetic.

      Below this velocity, wheel grip uses WHEEL_COF_STATIC. Above it, grip drops to WHEEL_COF_KINETIC, modeling the Stribeck/Coulomb friction curve.

      See Also:
    • LATERAL_SLIP_RELAXATION

      public static final double LATERAL_SLIP_RELAXATION
      Lateral slip relaxation length (m/s). Controls the viscous ramp region for sideways tire friction to prevent numerical jitter at low lateral velocities.
      See Also:
    • WHEEL_MOI_KG_M2

      public static final double WHEEL_MOI_KG_M2
      Effective rotational inertia of a single driven wheel assembly including the Kraken X60 rotor reflected through the DRIVE_GEAR_RATIO (kg·m²).
      See Also:
    • GRAVITY_M_PER_S2

      public static final double GRAVITY_M_PER_S2
      Standard gravitational acceleration (m/s²).
      See Also:
    • WALL_FRICTION

      public static final double WALL_FRICTION
      Coefficient of friction for robot bumpers scraping against field walls.
      See Also:
    • WALL_RESTITUTION

      public static final double WALL_RESTITUTION
      Coefficient of restitution (bounciness) for robot-to-wall collisions.
      See Also:
    • WHEEL_RADIUS_METERS

      public static final double WHEEL_RADIUS_METERS
      Radius of the swerve drive wheels (meters). Standard 2-inch colson = 0.0508m.
      See Also:
    • MAX_LINEAR_SPEED_MPS

      public static final double MAX_LINEAR_SPEED_MPS
      Maximum achievable linear robot speed (m/s).
      See Also:
    • MAX_ANGULAR_SPEED_RAD_PER_SEC

      public static final double MAX_ANGULAR_SPEED_RAD_PER_SEC
      Maximum achievable angular robot speed (rad/s).
      See Also:
    • NOMINAL_BATTERY_VOLTAGE

      public static final double NOMINAL_BATTERY_VOLTAGE
      Nominal battery voltage used for drive feedforward normalization (V).

      This is the true battery nominal (12.0V), NOT the load-shedding trigger threshold (PowerConstants.NOMINAL_VOLTAGE). Used in SwerveModule.setDesiredState(edu.wpi.first.math.kinematics.SwerveModuleState) to scale desired speed into voltage.

      See Also:
    • DRIVE_GEAR_RATIO

      public static final double DRIVE_GEAR_RATIO
      Drive motor gear ratio (motor rotations per output rotation). L1 = 6.75:1.
      See Also:
    • TURN_GEAR_RATIO

      public static final double TURN_GEAR_RATIO
      Turn motor gear ratio (motor rotations per module rotation).
      See Also:
    • DRIVE_STATOR_CURRENT_LIMIT

      public static final double DRIVE_STATOR_CURRENT_LIMIT
      Nominal stator current limit for drive motors (amps).
      See Also:
    • TURN_STATOR_CURRENT_LIMIT

      public static final double TURN_STATOR_CURRENT_LIMIT
      Nominal stator current limit for turn motors (amps).
      See Also:
    • MIN_LOAD_SHED_CURRENT

      public static final double MIN_LOAD_SHED_CURRENT
      Minimum current limit during load shedding (amps).
      See Also:
    • TURN_KP

      public static final double TURN_KP
      Proportional gain for the module turn voltage controller.
      See Also:
    • AUTO_TRANSLATION_KP

      public static final double AUTO_TRANSLATION_KP
      Proportional gain for autonomous translation path following.
      See Also:
    • AUTO_TRANSLATION_KD

      public static final double AUTO_TRANSLATION_KD
      Derivative gain for autonomous translation path following.
      See Also:
    • AUTO_ROTATION_KP

      public static final double AUTO_ROTATION_KP
      Proportional gain for autonomous rotation path following.
      See Also:
    • AUTO_ROTATION_KD

      public static final double AUTO_ROTATION_KD
      Derivative gain for autonomous rotation path following.
      See Also: