.. _mwait: mwait ------------------------------------------ This function waits for the motion of the preceding motion command to finish. Combined with an asynchronous motion command, it produces the same motion as a synchronous command. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool mwait() { return _mwait(_rbtCtrl); }; **Parameter** |br| None **Return** .. list-table:: :widths: 25 75 :header-rows: 1 * - **Value** - **Description** * - 0 - Error occurred while waiting for motion completion. * - 1 - Successfully waited until the preceding motion command finished. .. Note:: Returns false without a message when the robot is in STATE_EMERGENCY_STOP, STATE_SAFE_OFF, STATE_SAFE_OFF2, STATE_SAFE_STOP or STATE_SAFE_STOP2. **Example** .. code-block:: cpp // Define target joint position float point[NUM_JOINT] = {30, 30, 30, 30, 30, 30}; // Execute asynchronous motion command Drfl.movej(point, 60, 120); // Wait for the motion to complete before proceeding Drfl.mwait(); This example demonstrates how to **synchronize** an asynchronous motion command using ``mwait()``. The function pauses program execution until the robot finishes the current motion.