-
Notifications
You must be signed in to change notification settings - Fork 611
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
[cmd] After
Command Decorators
#7086
base: main
Are you sure you want to change the base?
[cmd] After
Command Decorators
#7086
Conversation
This reverts commit 3c21556.
Ignore the WIP commit that got in by accident, oopsie. |
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
After
Command Decorators After
Command Decorators
* @param condition the condition to wait for | ||
* @return the decorated command | ||
*/ | ||
public SequentialCommandGroup after(BooleanSupplier condition) { |
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.
"after" might be a bit confusing, since we also have decorators that enforce command ordering.
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 originally had waitFor
but js suggested after
, i can see both making sense
It might be clearer to implement these factories in terms of public SequentialCommandGroup after(BooleanSupplier condition) {
// if we want this to bypass the `WaitUntilCommand` if the condition is already true,
// we can use a conditional command but it proposes some compositional issues
- return new SequentialCommandGroup(new WaitUntilCommand(condition), this);
+ return beforeStarting(Commands.wait(condition));
} CommandPtr CommandPtr::After(std::function<bool()> condition) && {
- AssertValid();
- std::vector<std::unique_ptr<Command>> temp;
- temp.emplace_back(std::make_unique<WaitUntilCommand>(std::move(condition)));
- temp.emplace_back(std::move(m_ptr));
- m_ptr = std::make_unique<SequentialCommandGroup>(std::move(temp));
- return std::move(*this);
+ return std::move(*this).BeforeStarting(cmd::Wait(condition));
} |
wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Joseph Eng <[email protected]>
Co-authored-by: Joseph Eng <[email protected]>
Adds
After
andAfterTime
to commands.These are being upstreamed from choreolib CommandExt
This allows you to do
trajCmd.after(gampiece().negate())
to wait to move until the robot shoots its gamepiece.