Skip to content

Conversation

@jasondaming
Copy link
Member

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:

  1. index.rst - Landing page with overview, quick examples, and navigation
  2. what-is-commands-v3.rst - Conceptual foundation and core concepts
  3. getting-started.rst - Hands-on tutorial for first v3 program
  4. mechanisms.rst - Deep dive into Mechanisms (v3's Subsystems)
  5. commands-and-coroutines.rst - Core command creation and coroutine API
  6. async-await-patterns.rst - Async/await helpers for orchestration
  7. command-compositions.rst - Traditional composition groups
  8. binding-commands-to-triggers.rst - Button bindings and triggers
  9. priorities-and-interrupts.rst - Priority system and interruption
  10. structuring-v3-project.rst - Code organization best practices
  11. testing-and-simulation.rst - Testing commands with simulation
  12. telemetry-and-debugging.rst - Enhanced telemetry and debugging
  13. migration-from-v2.rst - Migration guide from v2 to v3
  14. advanced-topics.rst - Advanced patterns and edge cases

What's Included in Each File

Each skeleton file contains:

  • Title and purpose: Brief description of what the article covers
  • Section headers: Organized outline of topics
  • TODO directives: Detailed descriptions of what content should be written in each section
  • Guidance for writers: Clear direction on examples, explanations, and code samples needed

What's NOT Included

  • No actual tutorial content or detailed explanations
  • No code examples or RLIs (those come in Phase 3)
  • Just structural planning and content descriptions

Example: what-is-commands-v3.rst

Each file follows this pattern:

# What is Commands v3?

.. todo:: This article introduces the conceptual foundation...

## Introduction

.. todo::
   - Recap the command-based pattern
   - Explain what's fundamentally different in v3 vs v2
   - Why imperative style was chosen
   - Brief history: v1 → v2 → v3

## The Problem v3 Solves

.. todo::
   **Learning Curve Issues:**
   - v2 requires understanding functional composition...
   (detailed description of what to write)

Rationale

This phase allows review of:

  • Documentation organization: Is the article structure logical?
  • Topic coverage: Are all important v3 features covered?
  • Article scope: Is each article focused on a clear topic?
  • Content descriptions: Are TODO notes clear enough for future writers?

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:

  1. Create example projects in wpilibjExamples with verified code
  2. Write content article-by-article with RLIs to examples
  3. Submit content in small reviewable PRs (2-3 articles at a time)

Review Focus

Please review:

  • Is the article organization logical?
  • Are any important topics missing?
  • Are any articles too broad or too narrow in scope?
  • Are the TODO descriptions clear for future content writers?
  • Does the structure match what teams need to learn v3?

Statistics

  • 14 files created
  • 1,213 lines added
  • ~50 KB total
  • Average 86 lines per file

Checklist

Related to #3095
Related to #3165

🤖 Generated with Claude Code

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

.. todo::
- Recap the command-based pattern (commands + mechanisms for resource management)
- Explain what's fundamentally different in v3 vs v2
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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

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
Copy link
Member

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
Copy link
Member

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

- Cleanup and resource management
- How lifecycle differs from v2 commands

## Command Properties
Copy link
Member

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

jasondaming and others added 5 commits November 19, 2025 06:45
- 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is coroutine knowledge necessary?

Copy link
Member Author

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 ?

.. todo::
**Creating a New Project:**
- Use WPILib VS Code project creator
- Select "Command Robot (v3)" template
Copy link
Collaborator

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?

Copy link
Member Author

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

Copy link
Collaborator

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
Copy link
Collaborator

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?

Copy link
Member Author

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
Copy link
Collaborator

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

Copy link
Member Author

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.

Copy link
Collaborator

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>
Copy link
Collaborator

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:
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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

jasondaming and others added 2 commits November 30, 2025 08:20
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants