Skip to content

[choreolib] Add trajectory mirroring for x and y#1452

Merged
shueja merged 27 commits intoSleipnirGroup:mainfrom
RohanBhattacharyya:main
Apr 5, 2026
Merged

[choreolib] Add trajectory mirroring for x and y#1452
shueja merged 27 commits intoSleipnirGroup:mainfrom
RohanBhattacharyya:main

Conversation

@RohanBhattacharyya
Copy link
Copy Markdown
Contributor

@RohanBhattacharyya RohanBhattacharyya commented Mar 23, 2026

Allows the user to create a mirrored trajectory over the length or width.

Example usage would be if an auto was made for one side of the trench, but the user wants to run it for the other side in 2026 REBUILT.

Example usage:

private AutoRoutine shootToAllianceLeft() {
    final AutoRoutine routine = autoFactory.newRoutine("Shoot to Alliance Left");
    final AutoTrajectory traj = ShootAlliance.asAutoTraj(routine);

    routine.active().onTrue(
        Commands.sequence(
            traj.resetOdometry(),
            traj.cmd()
        )
    );


    return routine;
}

private AutoRoutine shootToAllianceRight() {
    final AutoRoutine routine = autoFactory.newRoutine("Shoot to Alliance Right");
    final AutoTrajectory traj = ShootAlliance.asAutoTraj(routine).mirrorY();

    routine.active().onTrue(
        Commands.sequence(
            traj.resetOdometry(),
            traj.cmd()
        )
    );
    return routine;
}

@Daniel1464
Copy link
Copy Markdown
Contributor

Looks good, but I would recommend adding mirrorX() and mirrorY() instance methods to AutoTrajectory, so you could just do

ShootAliance.asAutoTraj(routine).mirrorY()

@RohanBhattacharyya
Copy link
Copy Markdown
Contributor Author

Looks good, but I would recommend adding mirrorX() and mirrorY() instance methods to AutoTrajectory, so you could just do

ShootAliance.asAutoTraj(routine).mirrorY()

Alright, I added that.

return ChoreoAllianceFlipUtil.getFlipper().flip(this);
}

@Override
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added new public methods:

  • DifferentialSample::mirrorY and DifferentialSample::mirrorX
  • SwerveSample::mirrorY and SwerveSample::mirrorX

public class ChoreoAllianceFlipUtil {
/** The flipper to use for flipping coordinates. */
public static enum Flipper {
public abstract static class Flipper {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Flipper is no longer an enum with MIRRORED and ROTATE_AROUND, it is an abstract class with factories and instance utility methods.

Copy link
Copy Markdown
Member

@calcmogul calcmogul left a comment

Choose a reason for hiding this comment

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

The Copilot output wasn't great.

Comment thread choreolib/src/main/native/include/choreo/trajectory/DifferentialSample.h Outdated
Comment thread choreolib/src/main/native/include/choreo/trajectory/DifferentialSample.h Outdated
Comment thread choreolib/src/main/native/include/choreo/trajectory/DifferentialSample.h Outdated
Comment thread choreolib/src/main/native/include/choreo/trajectory/SwerveSample.h Outdated
Comment thread choreolib/src/main/native/include/choreo/trajectory/SwerveSample.h Outdated
Comment thread choreolib/src/main/native/include/choreo/trajectory/DifferentialSample.h Outdated
Comment thread choreolib/py/choreo/trajectory/__init__.py Outdated
Comment thread choreolib/py/choreo/trajectory/__init__.py Outdated
@calcmogul calcmogul removed help: needs C++ Needs a C++ port. help: needs Python Needs a Python port. labels Mar 23, 2026
@RohanBhattacharyya
Copy link
Copy Markdown
Contributor Author

I updated the port to C++ and Python with codex.

@calcmogul
Copy link
Copy Markdown
Member

calcmogul commented Mar 23, 2026

Please don't use an LLM to address review comments like this. It generated a lot of bad code, and I don't want to spend the time annotating everything it messed up.

@RohanBhattacharyya
Copy link
Copy Markdown
Contributor Author

Please don't use an LLM to address review comments like this. It generated a lot of bad code, and I don't want to spend the time annotating everything it messed up.

Alright, I undid the LLM-based commits. Please add the help: needs C++ and help: needs Python tags. This is reverted to before the Python and C++ ports.

@calcmogul calcmogul added help: needs C++ Needs a C++ port. help: needs Python Needs a Python port. labels Mar 23, 2026
Comment thread choreolib/src/main/native/include/choreo/trajectory/SwerveSample.h Outdated
@calcmogul calcmogul removed the help: needs C++ Needs a C++ port. label Apr 4, 2026
@calcmogul calcmogul removed the help: needs Python Needs a Python port. label Apr 4, 2026
Comment thread choreolib/src/main/java/choreo/trajectory/DifferentialSample.java Outdated
@shueja shueja dismissed calcmogul’s stale review April 5, 2026 02:30

Fixed function order

@shueja shueja merged commit d5b4aab into SleipnirGroup:main Apr 5, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChoreoAllianceFlippingUtil should be able to switch to a custom flipper

4 participants