.. _get_workpiece_weight: get_workpiece_weight ------------------------------------------ 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. The returned value represents the workpiece component of the total payload (excluding tool weight). **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp float get_workpiece_weight() { return _get_workpiece_weight(_rbtCtrl); }; **Parameter** |br| None **Return** .. list-table:: :widths: 25 75 :header-rows: 1 * - **Value** - **Description** * - float - Measured workpiece weight in kilograms (kg). .. Caution:: Ensure the servo is on and the arm is stationary before calling. After the measurement completes, the function sends a slow stop, the same as :ref:`stop(STOP_TYPE_SLOW) `, which stops any motion in progress. **Example** .. code-block:: cpp // Measure the current workpiece weight float weight = drfl.get_workpiece_weight(); // Print the measured weight value printf("Current workpiece weight: %.3f kg\n", weight); This example measures the current workpiece weight and prints the value to the console for verification or monitoring.