set_on_mastering_need
This function registers a callback function that automatically checks whether the robot’s axes have been twisted by an external force. Use it to run your own code automatically when this event occurs.
Definition
DRFLEx.h within class CDRFLEx, public section
void set_on_mastering_need(TOnMasteringNeedCB pCallbackFunc) {
_set_on_mastering_need(_rbtCtrl, pCallbackFunc);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
pCallbackFunc |
Refer to definition of callback function |
Return
None
Example
std::atomic<bool> g_bNeedHoming(false);
void OnMasteringNeedCB()
{
// Request homing from the main loop
g_bNeedHoming = true;
}
drfl.set_on_mastering_need(OnMasteringNeedCB);
// Main loop: call move_home outside the callback
while (true) {
if (g_bNeedHoming) {
g_bNeedHoming = false;
// Starts the homing mode for the alignment of the robot’s axes
drfl.move_home(MOVE_HOME_MECHANIC, 1);
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
When registered, this callback is executed automatically if the controller detects axis misalignment caused by external force. The callback sets a flag, and the main loop then starts the homing procedure to realign all robot joints, ensuring proper position calibration before resuming normal operation. Call move_home outside the callback; see Rules for callback functions.