acmerobotics / road-runner-quickstart

FTC quickstart for https://github.com/acmerobotics/road-runner
BSD 3-Clause Clear License
168 stars 856 forks source link

Wait for an Action to complete? #316

Closed madacker closed 6 months ago

madacker commented 7 months ago

RR FTC Version

0.1.8

Observed Behavior

Most threading models have a means to wait on thread-completion, but I haven't spotted native support for that with Actions in Road Runner. Synchronization is needed in many FTC scenarios. A couple to consider:

It's possible of course to hack around this. Implement the first Action so that it maintains an "isBusy" variable, create another Action that returns the run state of that first Action, and then synchronously wait on the second Action. But considering the potential frequency of this use case, it would be nice if there were a clean, first-class mechanism for synchronizing Actions.

Of course, with either the hackaround or with native support, the wait points have to be completed when the robot is stopped.

Tuning Files

No response

Robot Logs

No response

rbrott commented 7 months ago
* In the sample from the Road Runner overview, say we want to spin up the shooter while the robot is concurrently moving to a specific position to do its shot. Once it is stopped at that target position _and_ the flywheel is fully spun-up, then do the shot.

I would express that as seq(par(moveToTarget, spinUpFlywheel), shoot). The semantics of ParallelAction are to wait for every action to complete before continuing and that gives some sort of synchronization / join functionality.