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 a triggers api for auto routines #469

Closed
wants to merge 0 commits into from

Conversation

oh-yes-0-fps
Copy link
Collaborator

Removed old choreo command api

@oh-yes-0-fps oh-yes-0-fps changed the title Added a triggers api for auto routiness Added a triggers api for auto routines Apr 29, 2024
@oh-yes-0-fps oh-yes-0-fps marked this pull request as draft April 29, 2024 01:34
@oh-yes-0-fps
Copy link
Collaborator Author

This will have to wait for a stabilization of the frontend/app on how it emits event markers in the trajectory json

@shueja
Copy link
Collaborator

shueja commented May 4, 2024

This will remain unmerged until we (hopefully) release a final 2024 version of Choreo before the UI rewrite, since this is such a breaking change.

@oh-yes-0-fps
Copy link
Collaborator Author

That makes complete sense, i still have to test it on a robot irl. I have made a python script to change old .traj files to the new format so devs can beta test stuff until ui catches up.

The changes to the traj spec include the name of the trajectory in the json and an alternate event type thats simpler than pp event triggers.

private static final Gson gson = new Gson();

/** Default constructor. */
public Choreo() {}
public Choreo() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just make the constructor private?

*
* @return A {@link Trigger} that is true while this autonomous loop is being polled.
*/
public Trigger enabled() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So what happens if you want to stop and restart the autonomous routine without restarting code? The loop.enabled().onTrue() triggers won't fire the second time?

double nowTimestamp = timer.get();
return lastTimestamp < nowTimestamp && nowTimestamp >= timeSinceStart;
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this works as intended. lastTimestamp < nowTimestamp will always be true because getAsBoolean always happens after the creation of the BooleanSupplier.

* Returns the event with the given name.
*
* @param eventName The name of the event.
* @return The event with the given name, or an empty optional if the event does not exist.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These docs are wrong

Subsystem driveSubsystem,
EventLoop loop) {
this.name = "Group " + name;
this.trajectories = trajectories;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should probably be an immutable copy of the list

currentSpeeds = table.getStructTopic("CurrentSpeeds", ChassisSpeeds.struct).getEntry(new ChassisSpeeds());
timestamp = table.getDoubleTopic("Timestamp").getEntry(0);

desiredPoseEntry.set(desiredPoseEntry.get());
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the point of this section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was just some debug stuff trying to find a bug I made (I did timer reset instead of restart in the auto traj :/)

@calcmogul
Copy link
Member

The robot project files add a lot of bloat I'd like to avoid. The WPILib VS Code plugin supports vendordeps adding custom examples, so we should look into that.

@oh-yes-0-fps
Copy link
Collaborator Author

I removed the example project for now as it should either be in its own repo or inside the vendor dep, my offseason code can be used as a preliminary example of the trigger features

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