You're reading the documentation for an older, but still supported version (GL013300).
For information on the latest version, please have a look at GL013301.

set_stiffnessx

This function sets task-space stiffness (Cartesian stiffness) values for each translational and rotational axis within the specified reference coordinate system.

The stiffness transitions linearly from the current value over the specified time fTargetTime.

Definition
DRFLEx.h within class CDRFLEx, public section (line 949)

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

Parameter

Parameter Name

Data Type

Default Value

Description

fTargetStiffness

float[6]

Stiffness values for XYZ and Rx/Ry/Rz
Range: 0-20000 N/m (translation), 0-400 N·m/rad (rotation).
Larger: stiffer motion
Smaller → more compliant

eForceReference

COORDINATE_SYSTEM

COORDINATE_SYSTEM_TOOL

Coordinate frame in which stiffness is applied (e.g., TOOL, BASE, WORLD).

fTargetTime

float

0

Transition time [sec] for stiffness interpolation (0-1.0)
Gradual change over the given duration.

Return

Value

Description

0

Failed

1

Success

Example A — Manual Mode (Hand-Guiding Adjustment)

#include "DRFLEx.h"
using namespace DRAFramework;

int main() {
    CDRFLEx drfl;

    // Preconditions:
    // - Connection established, Teach mode active, Servo ON

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

    // 2) Start compliance mode
    float baseStiff[6] = {3000.f, 3000.f, 3000.f, 200.f, 200.f, 200.f};
    drfl.task_compliance_ctrl(baseStiff, COORDINATE_SYSTEM_TOOL, 0.0f);

    // 3) Adjust stiffness for more compliance along Z and rotations
    float softStiff[6] = {2000.f, 2000.f, 1000.f, 120.f, 120.f, 120.f};
    drfl.set_stiffnessx(softStiff, COORDINATE_SYSTEM_TOOL, 0.5f);

    printf("Stiffness adjusted for smoother hand guidance.\n");

    // 4) Stop compliance
    drfl.release_compliance_ctrl();
    printf("Compliance released.\n");

    return 0;
}

Example B — Auto Mode (Dynamic Stiffness Tuning During Insertion)

// 1) Approach target area
float p_app[NUM_TASK] = {550.f, 200.f, 150.f, 180.f, 0.f, 0.f};
drfl.movel(p_app, (float[2]){100.f, 30.f}, (float[2]){400.f, 150.f});
drfl.mwait();

// 2) Enable compliance
float initStiff[NUM_TASK] = {3000.f, 3000.f, 2000.f, 200.f, 200.f, 200.f};
drfl.task_compliance_ctrl(initStiff, COORDINATE_SYSTEM_TOOL, 0.1f);

// 3) Reduce Z stiffness gradually for insertion
float tunedStiff[NUM_TASK] = {3000.f, 3000.f, 800.f, 150.f, 150.f, 150.f};
drfl.set_stiffnessx(tunedStiff, COORDINATE_SYSTEM_TOOL, 0.3f);

// 4) Perform motion while compliant
float p_insert[NUM_TASK] = {550.f, 200.f, 90.f, 180.f, 0.f, 0.f};
drfl.movel(p_insert, (float[2]){40.f, 15.f}, (float[2]){200.f, 80.f});
drfl.mwait();

// 5) Restore normal stiffness for precision steps
float normalStiff[NUM_TASK] = {3000.f, 3000.f, 3000.f, 200.f, 200.f, 200.f};
drfl.set_stiffnessx(normalStiff, COORDINATE_SYSTEM_TOOL, 0.2f);
drfl.release_compliance_ctrl();

printf("Dynamic stiffness control completed.\n");

Notes & Best Practices

  • Adjust stiffness dynamically to balance force compliance and positional accuracy.

  • Use low stiffness (1000–2000 N/m) for contact or alignment phases.

  • Keep transition times short (0.3–0.5s) for smooth, real-time control response.

  • Combine with task_compliance_ctrl for advanced compliant task execution.

  • Always release compliance before high-speed motion or trajectory blending.