28 void enqueue(std::function<
void()> motion,
bool async);
73 bool empty = queue.empty();
84 onMotionStartCallback = callback;
88 std::queue<std::function<void()>> queue;
90 pros::Task *task =
nullptr;
91 uint32_t lastEnqueuedId = 0;
92 uint32_t currentRunningId = 0;
93 std::function<void()> onMotionStartCallback =
nullptr;
Manages the execution of motion commands asynchronously.
void setOnMotionStart(std::function< void()> callback)
Set a callback that is executed whenever a new motion starts.
MotionHandler()
Construct a new MotionHandler object.
void cancelAll()
Cancel all pending motions in the queue.
void cancelMotion()
Cancel the currently executing motion.
void enqueue(std::function< void()> motion, bool async)
Enqueue a new motion function.
bool isQueueEmpty()
Check if the motion queue is empty.
uint32_t getCurrentRunningId() const
Get the ID of the currently running motion.
void waitUntilDone()
Wait until all queued motions have finished executing.
friend void motionHandlerTask(void *param)
bool isInMotion()
Check if the handler is currently executing a motion.
uint32_t getLastEnqueuedId() const
Get the ID of the last enqueued motion.