get_tool_force
This function retrieves the force and moment applied at the robot tool center point (TCP). The force is expressed relative to the specified coordinate system (default: BASE). Internally, it is estimated using joint torque sensors and the robot’s dynamic model.
Definition
DRFLEx.h within class CDRFLEx, public section
LPROBOT_FORCE get_tool_force(COORDINATE_SYSTEM eTargetRef = COORDINATE_SYSTEM_BASE) {
return _get_tool_force(_rbtCtrl, eTargetRef);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
eTargetRef |
COORDINATE_SYSTEM_BASE |
Reference coordinate system in which the TCP force is expressed. Supported values are COORDINATE_SYSTEM_BASE, COORDINATE_SYSTEM_TOOL and COORDINATE_SYSTEM_WORLD; TOOL and WORLD require setup_monitoring_version(1). |
Return
Value |
Description |
|---|---|
Pointer to a structure containing the estimated TCP force (Fx, Fy, Fz) and moment (Mx, My, Mz). |
Caution
The function does not refuse unsupported eTargetRef values; it returns the BASE values instead. With monitoring version 0, COORDINATE_SYSTEM_TOOL and COORDINATE_SYSTEM_WORLD also return the BASE values. Call setup_monitoring_version(1) before requesting TOOL or WORLD.
Example
// Assume robot connection and operation mode initialized
LPROBOT_FORCE lpForce = drfl.get_tool_force(COORDINATE_SYSTEM_BASE);
if (lpForce) {
printf("Tool Force and Moment (Base Coordinate)\n");
printf("Force [N]: Fx=%.2f Fy=%.2f Fz=%.2f\n",
lpForce->_fForce[0],
lpForce->_fForce[1],
lpForce->_fForce[2]);
printf("Moment [N·m]: Mx=%.3f My=%.3f Mz=%.3f\n",
lpForce->_fForce[3],
lpForce->_fForce[4],
lpForce->_fForce[5]);
} else {
fprintf(stderr, "Failed to retrieve tool force.\n");
}
This example prints the current force and torque applied at the TCP,
expressed in the base coordinate system.
It can be used for:
Detecting contact with objects (e.g., surface alignment)
Measuring external forces during force-control applications
Validating compliance and impedance control responses