For information on the latest version, please have a look at 1.33.5.
get_workpiece_weight (Auto Mode)
This section explains how to use get_workpiece_weight during Auto (Run) operations to measure the workpiece weight. The workpiece weight is an essential parameter for accurate motion execution, payload handling, and force/compliance behavior during automated tasks.
Starts a payload measurement and returns the measured workpiece weight in kg, relative to the last reset_workpiece_weight. It does not return the value set with set_workpiece_weight. The arm must be in STANDBY with servo on. A virtual robot returns 0. A refused or unsent measurement also returns 0, so a return of 0 does not distinguish a failure from a zero weight. After the measurement completes, the function sends a slow stop; see get_workpiece_weight.
Typical usage
Measure the payload before running an automated sequence.
Adjust force/compliance behavior based on workpiece load.
Apply dynamic logic (e.g., different motions depending on the weight).
Perform safety validation to ensure a workpiece is held.
Note
Ensure servo is on and the arm is stationary before calling.
It is recommended to call before pick/place, palletizing, or force-controlled tasks.
Example: Checking Workpiece Weight Before Auto Motion
// Measure current workpiece weight
float w = drfl.get_workpiece_weight();
printf("Workpiece weight: %.3f kg\n", w);
// Validate payload before Auto Mode motion
if (w > 0.0f) {
float target[6] = {400.f, 100.f, 300.f, 180.f, 0.f, 0.f};
float vel[2] = {60.f, 30.f};
float acc[2] = {120.f, 60.f};
drfl.movel(target, vel, acc);
}
else {
printf("Warning: No workpiece weight measured.\n");
}
In this example, the robot reads the workpiece weight and verifies that the value is valid before executing an Auto mode motion sequence. This helps ensure stable trajectory generation and safe task execution.
Tips
Always check payload values when switching between different parts.
The result is relative to the last
reset_workpiece_weight; it is not the value set withset_workpiece_weight.Combine with force control tasks for more accurate contact behavior.
A non-zero value is recommended for stable Auto mode motion planning.