Skip to content

Commit

Permalink
Reset and Set Gyro methods
Browse files Browse the repository at this point in the history
  • Loading branch information
harnwalN committed Feb 11, 2024
1 parent 0434ce2 commit c592a76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/frc/robot/subsystems/drive/GyroIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public interface GyroIO {
@AutoLog
public static class GyroIOInputs {
class GyroIOInputs {
public boolean connected = false;
public double yawPositionRad = 0;
public double pitchPositionRad = 0;
Expand All @@ -14,9 +14,11 @@ public static class GyroIOInputs {
public double rollVelocityRadPerSec = 0.0;
}

public default void updateInputs(GyroIOInputs inputs) {}
default void updateInputs(GyroIOInputs inputs) {}

public default double getYawDegrees() {
return 0;
default void setGyro(GyroIOInputs inputs, double degrees) {
inputs.yawPositionRad = Math.toRadians(degrees);
}

default void resetGyro() {}
}
9 changes: 9 additions & 0 deletions src/main/java/frc/robot/subsystems/drive/GyroIOADIS16470.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public void updateInputs(GyroIOInputs gyroInputs) {
gyroInputs.rollVelocityRadPerSec =
Units.degreesToRadians(gyro.getRate(ADIS16470_IMU.IMUAxis.kZ));
}

public void setGyro(GyroIOInputs inputs, double degrees) {
gyro.setGyroAngle(ADIS16470_IMU.IMUAxis.kZ, Math.toRadians(degrees));
inputs.yawPositionRad = Math.toRadians(degrees);
}

public void resetGyro() {
gyro.reset();
}
}

0 comments on commit c592a76

Please sign in to comment.