set_on_monitoring_safety_state (Manual Mode)

This section explains how to use set_on_monitoring_safety_state during Manual (Teach) operations. This function registers a callback that is triggered each time the controller reports the robot’s safety state. The callback receives one SAFETY_STATE value, such as a violation-detected stop (SAFETY_STATE_VD_STO), jog and homing (SAFETY_STATE_JH_MOVE), or collaborative workspace operation (SAFETY_STATE_CW_RUN).

Typical usage

  • Monitor real-time safety state transitions during manual teaching.

  • Log or display safety state changes (e.g., SAFETY_STATE_VD_STO, SAFETY_STATE_CW_RUN).

  • Trigger user-defined recovery or alert routines in response to safety events.

Note

  • The callback executes automatically whenever the controller’s safety state updates.

  • The monitoring continues until explicitly replaced or the connection is closed.

  • See Rules for callback functions.

Example: Register a safety state monitoring callback

// 1) Define the callback function
void OnSafetyStateChanged(const SAFETY_STATE eState) {
    printf("[Safety State Changed]\n");
    printf(" Safety state: %d\n", (int)eState);
}

// Preconditions:
// - Connection established (open_connection)
// - Manual (Teach) mode active

// 2) Register safety monitoring callback
drfl.set_on_monitoring_safety_state(OnSafetyStateChanged);
printf("[Safety Monitor] Safety state callback registered.\n");

// 3) Keep program running to receive events
while (true) {
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

Tips

  • The callback receives one SAFETY_STATE value, for example SAFETY_STATE_VD_STO (violation detected, STO), SAFETY_STATE_JH_MOVE (jog and homing move) or SAFETY_STATE_CW_RUN (collaborative workspace run). Compare it with the previous value to detect transitions.

  • For comprehensive status diagnostics, combine this with:
  • The callback remains valid until manually re-registered or the session is terminated.