add_tcp

This function registers a new TCP (Tool Center Point) configuration in the robot controller memory. Each TCP defines a specific position and orientation of the tool’s reference point relative to the flange. Registered TCPs can later be activated with set_tcp.

Note that the TCP registration is stored in volatile memory, meaning it is cleared upon reboot unless registered via the Teach Pendant initialization process.

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 add_tcp(string strSymbol, float fPostion[NUM_TASK]) {
    return _add_tcp(_rbtCtrl, strSymbol.c_str(), fPostion);
};

Parameter

Parameter Name

Data Type

Default Value

Description

strSymbol

string

Name of the TCP to register.

fPostion

float[6]

TCP pose data (X, Y, Z, Rx, Ry, Rz) defining the TCP position and orientation
relative to the robot flange coordinate frame.

Return

Value

Description

0

Error — failed to register the TCP

1

Success — TCP registration completed successfully

Note

The name is limited to 32 bytes; longer names are truncated. Adding a name that already exists replaces that entry, and if the tool (TCP) is active the new values take effect immediately. The controller holds up to 50 tools and 50 TCPs; adding beyond that raises an alarm and stops the running program.

Example

float fTCP[6] = {10.f, 10.f, 10.f, 0.f, 0.f, 0.f};

// (1) Register a new TCP named "tcp#1"
drfl.add_tcp("tcp#1", fTCP);

// (2) Set it as the currently active TCP
drfl.set_tcp("tcp#1");

// (3) Delete the registered TCP
drfl.del_tcp("tcp#1");

This example demonstrates how to register a new TCP position, activate it for motion commands, and then remove it from the controller’s TCP registry.