Using Actions
runBlocking
The simplest way to execute an action is with runBlocking()
.
This function will run the given action to completion while blocking the current thread.
This is useful for simple, sequential autonomous op modes.
While the action is running, telemetry packets are sent to FTC Dashboard, allowing you to visualize the action's state.
ActionRunner
For more complex scenarios, like TeleOp,
where you need to run multiple actions concurrently,
you can use the ActionRunner
.
It is a singleton object that manages a queue of asynchronous actions.
Running Actions
To run an action with the ActionRunner
, simply call ActionRunner.run()
:
You can also run multiple actions at once:
Updating the Queue
The ActionRunner
needs to be updated on every loop of your op mode.
This is done by calling ActionRunner.update()
at the end of your loop()
method.
The update()
method will execute the actions in the queue and send telemetry to FTC Dashboard.
Action Interruption
When a new action is added to the queue,
the ActionRunner
will check if any of the currently running actions
share any requirements with the new action.
If they do, and the running action is Interruptible
, its onInterrupt()
method will be called,
and it will be removed from the queue.
This allows you to create complex, priority-based behaviors.
Op Mode Lifecycle
The ActionRunner
automatically manages the action queue across different op mode stages.
It ensures that the queue is empty before opModePreInit
and clears it after opModePostStop
.