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

Added routine.trajectory() method #912

Merged

Conversation

Daniel1464
Copy link
Contributor

Currently, the way to construct AutoTrajectories is using the factory.trajectory method:

var trajectory = factory.trajectory("AmpToC1", routine);

This PR provides a better-named alternative:

var trajectory = routine.trajectory("AmpToC1");

Note: c++ and docs updates are still tbd.

@calcmogul
Copy link
Member

Is adding a second way to do the same thing necessary? Can we remove the other one?

@Daniel1464
Copy link
Contributor Author

Is adding a second way to do the same thing necessary? Can we remove the other one?

Possibly; I didn't want to introduce a breaking change.

@calcmogul
Copy link
Member

The API is new for 2025, so we can break whatever we want before kickoff.

/** A generator that returns an auto routine that does nothing */
static final AutoRoutineGenerator NONE = factory -> AutoFactory.VOID_ROUTINE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why change the way this is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

voidRoutine has to be an instance method because AutoRoutine now depends on the AutoFactory.

Comment on lines 124 to 130
final TrajectoryCache trajectoryCache = new TrajectoryCache();
final Supplier<Pose2d> poseSupplier;
final BiConsumer<Pose2d, ? extends TrajectorySample<?>> controller;
final BooleanSupplier mirrorTrajectory;
final Subsystem driveSubsystem;
final AutoBindings bindings = new AutoBindings();
final Optional<TrajectoryLogger<? extends TrajectorySample<?>>> trajectoryLogger;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels off to me; I don't get the benefit from breaking encapsulation like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could pass them in as dependencies instead of passing in the AutoFactory itself. Overall though, it still doesn't break encapsulation from the library side(and was the only way I could do this)

@oh-yes-0-fps
Copy link
Collaborator

oh-yes-0-fps commented Dec 6, 2024

The members being package protected is silly, just have the trajectory methods in auto factory be package protected.

@oh-yes-0-fps oh-yes-0-fps force-pushed the trajectory-method-in-routine branch from 601f774 to e6d487a Compare December 6, 2024 17:26
docs/choreolib/auto-routines.md Outdated Show resolved Hide resolved
docs/choreolib/auto-routines.md Outdated Show resolved Hide resolved
shueja
shueja previously requested changes Dec 6, 2024
docs/choreolib/auto-routines.md Outdated Show resolved Hide resolved
@oh-yes-0-fps oh-yes-0-fps force-pushed the trajectory-method-in-routine branch from 5367358 to 4224991 Compare December 6, 2024 17:40
@oh-yes-0-fps oh-yes-0-fps force-pushed the trajectory-method-in-routine branch from 725e96f to b997828 Compare December 6, 2024 17:46
@oh-yes-0-fps oh-yes-0-fps dismissed stale reviews from shueja and spacey-sooty December 6, 2024 17:46

i fixed it

@@ -213,7 +213,7 @@ public AutoRoutine fivePieceAutoCompositionSeg(AutoFactory factory) {
// value
// AMP, SUB, SRC: The 3 starting positions
// Try to load all the trajectories we need
final AutoTrajectory ampToC1 = factory.trajectory("ampToC1", factory.voidLoop());
Copy link
Collaborator

Choose a reason for hiding this comment

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

nvm this causes an exception

Copy link
Collaborator

@oh-yes-0-fps oh-yes-0-fps left a comment

Choose a reason for hiding this comment

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

lgtm

shueja added a commit that referenced this pull request Dec 6, 2024
@spacey-sooty spacey-sooty added this pull request to the merge queue Dec 6, 2024
Merged via the queue into SleipnirGroup:main with commit fef4569 Dec 6, 2024
32 checks passed
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.

5 participants