.. _set_robot_control: set_robot_control ------------------------------------------ This function lets the user set and change the current operation state of the robot controller. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool set_robot_control(ROBOT_CONTROL eControl) { return _set_robot_control(_rbtCtrl, eControl); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - eControl - :ref:`ROBOT_CONTROL ` - - - Control command to apply to the robot controller. **Return** .. list-table:: :widths: 10 20 70 :header-rows: 1 * - **Value** - **Type** - **Description** * - 0 - int - Error — failed to change the control state. * - 1 - int - Success — successfully changed the control state. **Preconditions** The state in this table is the robot state last reported to this client. In any other state the function returns false without a message. .. list-table:: :widths: 35 65 :header-rows: 1 * - **eControl** - **Accepted state** * - CONTROL_INIT_CONFIG - Only on a new CDRFLEx object, before the controller has reported its safety mode and before any call that changes the mode (for example ``set_robot_mode``). See the Caution below. * - CONTROL_ENABLE_OPERATION - Only while the safety mode is INITIALIZE. * - CONTROL_SERVO_ON - In SAFE_OFF or SAFE_OFF2; in STANDBY it returns true and does nothing. * - CONTROL_RESET_SAFE_STOP - Only in SAFE_STOP or SAFE_STOP2; in SAFE_STOP the call waits until the state changes. * - CONTROL_RECOVERY_SAFE_STOP and CONTROL_RECOVERY_SAFE_OFF - In SAFE_STOP, SAFE_STOP2, SAFE_OFF or SAFE_OFF2. * - CONTROL_RECOVERY_BACKDRIVE - Only in SAFE_STOP2 or SAFE_OFF2. * - CONTROL_RESET_RECOVERY - Only in RECOVERY. .. Caution:: After a disconnect, the CDRFLEx object records the safety mode as AUTONOMOUS, so ``CONTROL_INIT_CONFIG`` returns false on a reconnected object. To use ``CONTROL_INIT_CONFIG`` after a disconnect, create a new CDRFLEx object. **Example** .. code-block:: cpp if (drfl.get_robot_state() == STATE_SAFE_OFF) { // Servo ON (reset from SAFE OFF) drfl.set_robot_control(CONTROL_RESET_SAFET_OFF); } else if (drfl.get_robot_state() == STATE_SAFE_OFF2) { // Enter recovery mode drfl.set_robot_control(CONTROL_RECOVERY_SAFE_OFF); } This example checks the robot’s **safe-off state** and sends a control command accordingly. It resets the servo power or performs recovery, enabling the robot to return to a controllable state. .. Note:: In Recovery mode, jog, multi_jog and the motion functions (movej, movel, movec, moveb, movejx, movesj, movesx, move_spiral, move_periodic, their amove variants, movesj_g and movesx_g) return false and print "this command cannot be used in recovery mode. please change to auto mode as robot mode". To leave Recovery mode, call set_robot_control(CONTROL_RESET_RECOVERY), then set_robot_mode(ROBOT_MODE_MANUAL) or set_robot_mode(ROBOT_MODE_AUTONOMOUS). Until set_robot_mode is called, these functions keep returning false.