.. _manual_set_robot_mode: set_robot_mode (Manual Mode) ------------------------------------------ This section explains how to use :ref:`set_robot_mode ` during **Manual (Teach)** operations. This function switches the robot controller between **Manual (Teach)** and **Automatic (Run)** modes. It is essential for managing when operators can safely jog, teach, or execute DRL programs. **Typical usage** - Switch to **Manual mode** before performing teaching, jogging, or calibration. - Change to **Auto mode** when executing a saved DRL program or remote control sequence. - Verify mode transition logic between external systems (e.g., PLC ↔ controller) for safety compliance. - Use in initialization routines to ensure the robot is in the correct mode before commanding motion. .. Note:: - Certain operations (e.g., motion, speed change) are restricted based on the active mode. - Some controllers may require physical switch confirmation for safety (e.g., TP key or panel input). .. Caution:: set_robot_mode stores the requested mode even when it returns false. get_robot_mode then returns the requested mode, and functions that require Auto or Manual mode accept calls although the controller did not change mode. If set_robot_mode returns false, do not use mode-gated functions until a later set_robot_mode call returns true. **Example: Switch robot to Manual Mode before jogging** .. code-block:: cpp // Preconditions: // - Connection established (open_connection) // - Safety interlocks and servo power ready printf("[Mode] Requesting switch to MANUAL mode...\n"); if (drfl.set_robot_mode(ROBOT_MODE_MANUAL)) printf("[Mode] Successfully switched to MANUAL mode.\n"); else printf("[Mode] Failed to switch mode. Check TP or safety key.\n"); // Simulate manual jogging operation float qTarget[6] = {0, -30, 90, 0, 90, 0}; drfl.movej(qTarget, 30, 30); this_thread::sleep_for(chrono::seconds(2)); printf("[Mode] Switching to AUTO mode for program execution...\n"); drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS); **Tips** - Always confirm **Manual mode** is active before enabling jog or teach functions. - Use :ref:`get_robot_mode ` to verify the current mode after switching. - Combine with :ref:`set_robot_system ` to coordinate mode and system-level changes. - In hybrid systems, mode transitions should be logged to ensure traceability and operator safety.