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

PathPlannerTrajectory.transformStateForAlliance appears to be incorrect? #241

Closed
vfurman-gh opened this issue Feb 9, 2023 · 3 comments
Closed

Comments

@vfurman-gh
Copy link

Hello,
First of all, thanks a lot for sharing the path planner code! It is a big help for the team I mentor!
We encountered an issue with the library, though. We trying to use PathPlannerTrajectory.transformStateForAlliance, looking at the PathPlannerTrajectory.java:124, it looks like translation happens by mirroring around axis with Y=FIELD_WIDTH_METERS/2:
new Translation2d(state.poseMeters.getX(), FIELD_WIDTH_METERS - state.poseMeters.getY());

I think to transform to red alliance coordinates, we should actually mirror around axis with X=8, so the code should look like:
new Translation2d(16 - state.poseMeters.getX(), state.poseMeters.getY());
What do you think?

@hadley31
Copy link
Contributor

hadley31 commented Feb 9, 2023

The origin is always assumed to be the right corner of your current alliance station. This years game makes that a little more difficult because the field is not symmetrical in that way, thus mirroring over the Y axis is correct

@vfurman-gh
Copy link
Author

vfurman-gh commented Feb 9, 2023 via email

@hadley31
Copy link
Contributor

hadley31 commented Feb 9, 2023

Yes, the AprilTagFieldLayout class has a setOrigin() method, that should be set depending on the value of DriverStation.getAlliance()

@mjansen4857 mjansen4857 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants