From f943cda7574ad430d965f0d6dfc752ecee8fc271 Mon Sep 17 00:00:00 2001 From: ericoj100 <144740721+ericoj100@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:25:18 -0800 Subject: [PATCH] gyro constants handled --- .../java/frc/robot/constants/swerve/DriveConstants.java | 8 +++++++- .../frc/robot/subsystems/drivetrain/GyroIOPigeon2.java | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/constants/swerve/DriveConstants.java b/src/main/java/frc/robot/constants/swerve/DriveConstants.java index 5492f69..9419a8c 100644 --- a/src/main/java/frc/robot/constants/swerve/DriveConstants.java +++ b/src/main/java/frc/robot/constants/swerve/DriveConstants.java @@ -141,6 +141,9 @@ public class DriveConstants { /* Neutral Modes */ public static final NeutralModeValue DRIVE_NEUTRAL_MODE = NeutralModeValue.Brake; public static final NeutralModeValue STEER_NEUTRAL_MODE = NeutralModeValue.Brake; + + /* Gyro mount pose roll in deg (180.0 if placed under the robot) */ + public static double GYRO_MOUNT_POSE_ROLL = 0.0; /* Drive Motor PID Values */ public static final double[] P_VALUES = { @@ -209,10 +212,13 @@ public class DriveConstants { // MK5n INVERT_STEER_MOTOR = InvertedValue.CounterClockwise_Positive; - + // Gear ratios DRIVE_GEAR_RATIO = (54.0 / 14.0) * (25.0 / 32.0) * (30.0 / 15.0); STEER_GEAR_RATIO = 287.0 / 11.0; + // Gyro is mounted under the robot + GYRO_MOUNT_POSE_ROLL = 180.0; + MODULE_CONSTANTS = COTSFalconSwerveConstants.SDSMK5n(DRIVE_GEAR_RATIO); } else if(robotId == RobotId.WaffleHouse){ diff --git a/src/main/java/frc/robot/subsystems/drivetrain/GyroIOPigeon2.java b/src/main/java/frc/robot/subsystems/drivetrain/GyroIOPigeon2.java index 1520fdf..1c20db3 100644 --- a/src/main/java/frc/robot/subsystems/drivetrain/GyroIOPigeon2.java +++ b/src/main/java/frc/robot/subsystems/drivetrain/GyroIOPigeon2.java @@ -41,9 +41,11 @@ public class GyroIOPigeon2 implements GyroIO { private final Queue yawPositionQueue; private final Queue yawTimestampQueue; private final StatusSignal yawVelocity = pigeon.getAngularVelocityZWorld(); + private Pigeon2Configuration config = new Pigeon2Configuration(); public GyroIOPigeon2() { - pigeon.getConfigurator().apply(new Pigeon2Configuration()); + config.MountPose.MountPoseRoll = DriveConstants.GYRO_MOUNT_POSE_ROLL; + pigeon.getConfigurator().apply(config); pigeon.getConfigurator().setYaw(0.0); yaw.setUpdateFrequency(250); yawVelocity.setUpdateFrequency(50.0); -- 2.39.5