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.

check_force_condition

This function checks whether the measured external force or torque along a specified axis is within a user-defined range (magnitude-based, independent of direction). It can be repeatedly evaluated inside while or if statements to implement conditional logic in both teaching and automatic operation modes.

When measuring force, the eForceAxis is interpreted relative to the reference coordinate system defined by set_ref_coord. When monitoring moment, eForceAxis corresponds to the tool coordinate.

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

bool check_force_condition(FORCE_AXIS eForceAxis,
                           float fTargetMin,
                           float fTargetMax,
                           COORDINATE_SYSTEM eForceReference = COORDINATE_SYSTEM_TOOL) {
    return _check_force_condition(_rbtCtrl, eForceAxis, fTargetMin, fTargetMax, eForceReference);
};

Parameter

Parameter Name

Data Type

Default Value

Description

eForceAxis

FORCE_AXIS

Axis to check for force or torque (e.g., FORCE_AXIS_X, Y, Z, Rx, Ry, Rz).

fTargetMin

float

Minimum threshold for the measured magnitude.

fTargetMax

float

Maximum threshold for the measured magnitude.

eForceReference

COORDINATE_SYSTEM

COORDINATE_SYSTEM_TOOL

Reference coordinate frame in which the measurement is interpreted.

Return

Value

Description

1

Condition True — current force/torque magnitude is within range.

0

Condition False — current force/torque magnitude is outside range.

Example A — Manual Mode (Force Validation During Teaching)

#include "DRFLEx.h"
#include <cstdio>
using namespace DRAFramework;

int main() {
    CDRFLEx drfl;
    // Preconditions: Connected, servo ON, Teach mode active

    // 1) Continuously monitor Z-axis force (TOOL frame)
    bool fCond = false;
    while (true) {
        fCond = drfl.check_force_condition(FORCE_AXIS_Z, 5.f, 10.f, COORDINATE_SYSTEM_TOOL);
        if (fCond) {
            printf("Force condition met: 5–10 N on Z-axis.\n");
            break;
        }
    }

    // Continue teaching sequence after contact detection
    return 0;
}

Example B — Auto Mode (Force-Based Insertion Trigger)

// Preconditions:
// - Auto mode active
// - Robot in motion with force sensing enabled

// 1) Approach the insertion point
float p_target[NUM_TASK] = {550.f, 200.f, 100.f, 180.f, 0.f, 0.f};
drfl.movel(p_target, (float[2]){100.f, 30.f}, (float[2]){400.f, 150.f});

// 2) Wait until sufficient contact force is detected on Z-axis
bool contact = false;
while (!contact) {
    contact = drfl.check_force_condition(FORCE_AXIS_Z, 15.f, 30.f, COORDINATE_SYSTEM_TOOL);
}

printf("Contact detected (Z-force 15–30 N). Proceeding to next step.\n");

// 3) Once contact detected, apply force control
float fTarget[6] = {0.f, 0.f, 25.f, 0.f, 0.f, 0.f};
unsigned char dir[6] = {0, 0, 1, 0, 0, 0};
drfl.set_desired_force(fTarget, dir, COORDINATE_SYSTEM_TOOL, 0.3f);

Notes & Best Practices

  • check_force_condition() compares the absolute magnitude of the force or torque (sign ignored).

  • Useful for contact detection, insertion feedback, or load verification.

  • Combine with check_position_condition_abs or check_position_condition_rel for hybrid force–position conditions.

  • Apply appropriate thresholds to prevent false triggers caused by minor sensor noise.

  • For multi-axis monitoring, call the function separately per axis or integrate it in custom logic loops.

  • To implement active force response after detection, combine with set_desired_force and release_force.