coord_transform

This function transforms a given task-space position (fTargetPos) from one coordinate system (eInCoordSystem) to another (eOutCoordSystem). It supports all valid transformation pairs among World, Base, Tool, and User coordinate systems.

Typical use cases include converting a pose expressed in a user-defined coordinate system into base coordinates for motion commands, or transforming tool TCP data into world space.

Definition
DRFLEx.h within class CDRFLEx, public section

LPROBOT_POSE coord_transform(
    float fTargetPos[NUM_TASK],
    COORDINATE_SYSTEM eInCoordSystem,
    COORDINATE_SYSTEM eOutCoordSystem
) {
    return _coord_transform(_rbtCtrl, fTargetPos, eInCoordSystem, eOutCoordSystem);
};

Supported Transformations

The following conversions are supported:

  • (InCoordSystem) world → (OutCoordSystem) base, tool, user

  • (InCoordSystem) base → (OutCoordSystem) world, tool, user

  • (InCoordSystem) tool → (OutCoordSystem) world, base, user

  • (InCoordSystem) user → (OutCoordSystem) world, base, tool

This allows flexible transformation between all combinations of reference frames.

Parameter

Parameter Name

Data Type

Default Value

Description

fTargetPos

float[6]

Target task-space position to be transformed (x, y, z, Rx, Ry, Rz).

eInCoordSystem

COORDINATE_SYSTEM

Source coordinate system in which fTargetPos is expressed.

eOutCoordSystem

COORDINATE_SYSTEM

Target coordinate system to which the position will be transformed.

Return

Value

Description

LPROBOT_POSE

The transformed pose, expressed in the output coordinate system.

Note

This call waits for the controller to answer.

The returned pointer refers to storage in the CDRFLEx object that other DRFL calls and every reconnect reuse; copy the structure before making another DRFL call. The 3-argument ikin returns its result in storage shared by all CDRFLEx objects in the process instead; see ikin. Except for get_user_home, the pointer is never NULL; do not use a NULL check to detect failure.

Example

float tcp_pose[6] = { 300.f, 100.f, 200.f, 0.f, 180.f, 90.f };

// Transform TCP pose from BASE to USER coordinate system
LPROBOT_POSE result = drfl.coord_transform(
    tcp_pose,
    COORDINATE_SYSTEM_BASE,
    COORDINATE_SYSTEM_USER_MIN   // user frame 101
);

printf("Transformed X: %.1f\n", result->_fPosition[0]);

This example converts a TCP pose originally expressed in the base coordinate system into the user coordinate system, and prints the transformed X-coordinate. This function is especially useful when calibrating user frames or performing motion planning relative to non-base reference systems.