-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
532 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,3 +173,5 @@ out/ | |
ctre_sim/ | ||
src/main/java/org/jmhsrobotics/frc2024/BuildConstants.java | ||
*.wpilog | ||
simgui-ds.json | ||
simgui.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package org.jmhsrobotics.frc2024; | ||
|
||
import com.revrobotics.CANSparkBase.IdleMode; | ||
|
||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.math.kinematics.SwerveDriveKinematics; | ||
import edu.wpi.first.math.util.Units; | ||
|
||
public class Constants { | ||
public static class SwerveConstants { | ||
// SPARK MAX CAN IDs | ||
public static final int kFrontLeftDrivingCanId = 10; | ||
public static final int kRearLeftDrivingCanId = 12; | ||
public static final int kFrontRightDrivingCanId = 11; | ||
public static final int kRearRightDrivingCanId = 13; | ||
|
||
public static final int kFrontLeftTurningCanId = 20; | ||
public static final int kRearLeftTurningCanId = 22; | ||
public static final int kFrontRightTurningCanId = 21; | ||
public static final int kRearRightTurningCanId = 23; | ||
|
||
public static final int kGyroCanId = 62; | ||
public static final boolean kGyroReversed = false; | ||
|
||
public static final double dtOffset = 0.02; | ||
|
||
public static final double kMaxXSpeed = 0.8; | ||
public static final double kMaxYSpeed = 0.8; | ||
public static final double kMaxRotationSpeed = 0.8; | ||
public static final boolean kFieldRelative = true; | ||
public static final boolean kRateLimit = false; | ||
|
||
// drive deadband constants | ||
public static final double kDeadBand = 0.05; | ||
// Driving Parameters - Note that these are not the maximum capable speeds of | ||
// the robot, rather the allowed maximum speeds | ||
public static final double kMaxSpeedMetersPerSecond = 4.2; | ||
public static final double kMaxAngularSpeed = Math.PI; // radians per second | ||
|
||
public static final double kDirectionSlewRate = 1.4; // radians per second | ||
public static final double kMagnitudeSlewRate = 1.8; // percent per second (1 = 100%) | ||
public static final double kRotationalSlewRate = 2.0; // percent per second (1 = 100%) | ||
|
||
private static final double kRobotWidthWheelDifference = 1.75 * 2; | ||
|
||
// Chassis configuration | ||
// Distance between centers of right and left wheels on robot | ||
public static final double kTrackWidth = Units.inchesToMeters(26 - kRobotWidthWheelDifference); | ||
// Distance between centers of front and back wheels on robot | ||
public static final double kWheelBase = Units.inchesToMeters(26 - kRobotWidthWheelDifference); | ||
|
||
public static final SwerveDriveKinematics kDriveKinematics = new SwerveDriveKinematics( | ||
new Translation2d(kWheelBase / 2, kTrackWidth / 2), new Translation2d(kWheelBase / 2, -kTrackWidth / 2), | ||
new Translation2d(-kWheelBase / 2, kTrackWidth / 2), | ||
new Translation2d(-kWheelBase / 2, -kTrackWidth / 2)); | ||
|
||
// Angular offsets of the modules relative to the chassis in radians | ||
public static final double kFrontLeftChassisAngularOffset = -Math.PI / 2; | ||
public static final double kFrontRightChassisAngularOffset = 0; | ||
public static final double kBackLeftChassisAngularOffset = Math.PI; | ||
public static final double kBackRightChassisAngularOffset = Math.PI / 2; | ||
} | ||
|
||
public enum ModuleSpeed { | ||
HIGH(14), MEDIUM(13), LOW(12); | ||
|
||
public final int pinionTeeth; | ||
|
||
ModuleSpeed(int pinionTeeth) { | ||
this.pinionTeeth = pinionTeeth; | ||
} | ||
|
||
} | ||
|
||
public static final class ModuleConstants { | ||
// The MAXSwerve module can be configured with one of three pinion gears: 12T, | ||
// 13T, or 14T. | ||
// This changes the drive speed of the module (a pinion gear with more teeth | ||
// will result in a | ||
// robot that drives faster). | ||
public static final int kDrivingMotorPinionTeeth = ModuleSpeed.HIGH.pinionTeeth; | ||
|
||
// Invert the turning encoder, since the output shaft rotates in the opposite | ||
// direction of | ||
// the steering motor in the MAXSwerve Module. | ||
public static final boolean kTurningEncoderInverted = true; | ||
|
||
// Calculations required for driving motor conversion factors and feed forward | ||
public static final double kDrivingMotorFreeSpeedRps = NeoMotorConstants.kFreeSpeedRpm / 60; | ||
public static final double kWheelDiameterMeters = 0.0762; | ||
public static final double kWheelCircumferenceMeters = kWheelDiameterMeters * Math.PI; | ||
// 45 teeth on the wheel's bevel gear, 22 teeth on the first-stage spur gear, 15 | ||
// teeth on the bevel pinion | ||
public static final double kDrivingMotorReduction = (45.0 * 22) / (kDrivingMotorPinionTeeth * 15); | ||
public static final double kDriveWheelFreeSpeedRps = (kDrivingMotorFreeSpeedRps * kWheelCircumferenceMeters) | ||
/ kDrivingMotorReduction; | ||
|
||
// used | ||
public static final double kDrivingEncoderPositionFactor = (kWheelDiameterMeters * Math.PI) | ||
/ kDrivingMotorReduction; // meters | ||
// used | ||
public static final double kDrivingEncoderVelocityFactor = ((kWheelDiameterMeters * Math.PI) | ||
/ kDrivingMotorReduction) / 60.0; // meters per second | ||
|
||
public static final double kTurningEncoderPositionFactor = (2 * Math.PI); // radians | ||
public static final double kTurningEncoderVelocityFactor = (2 * Math.PI) / 60.0; // radians per second | ||
|
||
public static final double kTurningEncoderPositionPIDMinInput = 0; // radians | ||
public static final double kTurningEncoderPositionPIDMaxInput = kTurningEncoderPositionFactor; // radians | ||
|
||
public static final double kDrivingP = 0.04; | ||
public static final double kDrivingI = 0; | ||
public static final double kDrivingD = 0; | ||
public static final double kDrivingFF = 1 / kDriveWheelFreeSpeedRps; | ||
public static final double kDrivingMinOutput = -1; | ||
public static final double kDrivingMaxOutput = 1; | ||
|
||
public static final double kTurningP = 1; | ||
public static final double kTurningI = 0; | ||
public static final double kTurningD = 0; | ||
public static final double kTurningFF = 0; | ||
public static final double kTurningMinOutput = -1; | ||
public static final double kTurningMaxOutput = 1; | ||
|
||
public static final IdleMode kDrivingMotorIdleMode = IdleMode.kBrake; | ||
public static final IdleMode kTurningMotorIdleMode = IdleMode.kBrake; | ||
|
||
public static final int kDrivingMotorCurrentLimit = 50; // amps | ||
public static final int kTurningMotorCurrentLimit = 20; // amps | ||
} | ||
|
||
// TODO: Clean up auto constants later | ||
public static final class AutoConstants { | ||
|
||
} | ||
|
||
public static final class NeoMotorConstants { | ||
public static final double kFreeSpeedRpm = 5676; | ||
} | ||
|
||
public static final class LEDConstants { | ||
public static final int LEDPortID = 9; | ||
public static final int LEDLength = 60; | ||
public static final int rainbowSpeed = 3; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.