set_robot_mode
This function sets the current operation mode of the robot controller.
Definition
DRFLEx.h within class CDRFLEx, public section
bool set_robot_mode(ROBOT_MODE eMode) { return _set_robot_mode(_rbtCtrl, eMode); };
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
eMode |
Target operation mode to be set. |
Return
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
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.