Commit f7bfc04
Improve motor controller code examples for clarity (#3144)
* Improve motor controller code examples for clarity
- Changed confusing variable names (Spark spark -> intakeMotor)
- Used different PWM ports (0 and 1) to avoid confusion
- Added descriptive comments for each line
- Added 'Basic Usage' section header
- Added important note explaining set() range (-1.0 to 1.0)
- Added 'Where to Put This Code' section with examples for:
- Command-Based programs (subsystem class)
- Timed Robot programs (Robot class with robotInit/teleopPeriodic)
- Added 'Common Use Cases' section listing real mechanisms:
- Intakes, shooters, conveyors, arms/elevators, climbers
- Links to drivetrain classes and WPILib examples
Fixes #1385
* Update source/docs/software/hardware-apis/motors/using-motor-controllers.rst
Co-authored-by: Dan Katzuv <[email protected]>
* Address review feedback on motor controller examples
Changes per reviewer feedback:
1. Removed confusing line about PWM controllers being controlled the
same as CAN controllers (sciencewhiz comment on line 7)
2. Deleted entire "Basic Usage" section as it was redundant with the
"Where to Put This Code" section (sciencewhiz comment on line 11).
The Basic Usage examples didn't add value since the Command-Based
and Timed Robot examples show declaration and usage more clearly.
3. Moved the set() range explanation (important box) up to right after
the note about Spark/VictorSP, so it's not lost with the deletion
of Basic Usage section.
4. Fixed C++ motor controller declaration in Timed Robot example
(sciencewhiz comment on line 162):
- Changed from std::unique_ptr with make_unique in RobotInit()
- To direct member variable initialized in initializer list
- This matches the recommended pattern used in Command-Based example
- Removed RobotInit() method as it's no longer needed
5. Updated CAN motor controllers vendors list (sciencewhiz comment on
line 195):
- Added specific examples (Talon FX, SPARK MAX/FLEX)
- Added Redux Robotics
- Changed "handful" to just listing vendors with "and others"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix Java joystick declaration bug in TimedRobot example
Added missing joystick declaration and initialization in Java example.
The code was referencing m_joystick.getRawButton(1) but never declared
or initialized the joystick object, which would cause a compilation error.
Added:
- private Joystick m_joystick; member variable
- m_joystick = new Joystick(0); initialization in robotInit()
This matches the C++ and Python examples which already had the joystick
properly declared and initialized.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Remove Redux
---------
Co-authored-by: Dan Katzuv <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: sciencewhiz <[email protected]>1 parent 465aa23 commit f7bfc04
File tree
1 file changed
+125
-14
lines changed- source/docs/software/hardware-apis/motors
1 file changed
+125
-14
lines changedLines changed: 125 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
11 | 74 | | |
12 | 75 | | |
13 | 76 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
18 | 97 | | |
19 | 98 | | |
20 | 99 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
25 | 117 | | |
26 | 118 | | |
27 | 119 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
32 | 131 | | |
33 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
34 | 145 | | |
35 | 146 | | |
36 | | - | |
| 147 | + | |
0 commit comments