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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Daniel1464
Copy link

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
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
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
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)

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.

3 participants