Skip to content

Pose inexplicably jumps when auto starts #7855

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

Closed
clrozeboom opened this issue Mar 7, 2025 · 2 comments
Closed

Pose inexplicably jumps when auto starts #7855

clrozeboom opened this issue Mar 7, 2025 · 2 comments
Labels
type: bug Something isn't working.

Comments

@clrozeboom
Copy link

Describe the bug
When we enable in auto, the pose will inexplicably jump to a random position. It can be off field or on.
I haven't seen it do this any other time than when we start an auto. We have a detection routine in our code where it will stop the auto if it is off field. I don't know if we've seen this behavior at comp, just at home.

To Reproduce
Steps to reproduce the behavior:

  1. Start robot code
  2. Set the initial pose to a preset
  3. Enable auto

Expected behavior
The pose will not jump to a random place in auto, but remain where it is set.

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. Windows 11]
  • Project Information:
  • WPILib Information:
    Project Version: 2025.3.1
    VS Code Version: 1.96.2
    WPILib Extension Version: 2025.3.1
    C++ Extension Version: 1.23.2
    Java Extension Version: 1.38.0
    Java Debug Extension Version: 0.58.1
    Java Dependencies Extension Version 0.24.1
    Java Version: 17
    Java Location: C:\Users\Public\wpilib\2025\jdk
    Vendor Libraries:
    ChoreoLib (2025.0.3)
    maplesim (0.3.9)
    PathplannerLib (2025.2.3)
    CTRE-Phoenix (v5) (5.35.1)
    CTRE-Phoenix (v6) (25.2.2)
    photonlib (v2025.1.1)
    ReduxLib (2025.0.1)
    REVLib (2025.0.2)
    Studica (2025.0.1)
    ThriftyLib (2025.0.2)
    WPILib-New-Commands (1.0.0)

Additional context
I have implemented a workaround in the code to handle this situation. When I detect that the pose is off by more than 0.1m (arbitrarily) from the last known pose, I re-run the pose-estimator update after resetting the pose to last known. I've seen this behavior when connected over AP, tethered, and in debug mode.
Our pose estimator is in YAGSL code and we are using a copy of the library instead of the vendordep.
The log output I'm getting doesn't seem to have anything off. Encoders haven't moved on the swerve modules. Yaw is basically 0.

https://github.com/FRC5010/Reefscape2025/blob/main/TigerShark2025/src/main/java/swervelib/SwerveDrive.java:1160
      Rotation2d yaw = getYaw();
// The normal update
      swerveDrivePoseEstimator.update(yaw, getModulePositions());

// Check that the pose hasn't jumped
      Pose2d currentPose = swerveDrivePoseEstimator.getEstimatedPosition();
      if (lastPoseEstimate != null) {
        double distance = Math.abs(lastPoseEstimate.getTranslation().getDistance(currentPose.getTranslation()));

// If we are enabled and a big jump occurs, reset the pose and try again
        if(distance > 0.1 && DriverStation.isEnabled()) {
          DriverStation.reportError("Pose error: Distance " + distance + "  Yaw " + yaw + " Last Pose " + lastPoseEstimate + " to " + currentPose, false);
          Arrays.stream(getModulePositions()).forEach(it -> DriverStation.reportError("Pose error: Module " + it , false));

// Reset the pose and try again
          swerveDrivePoseEstimator.resetPose(lastPoseEstimate);
          currentPose = swerveDrivePoseEstimator.update(yaw, getModulePositions());
          distance = Math.abs(lastPoseEstimate.getTranslation().getDistance(currentPose.getTranslation()));
          if(distance > 0.1) {
            DriverStation.reportError("Pose error: Nope that didn't help", false);
          } else {
            DriverStation.reportError("Pose error: Reset pose to last known", false);
          }
        }
      }

// Store the last known good pose
      lastPoseEstimate = currentPose;
@clrozeboom clrozeboom added the type: bug Something isn't working. label Mar 7, 2025
@clrozeboom
Copy link
Author

Additional context, we were working on odometry calibration and using only odometry to run autos, so no vision inputs are being given. We tried breakpoints at various places where the pose gets reset and not seeing anything reset the pose unexpectedly. We are using PathPlanner's path-generation on-the-fly to create the path, so we are not seeing it set pose to the start of an auto-path.

@clrozeboom
Copy link
Author

Figured this out. We have code from way back that zeros our drive train encoders. This caused the pose estimator to register a change in pose that would be relative to how our robot moved prior to starting auto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant