.. _set_robot_mode: set_robot_mode ------------------------------------------ This function sets the current operation mode of the robot controller. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool set_robot_mode(ROBOT_MODE eMode) { return _set_robot_mode(_rbtCtrl, eMode); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - eMode - :ref:`ROBOT_MODE ` - - - Target operation mode to be set. **Return** .. list-table:: :widths: 10 20 70 :header-rows: 1 * - **Value** - **Type** - **Description** * - 0 - int - Error — failed to change the robot mode. * - 1 - int - Success — successfully set the robot mode. .. note:: Returns false if the request was refused. A return of true does not confirm that the controller applied the request; get_robot_mode reports the request made by this CDRFLEx instance, so it does not confirm it either. A refusal is reported through TOnLogAlarmCB. .. Caution:: Do not change the mode while a jog, or a motion or program started by another client, is running. On a real robot the safety board refuses the change and set_robot_mode returns false. 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** .. code-block:: cpp if (drfl.get_robot_mode() == ROBOT_MODE_MANUAL) { // Converts to Auto mode drfl.set_robot_mode(ROBOT_MODE_AUTONOMOUS); } This example checks whether the robot is currently in **Manual mode** and switches it to **Auto mode** if necessary, allowing the controller to execute programmed motions sequentially.