-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
This will have to wait for a stabilization of the frontend/app on how it emits event markers in the trajectory json |
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. |
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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; | ||
} | ||
}); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :/)
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. |
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 |
Removed old choreo command api