set_tcp

This function sets the currently active TCP (Tool Center Point) among the TCP configurations that have been pre-registered in the robot controller. If an empty string is passed, the TCP information is cleared and reset to default. This ensures that motion and coordinate calculations use the correct reference point for the attached end-effector or tool.

Available in Manual mode. In any other mode the function returns false and prints this command can only be used in manual mode. please change to manual mode as robot mode. The mode check uses the value returned by get_robot_mode. On a real robot the safety board also refuses the call while the robot is moving; the motion is quick-stopped and a running program is stopped.

Definition
DRFLEx.h within class CDRFLEx, public section

bool set_tcp(string strSymbol) {
    return _set_tcp(_rbtCtrl, strSymbol.c_str());
};

Parameter

Parameter Name

Data Type

Default Value

Description

strSymbol

string

Name of the TCP to activate.
Must correspond to a TCP entry previously registered in the controller.
If an empty string “” is passed, the active TCP is cleared.

Return

Value

Description

0

Error — failed to activate the TCP

1

Success — the TCP was successfully set as active

Example

// (1) Set the TCP named "tcp#1"
drfl.set_tcp("tcp#1");

// (2) Move using the selected TCP reference
float point[6] = {756.6f, 511.6f, 876.6f, 44.5f, 86.7f, 55.7f};
float vel[2]   = {30.f, 20.f};
float acc[2]   = {30.f, 20.f};

drfl.movel(point, vel, acc);

This example selects the TCP named “tcp#1” and performs a linear task-space motion using that TCP as the reference frame for all position and orientation calculations.