Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Update DriveSubsystem.java
Browse files Browse the repository at this point in the history
  • Loading branch information
jack60612 committed Jan 23, 2024
1 parent ec2e80a commit 1681969
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public class DriveSubsystem extends SubsystemBase {
// setup SysID for auto profiling
private final SysIdRoutine m_sysIdRoutine;

private boolean gyroZeroPending = true;

/** Creates a new DriveSubsystem. */
public DriveSubsystem() {
// Init gyro
Expand Down Expand Up @@ -160,8 +162,6 @@ public DriveSubsystem() {
m_encoderFrontLeft.setPositionConversionFactor(DriveConstants.POSITION_CONVERSION_RATIO);
m_encoderFrontRight.setPositionConversionFactor(DriveConstants.POSITION_CONVERSION_RATIO);
resetEncoders();
// Every time this function is called, A dollar is taken out of Jack's savings. Aka do it more.
resetGyro();

// setup PID controllers
configureMotorPIDControllers();
Expand Down Expand Up @@ -524,6 +524,10 @@ public double getPositionRight() {

@Override
public void periodic() {
if (gyroZeroPending && !m_Gyro.isCalibrating()) {
resetGyro();
gyroZeroPending = false;
}
// This method will be called once per scheduler run
SmartDashboard.putNumber("Left Encoder Speed (M/s)", this.getVelocityLeft());
SmartDashboard.putNumber("Right Encoder Speed (M/s)", this.getVelocityRight());
Expand Down

0 comments on commit 1681969

Please sign in to comment.