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

[choreolib] Java triggers overhaul #589

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

Conversation

oh-yes-0-fps
Copy link
Collaborator

#469

I messed up and nuked the old pr by changing my forks branches around.
This pr is for the same features as the other.

There is currently only a Java implementation for the new API but if the interface is agreed upon I can also implement a python and c++ version.

I'm still working on a properly thought out example, I want to build it off of the rapid react command base example in wpilib.

for now you can look at my offseason code to get an idea of what the triggers API looks like.

shueja
shueja previously requested changes Aug 27, 2024
Copy link
Collaborator

@shueja shueja left a comment

Choose a reason for hiding this comment

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

This looks good enough to merge except for a spelling issue. However, we should think about what parts of this can become wpilib contributions.

choreolib/src/main/java/choreo/Choreo.java Outdated Show resolved Hide resolved
@oh-yes-0-fps
Copy link
Collaborator Author

oh-yes-0-fps commented Aug 27, 2024

It would be smart to add a wiki page on the pros and cons of triggers vs composition for autos.

Also unsure if the trajectory factory should have methods that return commands directly and don't take AutoLoops to make composition feel more first class.

// no need to make a loop or call `.cmd()`, the only issue is adding too many ways to do things and might confuse ppl
Command traj = factory.trajCmd("ampToMiddle");

@oh-yes-0-fps oh-yes-0-fps changed the title Choreolib triggers overhaul [choreolib] java triggers overhaul Aug 27, 2024
@spacey-sooty
Copy link
Collaborator

This looks good enough to merge except for a spelling issue. However, we should think about what parts of this can become wpilib contributions.

I think TriggerExt should be upstreamed as part of Trigger or at least solid portions of it

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

I think TriggerExt should be upstreamed as part of Trigger or at least solid portions of it

This was discussed in Discord and in some resolved convos in this thread, TriggerExt will not make it to release but can be left in for now to test better syntactic sugar that we can then upstream to wpilib. I think it should remain in for now and be removed later.

@spacey-sooty
Copy link
Collaborator

Closes #468 and #456

@oh-yes-0-fps oh-yes-0-fps marked this pull request as draft September 1, 2024 19:53
Copy link
Collaborator

@spacey-sooty spacey-sooty left a comment

Choose a reason for hiding this comment

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

This needs C++ and Python

choreolib/build.gradle Show resolved Hide resolved
choreolib/s.json Outdated Show resolved Hide resolved
choreolib/src/main/java/choreo/Choreo.java Outdated Show resolved Hide resolved
import java.util.Optional;

/** A trajectory loaded from Choreo. */
public class ChorTrajectory<SampleType extends TrajSample<SampleType>> {
Copy link
Member

@calcmogul calcmogul Sep 18, 2024

Choose a reason for hiding this comment

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

Can ChorTrajectory just be Trajectory? The package already disambiguates it. TrajSample should be TrajectorySample for clarity; letters are cheap.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It being Trajectory was annoying because the intellisense would always put the wpilib trajectory above the choreo one so I would have to arrow key down twice to auto complete it.

Copy link
Member

@calcmogul calcmogul Sep 19, 2024

Choose a reason for hiding this comment

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

Alphabetical sorting over other things is a bad reason to choose the longer name. WPILib doesn't prefix all its classes with underscores to win the sorting race.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its not for alphabetical, its so you start typing it differently, starting with Chor will always pull it up. I agree with banks that its important for this one class. This class will also likely only be used by most users in one place, their trajectory logger lambda.

Copy link
Member

@calcmogul calcmogul Sep 19, 2024

Choose a reason for hiding this comment

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

The entire point of packages is to disambiguate names like this tho, so you can reuse good names from the namespace. Also, who's banks?

I would still like TrajSample renamed to TrajectorySample; it's a trajectory, not a "traj". Again, letters are cheap.

choreolib/test_deploy/idk.chor Outdated Show resolved Hide resolved
cli/choreo-cli-x86_64-pc-windows-msvc.exe Outdated Show resolved Hide resolved
@oh-yes-0-fps
Copy link
Collaborator Author

This needs C++ and Python

Those will come in a future pr, a majority of people use java so getting this out for user tests would be beneficial.

@oh-yes-0-fps oh-yes-0-fps marked this pull request as ready for review September 19, 2024 01:32
* ChorTrajectory}, {@link Boolean})-&gt;void, where the function consumes a trajectory and a
* boolean indicating whether the trajectory is starting or finishing.
* Trajectory}, {@link Boolean})-&gt;void, where the function consumes a trajectory and a boolean
* indicating whether the trajectory is starting or finishing.
*/
public interface TrajectoryLogger<SampleType extends TrajSample<SampleType>>
Copy link
Member

Choose a reason for hiding this comment

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

TrajSample should be TrajectorySample.

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.

[lib] choreolib should use "choreo" package, not "com.choreo.lib"
4 participants