get_workpiece_weight()
Features
This function measures and returns the weight of the workpiece from external forces. Since the weight measurement may include residual errors due to sensor inaccuracies, measurement posture, or incorrect tool settings, it is recommended to use the reset_workpiece_weight command to eliminate residual errors in advance.
Caution
In the Non-FTS A & E model, this function cannot be used.
Return
| Value | Description |
|---|---|
Positive value | Measured weight |
Negative value | Error |
Exception
| Exception | Description |
|---|---|
DR_Error (DR_ERROR_RUNTIME) | C extension module error occurred |
DR_Error (DR_ERROR_STOP) | Program terminated forcefully |
Example
set_tool("2kg") # Actual tool weight is 2.2kg, set tool weight is 2kg
reset_workpiece_weight() # Initialize the residual error of 0.2kg before measuring the workpiece weight
movel([0, 0, -200, 0, 0, 0], v=30, a=30, ref=DR_TOOL, mod=DR_MV_MOD_REL) # Move to the position to grab the workpiece
set_modbus_output("gripper", DR_ON) # Grab the workpiece
movel([0, 0, 200, 0, 0, 0], v=30, a=30, ref=DR_TOOL, mod=DR_MV_MOD_REL) # Move to the position to measure the workpiece
weight = get_workpiece_weight() # Actual added workpiece weight is 2kg, measured workpiece weight is 2kg
set_workpiece_weight(weight, add_up=DR_ADD) # Total set workpiece weight is 6kg