Add commands v3 documentation pages - #3339
Conversation
sciencewhiz
left a comment
There was a problem hiding this comment.
Here's some initial comments. Also update new for 2027 to link to the documentation.
|
|
||
| .. tab-set-code:: | ||
|
|
||
| ```java |
There was a problem hiding this comment.
To improve maintainability, lets make these and all other "complete" code snippets into snippets in allwpilib and reference via RLIs.
There was a problem hiding this comment.
Yup. I plan on moving them when the code snippets are approved here. It's annoying to reference them across repos
Removed a lot of unnecessary tab-set-code and replaced others with manual tab-sets with descriptive tab labels
Co-authored-by: Dan Katzuv <31829093+katzuv@users.noreply.github.com>
|
@codex review |
sciencewhiz
left a comment
There was a problem hiding this comment.
A few more comments, haven't been able to get through everything yet
This should update the 2027 overview to link to the documentation instead of the confernce/design doc.
The examples page should be updated with the commands v3 examples
| @@ -0,0 +1,83 @@ | |||
| # State Machines with Commands | |||
There was a problem hiding this comment.
I think this article could benefit from a more complex example that demonstrates why State machines are beneficial for complex commands. The existing code example seems like something that could easily be done without a state machine
| @@ -0,0 +1,83 @@ | |||
| # State Machines with Commands | |||
|
|
|||
| The `StateMachine <https://github.wpilib.org/allwpilib/docs/beta/java/org/wpilib/command3/StateMachine.html>`__ class provides a way to define complex behavior as a series of states and transitions. Each state in a state machine runs a single ``Command``, and transitions define when the state machine should move from one state to another. | |||
There was a problem hiding this comment.
Use md style links throughout https://docs.wpilib.org/en/stable/docs/contributing/frc-docs/style-guide.html#external-links
|
|
||
| Mechanisms should be declared as ``public final`` fields in the robot class and initialized in the field declaration or in the constructor. The former makes the code a little more concise, while the latter allows for flexibility if different mechanism implementations exist. | ||
|
|
||
| .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/main/wpilibjExamples/src/main/java/org/wpilib/examples/rebuiltcmdv3/Robot.java |
There was a problem hiding this comment.
use the :lines: and :lineno-match: feature to remove boilerplate like the license and and package. For things in the WPILib repository, we usually start on line 7 for that reason. https://docs.wpilib.org/en/stable/docs/contributing/frc-docs/style-guide.html#rli-remote-literal-include
| 2. ``IntakeWrist``, for controlling the deployment of the intake | ||
| 3. ``Intake``, which combines both the rollers and the wrist | ||
|
|
||
| .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/main/wpilibjExamples/src/main/java/org/wpilib/examples/rebuiltcmdv3/mechanisms/Intake.java |
There was a problem hiding this comment.
Three long code blocks right after each other run together. Add a header for each one, and consider putting them in the same order as the list above
|
|
||
| .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/main/wpilibjExamples/src/main/java/org/wpilib/examples/rebuiltcmdv3/opmodes/auto/SweepAuto.java | ||
|
|
||
| ## Mechanism-level Commands |
There was a problem hiding this comment.
Would it make sense to put this right after mechanisms?
| ``` | ||
|
|
||
|
|
||
| ## Multi-Mechanism Commands |
|
|
||
| ### Greedy Loops (Compile-time) | ||
|
|
||
| If you write a ``while`` loop in a command that is missing a ``coroutine.yield()`` call, the WPILib compiler plugin will issue an error. This is because a loop that never yields will starve the rest of the robot program, preventing other commands from running and sensor data from being updated. |
There was a problem hiding this comment.
For the issues that cause a compile time error, include the error message, since that's what people would be searching for
Note that some docs reference not-yet-committed WPILib changes (wpilibsuite/allwpilib#9207)