Skip to content

Fix inverse rotation in FTCCoordinates and InvertedFTCCoordinates#156

Open
MightyHelper wants to merge 1 commit into
Pedro-Pathing:mainfrom
MightyHelper:fix-ftc-coordinate-inverse
Open

Fix inverse rotation in FTCCoordinates and InvertedFTCCoordinates#156
MightyHelper wants to merge 1 commit into
Pedro-Pathing:mainfrom
MightyHelper:fix-ftc-coordinate-inverse

Conversation

@MightyHelper
Copy link
Copy Markdown

ℹ️ I may be misunderstanding the intended semantics here, but I found what looks like a round-trip inconsistency in the FTC coordinate transforms. This PR assumes convertFromPedro() and convertToPedro() are meant to be inverses; if that assumption is wrong, feel free to disregard.

Summary

This fixes the convertToPedro() implementations in FTCCoordinates and InvertedFTCCoordinates so they are the actual inverse of convertFromPedro().

Problem

convertFromPedro() and convertToPedro() appear intended to be inverse transforms between Pedro coordinates and the FTC field coordinate systems.

This also matches the published coordinate conventions:

  • Pedro docs define +x to the right, +y upward on the field image, with positive heading counterclockwise.
  • FTC docs define the standard field frame from the Red Wall reference frame, with positive rotation also counterclockwise.
  • For the normal FTC field, that mapping corresponds to a -pi/2 rotation from Pedro to FTC, so the reverse transform should use +pi/2.
  • For the inverted FTC field, the mapping corresponds to a +pi/2 rotation 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
  • the inverse should therefore rotate by +pi/2 and then translate by (+72, +72)

Instead, convertToPedro() also rotates by -pi/2, which breaks round-trip identity.

The same issue exists in InvertedFTCCoordinates with the opposite sign.

Changes

  • FTCCoordinates.convertToPedro(): change rotation from -pi/2 to +pi/2
  • InvertedFTCCoordinates.convertToPedro(): change rotation from +pi/2 to -pi/2

Impact

This restores the expected identity properties:

  • convertFromPedro(convertToPedro(pose)) == pose
  • convertToPedro(convertFromPedro(pose)) == pose

for arbitrary poses in these coordinate systems.

References

Copilot AI review requested due to automatic review settings April 8, 2026 17:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -π/2 in convertFromPedro()).
  • Update InvertedFTCCoordinates.convertToPedro() to rotate by -π/2 (inverse of +π/2 in convertFromPedro()).

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);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@@ -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);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

2 participants