.. _cb_tonmasteringneedcb: TOnMasteringNeedCB ------------------------------------------ This callback function is used to check whether the **robot’s axes have been twisted or misaligned** by an external force. When this event occurs, the robot requires **re-mastering (axis alignment)** through homing. The alignment completion can then be verified using the :ref:`TOnHommingCompletedCB ` callback. See :ref:`Rules for callback functions `. **Defined in:** ``DRFLEx.h`` .. code-block:: cpp // typedef (DRFL.h) typedef void (*TOnMasteringNeedCB)(); // registration API (internal + wrapper) DRFL_API void _set_on_mastering_need(LPROBOTCONTROL pCtrl, TOnMasteringNeedCB pCallbackFunc); void set_on_mastering_need(TOnMasteringNeedCB pCallbackFunc) { _set_on_mastering_need(_rbtCtrl, pCallbackFunc); }; **Parameter** |br| None **Return** |br| None **Example** .. code-block:: cpp #include "DRFLEx.h" #include #include #include #include using namespace DRAFramework; using namespace std; std::atomic g_bNeedHoming(false); // Callback triggered when robot mastering (axis alignment) is required void OnMasteringNeedCB() { cout << "[MASTERING] Axis misalignment detected. Requesting homing sequence..." << endl; // Request homing from the main loop; do not call move_home here g_bNeedHoming = true; } int main() { CDRFLEx drfl; // Connect to the robot controller if (!drfl.open_connection("192.168.137.100")) { cout << "Failed to connect to controller." << endl; return -1; } // Register mastering-needed callback drfl.set_on_mastering_need(OnMasteringNeedCB); // Main loop: start homing outside the callback while (true) { if (g_bNeedHoming) { g_bNeedHoming = false; // Initiate homing mode for re-alignment of robot axes drfl.move_home(MOVE_HOME_MECHANIC, 1); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } drfl.close_connection(); return 0; } **Notes** - This callback is invoked when the controller detects **axis offset** that requires re-mastering. - Use this event to trigger an **automatic homing or alignment process**. - Use :ref:`TOnHommingCompletedCB ` to confirm when re-alignment finishes.