-
Notifications
You must be signed in to change notification settings - Fork 287
Add Commands v3 documentation outline (Phase 2) #3166
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
base: 2027
Are you sure you want to change the base?
Conversation
e7021a1 to
d7fa6b9
Compare
Move all Commands v2 documentation files into a commands-v2/ subdirectory to prepare for Commands v3 documentation. This is Phase 1 of the Commands v3 documentation project. Changes: - Move 12 v2 documentation files to commands-v2/ subdirectory (preserving git history) - Create new commands-v2/index.rst as landing page for v2 docs - Update main commandbased/index.rst to serve as high-level framework chooser - Update 20 files with corrected cross-references to new v2 locations - Add 12 redirects to ensure old URLs continue working This reorganization addresses feedback on PR wpilibsuite#3095 to split the work into manageable phases. The next phase will add v3 documentation structure with TODO placeholders. Related to wpilibsuite#3095
Move all Commands v2 documentation files into a commands-v2/ subdirectory to prepare for Commands v3 documentation. This is Phase 1 of the Commands v3 documentation project. Changes: - Move 12 v2 documentation files to commands-v2/ subdirectory (preserving git history) - Create new commands-v2/index.rst as landing page for v2 docs - Update main commandbased/index.rst to serve as high-level framework chooser - Update 20 files with corrected cross-references to new v2 locations - Add 12 redirects to ensure old URLs continue working This reorganization addresses feedback on PR wpilibsuite#3095 to split the work into manageable phases. The next phase will add v3 documentation structure with TODO placeholders. Related to wpilibsuite#3095
Create skeleton structure for Commands v3 documentation with section headers and TODO notes describing what content should go in each section. This phase establishes the documentation organization for review before content is written. Files created: - index.rst: Landing page with overview and quick examples - what-is-commands-v3.rst: Conceptual foundation and core concepts - getting-started.rst: Hands-on tutorial for first v3 program - mechanisms.rst: Deep dive into Mechanisms (v3's Subsystems) - commands-and-coroutines.rst: Core command creation and coroutine API - async-await-patterns.rst: Async/await helpers for orchestration - command-compositions.rst: Traditional composition groups - binding-commands-to-triggers.rst: Button bindings and triggers - priorities-and-interrupts.rst: Priority system and interruption - structuring-v3-project.rst: Code organization best practices - testing-and-simulation.rst: Testing commands with simulation - telemetry-and-debugging.rst: Enhanced telemetry and debugging - migration-from-v2.rst: Migration guide from v2 to v3 - advanced-topics.rst: Advanced patterns and edge cases Each file contains: - Section headers outlining the article structure - TODO directives describing what content should be written - Guidance for future content writers on what to include No actual tutorial content or code examples are included - this is purely structural planning for review. Related to wpilibsuite#3095 Related to wpilibsuite#3165
d7fa6b9 to
d7aa645
Compare
|
|
||
| .. todo:: | ||
| - Recap the command-based pattern (commands + mechanisms for resource management) | ||
| - Explain what's fundamentally different in v3 vs v2 |
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 think this page should focus on v3 standalone. Comparisons with v2 and v1 can live in the migration docs
| - Recap the command-based pattern (commands + mechanisms for resource management) | ||
| - Explain what's fundamentally different in v3 vs v2 | ||
| - Why imperative style was chosen over declarative composition | ||
| - Brief history: evolution from v1 → v2 → v3 |
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.
Ditto
| **Learning Curve Issues:** | ||
| - v2 requires understanding functional composition, decorators, and lambda chaining | ||
| - New programmers struggle with splitting logic across initialize/execute/isFinished | ||
| - Common mistake: writing blocking loops in execute() that stall the scheduler |
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.
The more fundamental point with the learning curve is transitioning from a very basic "programmer's first program"-style project to something that can coordinate multi-mechanism actions and events. Simple imperative code can be dressed up, in a sense, by wrapping it in the command-related functions and changing some method calls to use coroutines (eg Thread.sleep or direct subroutine invocations). We don't need to go into details on this page, since it's a summary, but it's important to mention the on-ramp.
For example, a very simple drive-in-a-square routine:
void driveSquare() {
for (int i = 0; i < 4; i++) {
right.set(1);
left.set(1);
Thread.sleep(2500);
right.set(1);
left.set(-1);
Thread.sleep(600);
}
}
void driveManySquares(int count) {
for (int i = 0; i < count; i++) {
driveSquare();
}
}This can be lifted to a command almost entirely in place:
Command driveSquare() {
return run(coroutine -> {
for (int i = 0; i < 4; i++) {
right.set(1);
left.set(1);
// Thread.sleep(2500);
coroutine.wait(Milliseconds.of(2500));
right.set(1);
left.set(-1);
// Thread.sleep(600);
coroutine.wait(Milliseconds.of(600));
}
}).named("Drive Square");
}
Command driveManySquares(int count) {
return run(coroutine -> {
for (int i = 0; i < count; i++) {
coroutine.await(driveSquare());
}
}).named("Drive " + count + " Squares");
}|
|
||
| .. todo:: | ||
| - What are coroutines (functions that can pause and resume) | ||
| - How Java's ``Continuation`` API enables this (internal implementation detail) |
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.
Should inner implementation details like this be included? Doesn't seem like it'd be relevant to people being introduced to the library
source/docs/software/commandbased/commands-v3/what-is-commands-v3.rst
Outdated
Show resolved
Hide resolved
| Provide an overview of what coroutines are and how v3 uses them. Cover: | ||
| - High-level explanation of coroutines for teams unfamiliar with the concept | ||
| - How coroutines enable sequential command logic without state machines | ||
| - The generator/yield paradigm |
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's not really a "generator" paradigm, since commands are void-returning.
| - How coroutines enable sequential command logic without state machines | ||
| - The generator/yield paradigm | ||
| - How the scheduler executes coroutine commands | ||
| - Comparison to v2's initialize/execute/end/isFinished pattern |
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.
v2 comparisons - probably best to leave in the migration guide
source/docs/software/commandbased/commands-v3/commands-and-coroutines.rst
Show resolved
Hide resolved
source/docs/software/commandbased/commands-v3/commands-and-coroutines.rst
Show resolved
Hide resolved
| - Cleanup and resource management | ||
| - How lifecycle differs from v2 commands | ||
|
|
||
| ## Command Properties |
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.
This seems very similar to the "Command Creation Patterns" above
- Remove v2 comparisons from what-is-commands-v3.rst - Update learning curve section to focus on imperative on-ramp - Remove Java Continuation API implementation detail - Remove 'Key Improvements Over v2' and 'Comparison' sections - Update structuring to not recommend RobotContainer pattern - Add Scheduler parameter note for testing - Update telemetry to focus on protobuf serialization and AdvantageScope - Remove CPU usage tracking (not implemented) - Clarify breakpoint debugging only in sim/unit tests - Remove incremental migration recommendation from migration guide - Note vendor library compatibility is up to vendors - Remove v2 comparisons from mechanisms.rst - Note automatic mechanism registration - Document periodic function patterns - Reorder async-await sections (awaitAll before await) - Clarify awaitAny cancels other commands
This commit addresses the remaining 13 comments (beyond the initial 30) on PR wpilibsuite#3166. ## binding-commands-to-triggers.rst (2 comments) - Removed "How v3 triggers compare to v2 triggers" (migration guide content) - Added note about potential updates from allwpilib PR #8366 ## advanced-topics.rst (4 comments) - Removed "Dynamic Command Generation" section entirely - Removed "Resource pooling and management" from Advanced Async Patterns - Changed "Priority conflicts and circular dependencies" to just "Priority conflicts" - Removed "Memory leaks and resource exhaustion" from Edge Cases ## command-compositions.rst (2 comments) - Removed "How v3 compositions compare to v2 command groups" (migration guide content) - Added detailed explanation of parallel group implementation: - All groups (parallel/race/deadline) are parallel groups with different configs - Parallel groups have _n_ required and _m_ optional commands - Traditional parallel: _m_ = 0, Race: _n_ = 0, Deadline: both nonzero ## commands-and-coroutines.rst (5 comments) - Changed "generator/yield paradigm" to "yield paradigm" (commands are void-returning) - Removed "Comparison to v2's initialize/execute/end/isFinished pattern" - Added compiler plugin note: checks for `yield` in while-loops only - Added compiler plugin note: checks for unreachable code after `park()` - Removed "Where properties should be set" from Command Properties (overlaps with creation patterns) - Removed "How lifecycle differs from v2 commands" from Command Lifecycle 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed "Unexpected indentation" errors in three files: - command-compositions.rst: Flattened nested bullets describing parallel group implementation into single bullet - structuring-v3-project.rst: Flattened nested directory tree into single line description - telemetry-and-debugging.rst: Flattened nested bullets under "Scheduler events" into single bullet All ERROR-level indentation issues resolved. Build now passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Resolved conflicts in: - source/docs/software/commandbased/index.rst: Removed v2/v3 comparison content, kept commands-v3/index in toctree - source/docs/software/commandbased/commands-v2/index.rst: Removed note referencing Commands v3 Also includes upstream changes: - source/docs/hardware/hardware-basics/status-lights-ref.rst updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move fork() section before await() in async-await-patterns.rst - Clarify timeout pattern description in Practical Patterns - Add v2 comparison sections to migration guide: - History: Evolution of Command-Based Programming - Telemetry and Debugging Changes - Testing and Simulation Changes - Add missing concept mappings (periodic, priority levels) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| .. todo:: | ||
| - Java 21+ requirement (for Continuation API support) | ||
| - WPILib 2027+ installation | ||
| - Basic Java knowledge (variables, methods, loops) |
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.
Is coroutine knowledge necessary?
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.
helpful but I don't think it is required. Maybe depends on at what level we call coroutine knowledge. @SamCarlberg ?
source/docs/software/commandbased/commands-v3/getting-started.rst
Outdated
Show resolved
Hide resolved
| .. todo:: | ||
| **Creating a New Project:** | ||
| - Use WPILib VS Code project creator | ||
| - Select "Command Robot (v3)" template |
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.
This template doesn't exist yet, right?
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.
Yes but this is an outline
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.
right, just figuring out what's needed that's outside of docs
| - Single-threaded requirement warning | ||
|
|
||
| **Example RLI:** | ||
| - Complete Robot.java from a wpilibjExamples project |
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.
This needs to be created, right?
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.
Yes but this is an outline
| - Viewing running commands | ||
| - Command status indicators | ||
|
|
||
| ## Common Mistakes and Fixes |
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.
This feels like a separate article
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 think we should wait and see how big this section gets. If it starts to dominate the page absolutely but I am not sure it will at this point.
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'm thinking even if it doesn't dominate the page, it will be more easily found if it isn't hidden in getting started
- Change v3 recommendation to alpha testing request - Remove redundant Java 21 prerequisite (covered by WPILib 2027+) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
.claude/settings.local.json
Outdated
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.
This file shouldn't be commited
| ## Encapsulation Best Practices | ||
|
|
||
| .. todo:: | ||
| Explain encapsulation principles for Mechanisms. Cover: |
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.
Maybe also cover an example of something that doesn't need to be encapsulated in a mechanism, like a vision system.
| - Viewing running commands | ||
| - Command status indicators | ||
|
|
||
| ## Common Mistakes and Fixes |
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'm thinking even if it doesn't dominate the page, it will be more easily found if it isn't hidden in getting started
| - Show hardware encapsulation pattern | ||
| - Default command for stopping motors when idle | ||
|
|
||
| ## Writing Your First Command |
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.
Should have a what is a command, similar to what is a mechanism
| - Available trigger sources (buttons, joysticks, sensors, custom) | ||
| - High-level syntax for creating and binding triggers | ||
|
|
||
| ## Button Bindings |
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.
Maybe something about the CommandHID classes vs regular HIS classes.
| - Type safety and units for constants | ||
| - Example constants organization patterns | ||
|
|
||
| ## Testing Structure |
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.
This feels like it might be better in the testing and simulation article, or at least the later topics in this section
| - New v3 package names and locations | ||
| - Renamed classes and methods | ||
| - Deprecated v2 APIs and their v3 equivalents | ||
| - How to add v3 dependencies to build.gradle/pom.xml |
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.
Shouldn't this be how to install v3 vendordep?
| - Why each version was created and what problems it solved | ||
| - How v3 addresses the learning curve issues with v2's declarative composition | ||
|
|
||
| ## Concept Mapping |
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.
This feels like it should be higher in the TOC before talking about the migration strategy
| - Real-time responsive commands with background processing | ||
| - Describe complex scenarios and how to implement them with v3 features | ||
|
|
||
| ## Edge Cases and Gotchas |
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'd move this into its own article and not hide in advanced topics
- Add vision system example to mechanisms.rst (things that don't need Mechanisms) - Move Common Mistakes section to new troubleshooting.rst article - Add 'What is a Command' intro to getting-started.rst - Add CommandHID vs regular HID classes info to triggers article - Move Testing Structure section from structuring to testing-and-simulation.rst - Update build.gradle/pom.xml reference to vendordep in migration guide 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This PR adds the structural outline for Commands v3 documentation with section headers and TODO notes describing what content should go in each section. This is Phase 2 of the Commands v3 documentation project, addressing feedback from @SamCarlberg on PR #3095.
This PR is for reviewing the documentation structure and organization only - no actual content is included yet.
Dependencies
This PR builds on PR #3165 (Phase 1: v2 reorganization). Review #3165 first.
Changes
Documentation Structure Created
Created 14 skeleton files in
commands-v3/directory:What's Included in Each File
Each skeleton file contains:
What's NOT Included
Example: what-is-commands-v3.rst
Each file follows this pattern:
Rationale
This phase allows review of:
By reviewing structure first, we can adjust organization before investing time in writing full content.
Based On
This outline is based on:
Next Steps (Phase 3)
After this structure is approved:
Review Focus
Please review:
Statistics
Checklist
Related to #3095
Related to #3165
🤖 Generated with Claude Code