Skip to content

Conversation

jasondaming
Copy link
Member

I added a bunch of stuff in here. Maybe some of it is too verbose? The idea was basically that Commands v3 could almost completely stand on its own.

@github-actions github-actions bot added the 2027 label Oct 3, 2025
Copy link
Member

@SamCarlberg SamCarlberg left a comment

Choose a reason for hiding this comment

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

First pass, still a lot to cover. Generally, I'd like sections to have more detail that just one or two sentences, particularly for things like parent/child commands and nested triggers. The LLM also seems to be conflating some v2 and v3 APIs (and outright hallucinating a few others)

We should also have a conversation about suggested project structure, since the Robot/RobotContainer split does a poor job of separating concerns

Command driveWithTimeout = Commands.race(
drivetrain.driveToPose(pose),
Commands.waitSeconds(3.0)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a better example than racing with a wait command? That's more idiomatically written using withTimeout. Maybe play an LED pattern instead?


* - Commands v2
- Commands v3
* - ``edu.wpi.first.wpilibj2.command.*``
Copy link
Member

Choose a reason for hiding this comment

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

btw, v2 is moving to the org.wpilib.commands2 package in 2027

Comment on lines 389 to 390
controller.a().onTrue(Commands.runOnce(() -> intake.extend()));
controller.b().whileTrue(new RunCommand(() -> intake.run(), intake));
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 we should use subsystem factories in our examples whenever possible

Suggested change
controller.a().onTrue(Commands.runOnce(() -> intake.extend()));
controller.b().whileTrue(new RunCommand(() -> intake.run(), intake));
controller.a().onTrue(intake.runOnce(() -> intake.extend()));
controller.b().whileTrue(intake.run(() -> intake.run()));

);
new Trigger(() -> sensor.isTriggered())
.onTrue(Command.print("Sensor triggered!"));
Copy link
Member

Choose a reason for hiding this comment

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

That reminds me, we don't currently have a print command in v3

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that just an oversight and there will / should be something like this in the future?

CommandXboxController controller = new CommandXboxController(0);
controller.a().onTrue(
intake.run(coro -> intake.extend()).named("Extend Intake")
Copy link
Member

Choose a reason for hiding this comment

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

This could be _ -> intake.extend() if we're on Java 22 or higher

### Wait and Delay Methods

#### ``wait(Measure<Time>)``
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### ``wait(Measure<Time>)``
#### ``wait(Time)``


#### ``fork(Command)``

Starts a command in the background without waiting for it to finish. Returns a ``CoroutineFuture`` you can ``await()`` later.
Copy link
Member

Choose a reason for hiding this comment

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

LLM hallucination? fork returns void

intake.setSpeed(0);
}).named("Collect Until Full");
### Parallel Actions with Timeout
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 we'd just use the withTimeout decorator instead of manually racing with timed wait commands

### 4. Child Commands and Lifetimes

Commands started with ``await()`` or ``fork()`` are "child commands" of the parent. If the parent is canceled, all children are automatically canceled.
Copy link
Member

Choose a reason for hiding this comment

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

likewise, interrupting a child command will also interrupt its parent (and its parent and... all the way up the chain). One child interrupting another, though, will not interrupt their shared parent

}
});
### 2. Don't Yield Inside Synchronized Blocks
Copy link
Member

Choose a reason for hiding this comment

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

Not relevant if we're on Java 25

@jasondaming
Copy link
Member Author

I think I touched them all. I will go back through the comments later to make sure

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.

2 participants