.. _auto_drl_stop: drl_stop (Auto Mode) ------------------------------------------ This section explains how to use :ref:`drl_stop ` during **Auto (Run)** operations to stop a currently running **DRL (Doosan Robotics Language)** program. It is typically used to interrupt a task sequence triggered by ``drl_start``, allowing external systems (PC, PLC, MES, vision logic, safety logic) to control when the robot should halt DRL execution. When drl_stop returns true, the robot is in Manual mode; call set_robot_mode(ROBOT_MODE_AUTONOMOUS) before the next drl_start. When no DRL program is running or paused, or the controller refuses the stop, drl_stop returns false and the mode does not change. drl_stop also returns false after the program has stopped when Manual mode is not confirmed or the robot is in a fault state; after a false return, check get_program_state() and get_robot_mode(). **Typical usage** - Stop an active DRL program when a cycle must be interrupted. - Integrate with external UI/PLC buttons (STOP / EMERGENCY STOP substitutes). .. Note:: - The program's motion is always quick-stopped. - ``0`` and ``1`` end the program as a normal forced stop; ``2`` ends it as an error stop. - The function only succeeds if a DRL program is currently running or paused. **Example: Stopping a Running DRL Task** .. code-block:: cpp // 1) Check DRL program execution state DRL_PROGRAM_STATE state = drfl.get_program_state(); // 2) Stop only if the program is running or paused if (state == DRL_PROGRAM_STATE_PLAY || state == DRL_PROGRAM_STATE_HOLD) { // STOP_TYPE_QUICK (1): normal forced stop if (!drfl.drl_stop(STOP_TYPE_QUICK)) { printf("Failed to stop DRL program.\n"); return -1; } printf("DRL program stopped.\n"); } else { printf("No active DRL program.\n"); } In this example, the program checks the current DRL execution state and stops the program only when a DRL program is running or paused. This allows external logic to interrupt automatic task sequences. **Tips** - Combine with :ref:`drl_pause ` for smoother step-wise control. - Log stop reasons (sensor trigger, operator request, safety event) for debugging and traceability.