Skip to content

Commit

Permalink
Merge pull request #11 from firebears-frc/swerve-fixes
Browse files Browse the repository at this point in the history
Swerve fixes
  • Loading branch information
TylerSeiford authored Feb 4, 2025
2 parents cfef6f7 + 2c15353 commit 2db66f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/subsystems/drive/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class Drive extends SubsystemBase {
private final GyroIOInputsAutoLogged gyroInputs = new GyroIOInputsAutoLogged();
private final Module[] modules = new Module[4]; // FL, FR, BL, BR
private final SysIdRoutine sysId;
private final Rotation2d gyroOffSet = Rotation2d.fromDegrees(180);
private final Alert gyroDisconnectedAlert =
new Alert("Disconnected gyro, using kinematics as fallback.", AlertType.kError);

Expand Down Expand Up @@ -167,7 +168,7 @@ public void periodic() {
// Update gyro angle
if (gyroInputs.connected) {
// Use the real gyro angle
rawGyroRotation = gyroInputs.odometryYawPositions[i];
rawGyroRotation = gyroInputs.odometryYawPositions[i].plus(gyroOffSet);
} else {
// Use the angle delta from the kinematics and module deltas
Twist2d twist = kinematics.toTwist2d(moduleDeltas);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/frc/robot/subsystems/drive/DriveConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ public class DriveConstants {
};

// Zeroed rotation values for each module, see setup instructions
public static final Rotation2d frontLeftZeroRotation = new Rotation2d(0.0);
public static final Rotation2d frontRightZeroRotation = new Rotation2d(0.0);
public static final Rotation2d backLeftZeroRotation = new Rotation2d(0.0);
public static final Rotation2d backRightZeroRotation = new Rotation2d(0.0);
public static final Rotation2d frontLeftZeroRotation = Rotation2d.fromDegrees(-90.0);
public static final Rotation2d frontRightZeroRotation = Rotation2d.fromDegrees(0.0);
public static final Rotation2d backLeftZeroRotation = Rotation2d.fromDegrees(180.0);
public static final Rotation2d backRightZeroRotation = Rotation2d.fromDegrees(90.0);

// Device CAN IDs
public static final int gyroCanId = 9;

public static final int frontLeftDriveCanId = 1;
public static final int backLeftDriveCanId = 5;

public static final int frontRightDriveCanId = 3;
public static final int backRightDriveCanId = 7;

public static final int frontLeftTurnCanId = 2;
public static final int backLeftTurnCanId = 6;

public static final int frontRightTurnCanId = 4;
public static final int backRightTurnCanId = 8;

Expand Down

0 comments on commit 2db66f8

Please sign in to comment.