wpilibsuite / frc-docs

Official FRC Documentation powered by Read the Docs
https://docs.wpilib.org
Other
149 stars 264 forks source link

Example code in "Using Motor Controllers with Code" needs improvement #1385

Open Billfred opened 3 years ago

Billfred commented 3 years ago

As it sits, the example code snippet on this page is not friendly to those new to programming. Consider, if you will:

Spark spark = new Spark(0); // 0 is the RIO PWM port this is connected to

This reads dangerously close to Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo; while grammatically correct, it takes far too much expertise to understand what's really going on.

To make this into actionable suggestions:

  1. The name for the Spark in question should be "demoSpark" (and similarly, "demoVictor" in the Victor SP example).
  2. There should be some indication of where these lines of code live in the program, or at least a link to more fleshed out example code; as it sits, only drivetrains have some resources through the link in the first paragraph. Other critical robot elements--intakes, conveyors, shooters, arms, etc--that can rely on simply spinning a solitary motor are out in the cold.
jasondaming commented 3 years ago

I completely agree with 1

2 I think is tricky as advising where that code goes really depends on what it is for and if using command or non command. Other than advising that this needs to happen during initialization what else would you have us do? I am not sure here is the right place for an example unless it was super concise and I am not sure that would give what you want.

Maybe we should also have an additional example that is Hatchbot, but not using the command framework.

I think what would be ideal here is when we get more of the extended Zero to Robot stuff done, which would have something like programming an "intake" or something and we could also link to that.

UserC2 commented 6 months ago

As it sits, the example code snippet on this page is not friendly to those new to programming. Consider, if you will:

Spark spark = new Spark(0); // 0 is the RIO PWM port this is connected to

This reads dangerously close to Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo; while grammatically correct, it takes far too much expertise to understand what's really going on.

To make this into actionable suggestions:

  1. The name for the Spark in question should be "demoSpark" (and similarly, "demoVictor" in the Victor SP example).
  2. There should be some indication of where these lines of code live in the program, or at least a link to more fleshed out example code; as it sits, only drivetrains have some resources through the link in the first paragraph. Other critical robot elements--intakes, conveyors, shooters, arms, etc--that can rely on simply spinning a solitary motor are out in the cold.

You could name it motor to be more concise