-
Notifications
You must be signed in to change notification settings - Fork 288
Fix C++ code snipet for runIntakeCommand(double percentage) #3072
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
Conversation
|
|
||
| ```c++ | ||
| frc2::CommandPtr Intake::RunIntakeCommand() { | ||
| frc2::CommandPtr Intake::RunIntakeCommand(double percent) { |
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.
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
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 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.
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.
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.
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.
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.
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.
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.
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
inttodoublewill be required because speeds are entered as1and0instead of1.0and0.0in many of the examples in both C++ and Java throughout the section.