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 command.repeatdly(int count) to both java and c++ #6589

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

Conversation

kytpbs
Copy link
Contributor

@kytpbs kytpbs commented May 6, 2024

Currently, the unit tests fail and there are a lot of print statements for whoever might be checking into this.

The problem is. The exact same function calls create different results between C++ and Java. I may just be the idiot but it seems to require further look into

The debug's are in different commits making it a lot easier to revert them if needed.

@kytpbs kytpbs requested review from a team as code owners May 6, 2024 00:58
Copy link
Contributor

@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.

Overall looks good just a few comments. Dunno why C++ would print stuff out especially since Java doesn't, along with this for printing in C++ its generally better to use fmt::print()

@kytpbs
Copy link
Contributor Author

kytpbs commented May 6, 2024

/format

@KangarooKoala
Copy link
Contributor

This was stated in Discord, but tests are probably failing because of an inconsistent order of when the commands in the internal deadline group are checked, which should be fixed by #6602.

@kytpbs kytpbs force-pushed the add-Command.Repeatdly(int-count) branch 7 times, most recently from c21b4cf to 832d5a0 Compare October 7, 2024 00:50
@kytpbs
Copy link
Contributor Author

kytpbs commented Oct 7, 2024

Thanks to #6602 being merged, the tests pass correctly.

I reverted back the print code and rebased them out for a cleaner history.

@kytpbs kytpbs requested a review from spacey-sooty October 7, 2024 01:17
@kytpbs kytpbs requested a review from Starlight220 October 7, 2024 01:27
Starlight220
Starlight220 previously approved these changes Oct 7, 2024
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Nice! Overall looks good, just a few small things.

@kytpbs
Copy link
Contributor Author

kytpbs commented Oct 10, 2024

fix formatting with rebase + force push:

@kytpbs kytpbs force-pushed the add-Command.Repeatdly(int-count) branch from f0d8608 to b569c8f Compare October 10, 2024 22:05
@kytpbs kytpbs requested a review from Starlight220 October 10, 2024 23:07
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Looks good to me, for what it's worth.

@github-actions github-actions bot added the component: command-based WPILib Command Based Library label Dec 16, 2024
@kytpbs
Copy link
Contributor Author

kytpbs commented Dec 16, 2024

/format

@PeterJohnson PeterJohnson requested review from PeterJohnson and a team as code owners December 16, 2024 14:55
@github-actions github-actions bot added component: wpiutil WPI utility library component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: wpimath Math library component: wpiunits Java units library labels Dec 16, 2024
kytpbs and others added 5 commits December 16, 2024 16:31
also, give better errors

Co-Authored-By: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
I didn't know you could just pass by value by doing this thx @KangarooKoala  for pointing it out.

Co-Authored-By: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
@kytpbs
Copy link
Contributor Author

kytpbs commented Dec 16, 2024

Force pushing to rebase with main and revert the format commit (broke the entire PR lol)

@kytpbs kytpbs force-pushed the add-Command.Repeatdly(int-count) branch 2 times, most recently from 3a36e0d to cd2328e Compare December 16, 2024 15:55
Comment on lines +273 to +274
* Decorates this command to run repeatedly until the given count is reached
* or is interrupted. The decorated command can still be canceled.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should either make Java match C++ or C++ match Java. (I don't have a particularly strong preference on which one)
This also applies to the CommandPtr doc comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would mean we would neet to also change the documentation on the .repeating() function.

IMO, it would be better if this PR didn't have any line removals

Copy link
Contributor

Choose a reason for hiding this comment

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

This would mean we would neet to also change the documentation on the .repeating() function.

How so? I'm just talking about changing the repeatedly(int) doc comments.

Also, the wording that would most match the repeatedly() doc comment (in both Java and C++) is "Decorates this command to run repeatedly, restarting it when it ends, until this command is run the specified number of times or is interrupted. The decorated command can still be canceled."

@kytpbs kytpbs force-pushed the add-Command.Repeatdly(int-count) branch 3 times, most recently from 57ceb5b to 7be3682 Compare December 16, 2024 18:13
kytpbs and others added 2 commits December 17, 2024 22:14
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
@kytpbs kytpbs force-pushed the add-Command.Repeatdly(int-count) branch from 7be3682 to f31b58c Compare December 17, 2024 21:15
Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

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

Great work! There's just a few things left:

  • The Java and C++ doc comments still need to be updated (see this comment).
  • Pick a consistent name for the parameter (repetitions or counts) and make sure the parameter doc comments are the same between Java and C++.

auto command = InstantCommand([&counter] { counter++; }, {}).Repeatedly(3);

scheduler.Schedule(command);
EXPECT_TRUE(scheduler.IsScheduled(command));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
EXPECT_TRUE(scheduler.IsScheduled(command));
EXPECT_EQ(1, counter);

This matches Java and is more useful than the current check.
There's also a few more small changes- Make sure to read the whole comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: command-based WPILib Command Based Library component: hal Hardware Abstraction Layer component: wpilibc WPILib C++ component: wpilibj WPILib Java component: wpimath Math library component: wpiunits Java units library component: wpiutil WPI utility library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants