Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add delay for motor init on MK4i modules #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/frc/robot/subsystems/Swerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import edu.wpi.first.math.kinematics.SwerveModuleState;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj.Timer;

public class Swerve extends SubsystemBase {
public SwerveDriveOdometry swerveOdometry;
Expand All @@ -35,6 +36,14 @@ public Swerve() {
new SwerveModule(3, Constants.Swerve.Mod3.constants)
};

/*
* By pausing init for a second before setting module offsets, we avoid a bug
* with inverting motors.
* See https://github.com/Team364/BaseFalconSwerve/issues/8 for more info.
*/
Timer.delay(1.0);
resetModulesToAbsolute();

swerveOdometry = new SwerveDriveOdometry(Constants.Swerve.swerveKinematics, getGyroYaw(), getModulePositions());
}

Expand Down Expand Up @@ -124,4 +133,4 @@ public void periodic(){
SmartDashboard.putNumber("Mod " + mod.moduleNumber + " Velocity", mod.getState().speedMetersPerSecond);
}
}
}
}