task_compliance_ctrl

This function starts task-space compliance control (Cartesian stiffness control) in the specified reference coordinate system.

To end compliance control, use release_compliance_ctrl.

Definition
DRFLEx.h within class CDRFLEx, public section

bool task_compliance_ctrl(float fTargetStiffness[NUM_TASK],
                          COORDINATE_SYSTEM eForceReference = COORDINATE_SYSTEM_TOOL,
                          float fTargetTime = 0.f) {
    return _task_compliance_ctrl(_rbtCtrl, fTargetStiffness, eForceReference, fTargetTime);
};

Parameter

Parameter Name

Data Type

Default Value

Description

fTargetStiffness

float[6]

Stiffness for XYZ (translation) and Rx/Ry/Rz (rotation)
Larger: stiffer (less compliant)
Smaller values: softer (more compliant)
Units: N/m (translation) and N·m/rad (rotation)

eForceReference

COORDINATE_SYSTEM

COORDINATE_SYSTEM_TOOL

Reference coordinate frame for stiffness control (e.g., TOOL, BASE, WORLD).

fTargetTime

float

0

Transition duration [sec] for stiffness change (range 0–1).
Linear interpolation is used during the specified time.

Return

Value

Description

0

Failed

1

Success

Note

When the address passed to open_connection is exactly “127.0.0.1”, task_compliance_ctrl, set_stiffnessx, release_compliance_ctrl, set_desired_force and release_force return true without sending the command to the controller.

Example A — Manual (Teach) Hand-Guiding

// Preconditions:
// - Connection established
// - Manual (Teach) mode active
// - Servo power ON

// 1) Move to a safe position before enabling compliance
float q0[6] = { 0.0f, 0.0f, 90.0f, 0.0f, 90.0f, 0.0f };
drfl.movej(q0, 60, 30);
drfl.mwait();

// 2) Define stiffness for each axis (lower = more compliant)
float stiffness[6] = { 2500.f, 2500.f, 2500.f, 150.f, 150.f, 150.f };

// 3) Enable compliance control in TOOL frame
if (!drfl.task_compliance_ctrl(stiffness, COORDINATE_SYSTEM_TOOL, 0.1f)) {
    printf("Failed to start compliance control.\n");
    return -1;
}

printf("Compliance active. The arm can now be hand-guided safely.\n");

// 4) Release compliance after teaching
drfl.release_compliance_ctrl();
printf("Compliance control released.\n");

Example B — Auto Mode (Insertion or Surface Contact Task)

// 1) Move to approach position
float p_app[NUM_TASK] = {550.f, 200.f, 150.f, 180.f, 0.f, 0.f};
float vel1[2] = {150.f, 30.f}, acc1[2] = {400.f, 150.f};
drfl.movel(p_app, vel1, acc1);
drfl.mwait();

// 2) Enable compliance (soft in Z and rotation)
float k_soft[NUM_TASK] = {2500.f, 2500.f, 1200.f, 100.f, 100.f, 100.f};
if (!drfl.task_compliance_ctrl(k_soft, COORDINATE_SYSTEM_TOOL, 0.2f)) {
    printf("Failed to enable compliance.\n");
}

// 3) Execute insertion motion under compliance
float p_down[NUM_TASK] = {550.f, 200.f, 90.f, 180.f, 0.f, 0.f};
float vel2[2] = {40.f, 15.f}, acc2[2] = {150.f, 60.f};
drfl.movel(p_down, vel2, acc2);
drfl.mwait();

// 4) Disable compliance after insertion
drfl.release_compliance_ctrl();
drfl.mwait();

// 5) Continue with precision motion
float p_final[NUM_TASK] = {550.f, 200.f, 85.f, 180.f, 0.f, 0.f};
float vel3[2] = {60.f, 20.f}, acc3[2] = {300.f, 120.f};
drfl.movel(p_final, vel3, acc3);
drfl.mwait();

Notes & Best Practices

  • Activate compliance only during necessary operations. Disable it before executing fast or high-precision movements using release_compliance_ctrl.

  • Use mwait() to ensure motion completion before switching between position and compliance control.

  • Recommended stiffness values: XYZ 1500–2500, rotations 100–200.

  • Use the TOOL coordinate system for hand-guiding or alignment tasks.

  • Use the BASE coordinate system when the compliance direction should follow the workspace axes.