Fix inverse rotation in FTCCoordinates and InvertedFTCCoordinates#156
Fix inverse rotation in FTCCoordinates and InvertedFTCCoordinates#156MightyHelper wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the FTC ↔ Pedro pose conversion round-trip behavior by updating the rotation direction in convertToPedro() so it is the mathematical inverse of convertFromPedro() for both standard and inverted FTC coordinate systems.
Changes:
- Update
FTCCoordinates.convertToPedro()to rotate by+π/2(inverse of-π/2inconvertFromPedro()). - Update
InvertedFTCCoordinates.convertToPedro()to rotate by-π/2(inverse of+π/2inconvertFromPedro()).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ftc/src/main/java/com/pedropathing/ftc/FTCCoordinates.java | Fixes convertToPedro() rotation sign to correctly invert convertFromPedro() |
| ftc/src/main/java/com/pedropathing/ftc/InvertedFTCCoordinates.java | Fixes convertToPedro() rotation sign to correctly invert convertFromPedro() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -39,6 +39,6 @@ public Pose convertFromPedro(Pose pose) { | |||
| @Override | |||
| public Pose convertToPedro(Pose pose) { | |||
| Pose newPose = new Pose (pose.getX(), pose.getY(), pose.getHeading(), PedroCoordinates.INSTANCE); | |||
There was a problem hiding this comment.
There’s an extra space between the constructor name and parentheses (new Pose (...)), which is inconsistent with the rest of the codebase’s new Pose(...) usage. Consider removing the space for consistent formatting.
| @@ -37,6 +37,6 @@ public Pose convertFromPedro(Pose pose) { | |||
| @Override | |||
| public Pose convertToPedro(Pose pose) { | |||
| Pose newPose = new Pose (pose.getX(), pose.getY(), pose.getHeading(), PedroCoordinates.INSTANCE); | |||
There was a problem hiding this comment.
There’s an extra space between the constructor name and parentheses (new Pose (...)), which is inconsistent with the rest of the codebase’s new Pose(...) usage. Consider removing the space for consistent formatting.
Summary
This fixes the
convertToPedro()implementations inFTCCoordinatesandInvertedFTCCoordinatesso they are the actual inverse ofconvertFromPedro().Problem
convertFromPedro()andconvertToPedro()appear intended to be inverse transforms between Pedro coordinates and the FTC field coordinate systems.This also matches the published coordinate conventions:
+xto the right,+yupward on the field image, with positive heading counterclockwise.-pi/2rotation from Pedro to FTC, so the reverse transform should use+pi/2.+pi/2rotation from Pedro to FTC, so the reverse transform should use-pi/2.In the current implementation, both directions use the same rotation sign, so round-tripping an arbitrary pose does not return the original pose.
For example, with
FTCCoordinates:convertFromPedro()translates by(-72, -72)and rotates by-pi/2+pi/2and then translate by(+72, +72)Instead,
convertToPedro()also rotates by-pi/2, which breaks round-trip identity.The same issue exists in
InvertedFTCCoordinateswith the opposite sign.Changes
FTCCoordinates.convertToPedro(): change rotation from-pi/2to+pi/2InvertedFTCCoordinates.convertToPedro(): change rotation from+pi/2to-pi/2Impact
This restores the expected identity properties:
convertFromPedro(convertToPedro(pose)) == poseconvertToPedro(convertFromPedro(pose)) == posefor arbitrary poses in these coordinate systems.
References