Skip to content

Conversation

@w-reynolds
Copy link
Contributor

In Organizing Command Based Robot Projects in the Command-Based Programming Section.
The C++ example code for parsing a percentage into the runIntakeCommand is missing (double percentage) .
Also numerous compiler type conversions from int to double will be required because speeds are entered as 1 and 0 instead of 1.0 and 0.0 in many of the examples in both C++ and Java throughout the section.


```c++
frc2::CommandPtr Intake::RunIntakeCommand() {
frc2::CommandPtr Intake::RunIntakeCommand(double percent) {
Copy link
Member

Choose a reason for hiding this comment

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

Not having the parameter isn't necessarily an oversight: it's quite common to have hardcoded/constants for duty cycles that don't need to change.

Besides: the technical term used in other places is duty cycle; this should match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thinking showing an example with the ability to supply percentage or reverse percentage at binding time is a great extension to hard coded constants. I know these docs are used by many beginner programmers (myself included) that are trying to get their head around command based programming, so all I was doing is correcting the existing code so that it would work and match the Java example. I know from personal experience there is nothing worse when you are learning to code and the example code supplied doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

there is nothing worse when you are learning to code and the example code supplied doesn't work

Agreed

The changes from ints to doubles is great.

My gripe is with the addition of the parameter; especially if it's done only in one of the examples.

Copy link
Collaborator

@sciencewhiz sciencewhiz Jul 4, 2025

Choose a reason for hiding this comment

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

My gripe is with the addition of the parameter; especially if it's done only in one of the examples.

I'm having trouble following. The java example for the same code block has the percent parameter, and the text right above it references the percent parameter, so it's currently inconsistent to not have the percent parameter and this makes it consistent..

If you think there's a bigger issue with the article, please make a PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's exactly what I was fixing. I think the article is just fine. I'm for leaving the examples with parameters. It's the natural extension from hard coded constants. Although some intakes may run at a fixed speed, there are intakes that run at many different speeds. Ours this year had four speeds including one in the opposite direction.

Now we just need to add the C++ example code for the next code samples further down in that same doc. It's been to do since CommandPtr has been around.

@sciencewhiz sciencewhiz merged commit e981dae into wpilibsuite:main Jul 4, 2025
9 checks passed
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.

3 participants