set_workpiece_weight

This function configures the weight and center of gravity (COG) of the currently mounted workpiece. It combines the tool parameters (set via set_tool) with the workpiece’s own weight and balance information to calculate the total end-effector dynamics used in control and safety calculations.

It is particularly useful for tasks where the workpiece mass changes dynamically or multiple payloads are handled.

Definition
DRFLEx.h within class CDRFLEx, public section

bool set_workpiece_weight(
    float fWeight = 0.0,
    float fCog[3] = COG_DEFAULT,
    COG_REFERENCE eCogRef = COG_REFERENCE_TCP,
    ADD_UP eAddUp = ADD_UP_REPLACE,
    float fStartTime = -10000,
    float fTransitionTIme = -10000
) {
    return _set_workpiece_weight(_rbtCtrl, fWeight, fCog, eCogRef, eAddUp, fStartTime, fTransitionTIme);
};

Caution

  • On firmware before DRCF v3.3.0 and v2.12.1, a workpiece weight is applied only in a collision-mute (high-priority) zone; running outside it with a non-zero weight raises an SS1 protective stop, and the controller can raise a further alarm. On v3.3.0 or later and v2.12.1 or later these checks do not apply.

  • On DRCF v3.3 or later and v2.12.1 or later, the controller applies the new payload only while the robot is not moving.

  • If the robot stops due to an error and needs to be manually restored, place the robot in the desired position in Recovery mode and unload the workpiece through Servo On and I/O operation while the corresponding zones are activated in Auto mode.

  • When the tool weight is changed, the workpiece weight is reset to 0.

  • When calling set_tool and set_workpiece_weight in succession, you must call the wait function between them for transition_time. Otherwise, errors can occur in the weight change.

Parameter

Parameter Name

Data Type

Default Value

Description

fWeight

float

0.0

Workpiece weight in kilograms (kg).

fCog

float[3]

[0, 0, 0]

Center of gravity of the workpiece in millimeters [x, y, z].

eCogRef

COG_REFERENCE

COG_REFERENCE_TCP

Reference coordinate system for the COG.

eAddUp

ADD_UP

ADD_UP_REPLACE

Behavior when updating workpiece info
DR_REPLACE(0): Replace existing workpiece
DR_ADD(1): Add workpiece data
DR_REMOVE(2): Remove existing workpiece

fStartTime

float

-10000

Start time (in seconds) for the workpiece weight change. -10000 = not specified; the controller uses its automatic value.

fTransitionTIme

float

-10000

Transition time (in seconds) for gradually applying weight change. -10000 = not specified; the controller uses its automatic value.

Return

Value

Description

0

The call was refused.

1

No refusal was received. A return of true does not confirm that the setting was applied.

Example

// Apply new workpiece weight (2.5 kg) with COG at (0, 0, 50 mm)
float fCog[3] = {0.f, 0.f, 50.f};
if (!drfl.set_workpiece_weight(2.5f, fCog))
    printf("set_workpiece_weight was refused.\n");

This example sets a workpiece weight of 2.5 kg with its center of gravity at (0, 0, 50) mm.