Skip to content

Commit

Permalink
Merge pull request #41 from frc937/heading-snapping-bug
Browse files Browse the repository at this point in the history
Heading snapping bug
  • Loading branch information
Jack-Haefele authored Feb 2, 2024
2 parents 97822b0 + 479a8e8 commit 4eb5332
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public DriveFieldOrientedHeadingSnapping() {

// Called when the command is initially scheduled.
@Override
public void initialize() {}
public void initialize() {
drive.setHeadingCorrection(true);
}

// Called every time the scheduler runs while the command is scheduled.
@Override
Expand Down Expand Up @@ -78,7 +80,9 @@ public void execute() {

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}
public void end(boolean interrupted) {
drive.setHeadingCorrection(false);
}

// Returns true when the command should end.
@Override
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/frc/robot/subsystems/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public void enterXMode() {
drive.lockPose();
}

/**
* Set the heading correction capabilities of YAGSL. Should only be enabled when heading
* correction capabilities are in use
*
* @param state SwerveDrive.headingCorrection state
*/
public void setHeadingCorrection(boolean state) {
drive.setHeadingCorrection(state);
}

/**
* Takes [-1, 1] joystick-like inputs and converts them to a {@link ChassisSpeeds} object that
* represents the commanded robot velocities
Expand Down

0 comments on commit 4eb5332

Please sign in to comment.