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

Add an Either Command to the pathplanner events #609

Open
mmilunicmobile opened this issue Feb 17, 2024 · 4 comments
Open

Add an Either Command to the pathplanner events #609

mmilunicmobile opened this issue Feb 17, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mmilunicmobile
Copy link

Something that my team is working on is conditional pathing based on whether we have a game piece in the robot. We are currently making named commands that follow one sequence of paths if we have a piece and a different set if we do not see a piece. This saves time not having to go back.

A solution to this would be including an "either" group in addition to the current "sequential", "parallel", etc. groups. This could allow for much more dynamic branching in auto. Boolean suppliers could be registered with the named commands static class as well.

@mmilunicmobile mmilunicmobile added the enhancement New feature or request label Feb 17, 2024
@NickAnastasoff
Copy link

id love to see this! i came across conditional commands which could help https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj2/command/ConditionalCommand.html

@mmilunicmobile
Copy link
Author

After thinking about this for a bit, a hack that you could kinda run would be using a sequential command group inside of a race command group with one other command. The other command could be something like "hasPiece", and when the command starts, it could immediately check if there is a piece, and either end immediately if there is no piece, or continue forever if there is one. This has the effect of the items in the sequential command group only running if there is a piece. You could then make a "!hasPiece" that does the opposite and put that in a race sequence immediately after. This would give you an equivalent to the Either. Since very very few teams would ever use this, and adding the ability to register boolean suppliers is a huge undertaking, I think that this solution would work for now, and we're probably gonna try and see if this works.

@mmilunicmobile
Copy link
Author

mmilunicmobile commented Mar 22, 2024

This is an example of the sort of composition @NickAnastasoff:

Screenshot 2024-03-21 at 10 39 33 PM

(You would put the "hasPiece" and "!hasPiece" commands in the empty NamedCommand spots.)

@NickAnastasoff
Copy link

I think at this point it would make more sense to just create the autos in code with the PathPlanner.fromPathFile function, although that is a cool way to do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants