Skip to content

Commit 4cd3348

Browse files
committed
Address all PR review comments
- 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
1 parent d8d0e49 commit 4cd3348

File tree

7 files changed

+79
-107
lines changed

7 files changed

+79
-107
lines changed

source/docs/software/commandbased/commands-v3/async-await-patterns.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@
1414
- High-level mental model for how it works with the scheduler
1515
- Relationship to coroutines and yield()
1616

17-
## await()
18-
19-
.. todo::
20-
Explain the await() function in detail. Cover:
21-
- What await(command) does: schedule a command and wait for it to complete
22-
- How await() blocks the calling command until the child completes
23-
- Requirements and priority handling with awaited commands
24-
- What happens if the awaited command is interrupted
25-
- What happens if the parent command is interrupted
26-
- Return values and status from awaited commands
27-
- Examples of await() patterns (describe what examples should show)
28-
2917
## awaitAll()
3018

3119
.. todo::
@@ -36,15 +24,29 @@
3624
- Requirements management across multiple parallel commands
3725
- Error and interruption handling
3826
- Performance implications of parallel execution
27+
- Easier to explain as a blocking version of fork()
3928
- Examples of awaitAll() patterns (describe what examples should show)
4029

30+
## await()
31+
32+
.. todo::
33+
Explain the await() function in detail. Cover:
34+
- What await(command) does: schedule a command and wait for it to complete
35+
- How await() blocks the calling command until the child completes
36+
- Requirements and priority handling with awaited commands
37+
- What happens if the awaited command is interrupted
38+
- What happens if the parent command is interrupted
39+
- Return values and status from awaited commands
40+
- Examples of await() patterns (describe what examples should show)
41+
4142
## awaitAny()
4243

4344
.. todo::
4445
Explain the awaitAny() function in detail. Cover:
4546
- What awaitAny(commands) does: wait until any command completes
4647
- Race condition semantics: which command "wins"
47-
- What happens to other commands when one completes
48+
- **Important**: awaitAny() cancels all other still-running commands when one completes
49+
- Both await functions are blocking
4850
- Use cases for awaitAny() (timeouts, alternative paths, etc.)
4951
- How interruption is handled
5052
- Differences from race groups in composition

source/docs/software/commandbased/commands-v3/mechanisms.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
.. todo::
99
Describe how to create a Mechanism class. Cover:
1010
- Basic Mechanism class structure and constructor
11-
- How Mechanisms differ philosophically from v2 Subsystems
1211
- When to create a Mechanism vs. other organizational patterns
1312
- Naming conventions for Mechanism classes
1413
- Where Mechanism classes should live in the project structure
15-
- How to register Mechanisms with the command scheduler (if needed)
14+
- Note: Mechanisms are automatically registered with the scheduler in the base class constructor
1615

1716
## Encapsulation Best Practices
1817

@@ -40,8 +39,10 @@
4039

4140
.. todo::
4241
Describe periodic update patterns in Mechanisms. Cover:
43-
- Whether Mechanisms have a periodic() method like v2 Subsystems
44-
- If not, how to handle periodic updates in v3
42+
- Mechanisms don't have a built-in periodic() method
43+
- Manual periodic functions can be plumbed if needed using `Scheduler.addPeriodic()`
44+
- Alternatively, call periodic functions manually in `robotPeriodic()`
45+
- Example patterns for sensor refresh methods
4546
- When to use periodic updates vs. command-based updates
4647
- Performance considerations for periodic operations
4748
- Common patterns like updating telemetry, processing sensor data, safety checks

source/docs/software/commandbased/commands-v3/migration-from-v2.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Migrating from Commands v2 to v3
22

33
.. todo::
4-
This article guides teams through migrating an existing Commands v2 codebase to v3. Migration can be done incrementally, and this article should help teams plan their migration strategy, understand the key differences, and avoid common pitfalls. This is a critical resource for established teams.
4+
This article guides teams through migrating an existing Commands v2 codebase to v3. This article should help teams plan their migration strategy, understand the key differences, and avoid common pitfalls. This is a critical resource for established teams.
55

66
## Migration Strategy
77

88
.. todo::
99
Provide high-level guidance on planning a v2-to-v3 migration. Cover:
1010
- Should teams migrate? (pros/cons, when to migrate vs. stay on v2)
11-
- Migration approaches: full rewrite vs. incremental migration
12-
- Incremental migration: v2 and v3 can coexist in the same project
11+
- Migration approach: full rewrite recommended
1312
- What to migrate first (start with simple mechanisms/commands)
1413
- Testing strategy during migration
1514
- Timeline considerations (offseason vs. competition season)
@@ -25,7 +24,7 @@
2524
- Deprecated v2 APIs and their v3 equivalents
2625
- How to add v3 dependencies to build.gradle/pom.xml
2726
- Version compatibility and requirements
28-
- Vendor library compatibility with v3
27+
- Note: Vendor library compatibility with v3 is up to individual vendors
2928

3029
## Concept Mapping
3130

source/docs/software/commandbased/commands-v3/structuring-v3-project.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,33 @@
88
.. todo::
99
Describe the recommended file and package organization for v3 projects. Cover:
1010
- Top-level package structure
11-
- Where Mechanisms should live
11+
- Where Mechanisms should live (mechanisms/ directory with subdirectories per mechanism)
1212
- Where command functions/classes should be organized
1313
- Organization of constants and configuration
1414
- Separation of concerns between different code areas
15-
- How v3 structure differs from v2 structure
16-
- Example directory tree showing recommended organization
15+
- Example directory tree:
16+
- Autos.java
17+
- ControllerBindings.java
18+
- Main.java
19+
- Robot.java
20+
- mechanisms/
21+
- drive/
22+
- DriveConstants.java
23+
- Drive.java
24+
- elevator/
25+
- ElevatorConstants.java
26+
- Elevator.java
1727

18-
## RobotContainer Design
28+
## Robot.java and Controller Bindings
1929

2030
.. todo::
21-
Explain the role and design of the RobotContainer class. Cover:
22-
- What RobotContainer is responsible for in v3
23-
- How to structure RobotContainer for maintainability
24-
- Mechanism instantiation and initialization
31+
Explain the organization of Robot.java and controller bindings. Cover:
32+
- Robot.java is the main organization point (not using RobotContainer pattern)
33+
- Mechanism instantiation and initialization in Robot.java
34+
- ControllerBindings.java for organizing button bindings
35+
- Autos.java for autonomous routine organization
2536
- Controller/joystick setup
26-
- Button binding organization
27-
- Autonomous routine selection
28-
- Patterns for large RobotContainer classes (splitting into methods or subclasses)
29-
- Example RobotContainer structure (describe sections, not full implementation)
37+
- Patterns for clean organization without RobotContainer
3038

3139
## Robot.java Setup
3240

@@ -37,7 +45,6 @@
3745
- How v3 uses the scheduler in periodic loops
3846
- Autonomous vs. teleop initialization
3947
- Test mode setup for v3
40-
- Simulation support hooks
4148
- What should NOT go in Robot.java (antipatterns)
4249
- Example Robot.java structure for v3
4350

@@ -76,6 +83,7 @@
7683
- Integration test organization
7784
- Test utilities and fixtures
7885
- Mocking Mechanisms and hardware for command tests
86+
- **Mechanism testing**: Mechanisms can accept a `Scheduler` parameter in their constructor to avoid shared state in tests
7987
- Simulation test setup
8088
- CI/CD integration considerations
8189
- Example test directory structure

source/docs/software/commandbased/commands-v3/telemetry-and-debugging.rst

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
# Telemetry and Debugging
22

33
.. todo::
4-
This article covers using v3's enhanced telemetry features and debugging tools to understand and troubleshoot robot behavior. Good telemetry is essential for rapid iteration during competition, and v3 provides improved tools compared to v2.
4+
This article covers using v3's telemetry features and debugging tools to understand and troubleshoot robot behavior. Good telemetry is essential for rapid iteration during competition.
55

6-
## v3 Telemetry Improvements
6+
## Telemetry Features
77

88
.. todo::
9-
Overview of telemetry enhancements in v3. Cover:
10-
- What telemetry improvements v3 provides over v2
11-
- Built-in command scheduler telemetry
9+
Overview of telemetry features in v3. Cover:
10+
- Telemetry API and Epilogue compatibility (protobuf serialization)
1211
- Mechanism state visibility
12+
- Scheduler events
13+
- Detail the subtypes of `SchedulerEvent` and when they are emitted
14+
- Add event listeners to listen for them
1315
- Command lifecycle events
1416
- Priority and interruption logging
15-
- Performance metrics (cycle time, CPU usage)
1617
- How telemetry integrates with the scheduler
1718

18-
## Dashboard Integration
19+
## Data Logging and Analysis
1920

2021
.. todo::
21-
Explain how to integrate v3 telemetry with dashboards. Cover:
22-
- Supported dashboard tools (Shuffleboard, Glass, etc.)
23-
- Automatic command scheduler widget/visualization
22+
Explain how v3 telemetry works with data logging and analysis tools. Cover:
23+
- Protobuf serialization for telemetry data
24+
- Integration with AdvantageScope for post-match analysis
25+
- Tracking command lifetimes and triggering events
26+
- Live or post-match analysis workflows
2427
- Publishing Mechanism state to Network Tables
25-
- Publishing command properties and status
26-
- Creating custom dashboard layouts for v3 projects
27-
- Live tuning parameters through the dashboard
28-
- Remote command triggering from dashboard
29-
- Best practices for dashboard organization
28+
- Best practices for data logging
3029

3130
## Debugging Techniques
3231

3332
.. todo::
3433
Provide techniques for debugging v3 command-based code. Cover:
35-
- Using dashboard telemetry to diagnose issues
34+
- Using telemetry data to diagnose issues
3635
- Logging command lifecycle events
3736
- Tracing command execution flow
3837
- Debugging priority conflicts
3938
- Debugging requirement conflicts
4039
- Debugging trigger bindings that don't fire
4140
- Debugging commands that don't end/interrupt properly
4241
- Using simulation for debugging
43-
- Breakpoint debugging in IDEs with v3
42+
- Breakpoint debugging in IDEs (only in simulation or unit tests, not on running robots)
4443
- Common debugging patterns and workflows
4544

4645
## Logging Best Practices

source/docs/software/commandbased/commands-v3/testing-and-simulation.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Testing and Simulation
22

33
.. todo::
4-
This article covers testing commands and mechanisms using both unit tests and simulation. Testing is crucial for reliable robot code, and v3's design makes testing easier than v2. This article should encourage teams to adopt testing practices and show them how.
4+
This article covers testing commands and mechanisms using both unit tests and simulation. Testing is crucial for reliable robot code, and v3's design facilitates testing. This article should encourage teams to adopt testing practices and show them how.
55

66
## Why Test Commands
77

88
.. todo::
99
Make the case for testing command-based code. Cover:
1010
- Benefits of testing: catch bugs early, enable refactoring, document behavior
11-
- Why v3 makes testing easier than v2
1211
- What aspects of command code can/should be tested
1312
- Testing pyramid: unit tests, integration tests, simulation tests
1413
- When to write tests (TDD, after implementation, before competition)

source/docs/software/commandbased/commands-v3/what-is-commands-v3.rst

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
.. todo::
88
- Recap the command-based pattern (commands + mechanisms for resource management)
9-
- Explain what's fundamentally different in v3 vs v2
10-
- Why imperative style was chosen over declarative composition
11-
- Brief history: evolution from v1 → v2 → v3
9+
- Explain the imperative programming style
10+
- How v3 enables writing robot code that looks like simple sequential programs
1211

13-
## The Problem v3 Solves
12+
## Learning Curve and On-Ramp
1413

1514
.. todo::
16-
**Learning Curve Issues:**
17-
- v2 requires understanding functional composition, decorators, and lambda chaining
18-
- New programmers struggle with splitting logic across initialize/execute/isFinished
19-
- Common mistake: writing blocking loops in execute() that stall the scheduler
15+
**Imperative On-Ramp:**
16+
- Commands v3 allows teams to transition from basic imperative code to the command framework
17+
- Simple sequential code can be lifted into commands with minimal changes
18+
- Example: A basic drive-in-a-square routine can be wrapped in command functions
19+
- Changing `Thread.sleep()` to `coroutine.wait()` and direct calls to `coroutine.await()`
20+
- This provides a gentle learning curve for teams new to command-based programming
2021

2122
**Code Readability:**
22-
- Complex behaviors require deeply nested decorator chains
23-
- Hard to see the sequential flow of actions
24-
- Difficult to add conditional logic mid-sequence
25-
26-
**Example comparison:** Show a complex autonomous routine in v2 (decorator chains) vs v3 (sequential imperative code) to illustrate the readability difference.
23+
- Write robot actions as sequential steps
24+
- Use familiar control flow: loops, if-statements, and function calls
25+
- Easy to add delays, loops, and conditions within command logic
2726

2827
## Core Concepts
2928

@@ -39,66 +38,45 @@
3938

4039
.. todo::
4140
- What are coroutines (functions that can pause and resume)
42-
- How Java's ``Continuation`` API enables this (internal implementation detail)
4341
- Cooperative vs preemptive multitasking
4442
- Commands must voluntarily yield control
4543
- The scheduler cannot forcibly suspend commands
4644

4745
### Mechanisms as Exclusive Resources
4846

4947
.. todo::
50-
- Mechanisms represent hardware groupings (like v2 Subsystems)
48+
- Mechanisms represent hardware groupings
5149
- Only one command can require a mechanism at a time
5250
- Automatic resource conflict detection and resolution
53-
- Comparison to v2 Subsystems with key differences
5451

5552
### Command Priorities
5653

5754
.. todo::
58-
- Priority levels replace v2's binary interrupt behavior
55+
- Priority levels for controlling command interruption
5956
- Higher priority commands can interrupt lower priority ones
6057
- Enables nuanced control (e.g., LED priority ladder for different robot states)
6158
- Default priorities and when to override them
6259

63-
## Key Improvements Over v2
60+
## Additional Features
6461

65-
### 1. Natural Sequential Syntax
66-
67-
.. todo::
68-
- Write steps in order like a recipe
69-
- No need to chain decorators for sequential actions
70-
- Easy to add delays, loops, and conditions mid-command
71-
- Example: Drive to position with adjustments
72-
73-
### 2. Mandatory Command Naming
62+
### Mandatory Command Naming
7463

7564
.. todo::
7665
- All commands must have descriptive names
7766
- Improves telemetry and debugging
78-
- Eliminates vague "SequentialCommandGroup" labels
7967
- Automatic naming for compositions (e.g., "Step 1 -> Step 2 -> Step 3")
8068

81-
### 3. Eliminated Uncommanded Behavior
82-
83-
.. todo::
84-
- v2 issue: nested commands finishing at different times leaves subsystems uncommanded
85-
- v2 solution: proxy commands (boilerplate heavy)
86-
- v3 solution: child commands use mechanisms without parent requiring them
87-
- Child commands cannot interrupt parents
88-
89-
### 4. Enhanced Telemetry
69+
### Enhanced Telemetry
9070

9171
.. todo::
9272
- Per-instance command tracking (each execution has unique ID)
9373
- Clear command hierarchy visualization
94-
- Performance metrics per command execution
9574
- Better dashboard integration
9675

97-
### 5. Inner Trigger Scopes
76+
### Inner Trigger Scopes
9877

9978
.. todo::
10079
- Triggers defined inside command bodies are scoped to that command's lifetime
101-
- No need for global trigger libraries with conditional checks
10280
- Cleaner code organization
10381
- Example: Temporary button binding during a specific command
10482

@@ -110,20 +88,6 @@
11088
- **No unrestricted coroutine usage**: Coroutines only work within command context
11189
- **Cannot replace periodic loops**: Still need periodic methods for continuous updates
11290

113-
## Comparison: v2 vs v3
114-
115-
.. todo::
116-
**When to use v2:**
117-
- Need C++/Python support
118-
- Team comfortable with functional programming
119-
- Existing codebase works well
120-
121-
**When to use v3:**
122-
- Java-only team
123-
- Prefer imperative style
124-
- Want latest features
125-
- Starting fresh for 2027
126-
12791
## Next Steps
12892

12993
.. todo::

0 commit comments

Comments
 (0)