|
HoloLib
High-performance holonomic (X-Drive) control library for VEX V5
|
Manages the execution of motion commands asynchronously. More...
#include <motion_handler.h>
Public Member Functions | |
| MotionHandler () | |
| Construct a new MotionHandler object. | |
| void | enqueue (std::function< void()> motion, bool async) |
| Enqueue a new motion function. | |
| void | cancelAll () |
| Cancel all pending motions in the queue. | |
| void | waitUntilDone () |
| Wait until all queued motions have finished executing. | |
| void | cancelMotion () |
| Cancel the currently executing motion. | |
| bool | isInMotion () |
| Check if the handler is currently executing a motion. | |
| uint32_t | getLastEnqueuedId () const |
| Get the ID of the last enqueued motion. | |
| uint32_t | getCurrentRunningId () const |
| Get the ID of the currently running motion. | |
| bool | isQueueEmpty () |
| Check if the motion queue is empty. | |
| void | setOnMotionStart (std::function< void()> callback) |
| Set a callback that is executed whenever a new motion starts. | |
Friends | |
| void | motionHandlerTask (void *param) |
Manages the execution of motion commands asynchronously.
The MotionHandler class allows queueing of movement commands, which are executed in a separate PROS task. This permits asynchronous operation without blocking the main control loop.
Definition at line 15 of file motion_handler.h.
| MotionHandler::MotionHandler | ( | ) |
Construct a new MotionHandler object.
| void MotionHandler::enqueue | ( | std::function< void()> | motion, |
| bool | async | ||
| ) |
Enqueue a new motion function.
| motion | The function to execute. |
| async | If false, waits until the motion is done before returning. |
| void MotionHandler::cancelAll | ( | ) |
Cancel all pending motions in the queue.
| void MotionHandler::waitUntilDone | ( | ) |
Wait until all queued motions have finished executing.
| void MotionHandler::cancelMotion | ( | ) |
Cancel the currently executing motion.
| bool MotionHandler::isInMotion | ( | ) |
Check if the handler is currently executing a motion.
|
inline |
Get the ID of the last enqueued motion.
Definition at line 57 of file motion_handler.h.
|
inline |
Get the ID of the currently running motion.
Definition at line 64 of file motion_handler.h.
|
inline |
Check if the motion queue is empty.
Definition at line 71 of file motion_handler.h.
|
inline |
Set a callback that is executed whenever a new motion starts.
| callback | The callback function. |
Definition at line 83 of file motion_handler.h.
|
friend |