Stäubli VAL3 Height Measurement: Configuring Z Search

Jason IP3 min read
Other ManufacturerRoboticsTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Measure bag height in VAL3 by capturing the robot pose in the correct frame, applying the distance-sensor correction only to Z, and moving through a verified approach point before commanding the calculated pick point. Do not subtract a six-axis transformation from a scalar sensor value.

Correct the data-type mismatch

The original calculation mixed two incompatible data types: the analog distance reading is a scalar, while a transformation contains six components. Select only the Z component when calculating vertical displacement.

VAL3 expression Purpose
here(tGripper[2],fBagPos1) Capture the current tool pose relative to the bag frame.
LP_pLastPickPOS.trsf.z Read or modify only the pose's Z translation.
appro(pBagPos1,{0,0,zOffset,0,0,0}) Generate an offset pose from the taught bag position.
link(LP_pLastPickPOS,fBagPos1) Associate the local position with the frame used to interpret its coordinates.

If the transformation is stored as an indexed array instead, select its Z element rather than using the entire array. The evidence describes that component as the third transformation element, but the shown VAL3 code uses the clearer .z member.

Choose the height-detection method

Two supported approaches are available. Use the distance sensor when it provides a stable, calibrated measurement. Use an incremental downward search when vacuum feedback or a part-present input can identify contact or acquisition.

Method Decision rule Required protection
Distance-sensor correction Calculate a Z offset from the analog reading and the calibrated sensor-to-pick relationship. Reject a zero signal and verify the corrected pose before descending.
Incremental search Move downward by 0.5 per iteration until vacuum or part feedback becomes true. Enforce a minimum Z limit and execute recovery instead of waiting indefinitely.

Calculate the sensor-based pick position

The completed example moves to a pose 200 above the taught gripping position, validates the analog signal for 5, delays 1 to obtain the measurement, and calculates the pick correction as aioGet(aiDistSensor)-trSensorCal.z. Its comment states that the calibration value is 423, formed from a 200 approach height and a 223 sensor-height difference.

Those values are installation-specific evidence, not universal Stäubli settings. Confirm the sign convention and calibration at the actual tool, sensor, frame, and taught point before enabling the final descent.

// Move to a collision-free position
movej(pFreePosBag,tGripper[2],mNomSpeed)
waitEndMove()

// Measure 200 above the taught gripping position
movej(appro(pBagPos1,trSensor),tGripper[2],mSlowSpeed)
waitEndMove()

// Reject a missing sensor signal
if(watch(aioGet(aiDistSensor)!=0,5))==false
  sErrorMsg="No signal"
  popUpMsg("No Signal")
  return
endIf

delay(1)

// Move through the approach pose, then apply only the Z correction
movel(appro(pBagPos1,{0,0,trSensor.z,0,0,0}),tGripper[2],mVerySlowSpeed)
movel(appro(pBagPos1,{0,0,aioGet(aiDistSensor)-trSensorCal.z,0,0,0}),tGripper[2],mVerySlowSpeed)
waitEndMove()

Use a controlled downward search when needed

A feedback-driven search captures the current pose, decreases its frame-relative Z coordinate, and commands the next linear move. The supplied routine uses increments of 0.5, stops when either vacuum or part-in-gripper feedback becomes true, and checks a Z limit of -415. Treat -415 as a cell-specific table limit that must be replaced with the verified limit for the installation.

  1. Move through collision-free, approach, and taught pick poses using the appropriate tool and frame.
  2. Capture the current search pose with here(tPartTool,fTtable).
  3. Subtract 0.5 from LP_pLastPickPOS.trsf.z and command a slow linear move.
  4. Repeat until vacuum or part feedback is true, but stop and enter recovery if the verified minimum Z is reached.
  5. After a successful pick, save the world-frame pose with pLastPickedPart=here(tPartTool,world) so a later cycle can return near the last successful height.

The saved position is populated at runtime; it is not an additional point that must be taught initially. Keep its valid flag false on the first run or after opening the cell so the program skips the return move until a successful position exists.

Verify the calculation before production

  1. Confirm that the active tool and reference frame match those used for teaching and calibration.
  2. At the measurement pose, compare the analog reading with an independently known bag height and verify the direction of the calculated Z correction.
  3. Run at the shown slow or very slow motion setting and inspect both the intermediate approach pose and final calculated pose.
  4. Test the zero-signal path and confirm that it displays the fault and returns without descending.
  5. For incremental search, test the no-part case and replace the sample indefinite wait with the cell's defined recovery action.

FAQ

How do I get the current robot position in Stäubli VAL3?

Use here(tool,frame), such as here(tGripper[2],fBagPos1). The returned position is expressed relative to the specified frame.

How do I shift only the Z axis of a VAL3 position?

Modify the position's Z translation with an expression such as position.trsf.z=position.trsf.z-0.5, or generate an offset pose with appro(point,{0,0,zOffset,0,0,0}).

Why can I not subtract a VAL3 transformation from a distance reading?

The distance reading is one scalar value, while the transformation contains six components. Extract or address only its Z component, then apply the calibrated scalar correction to Z.

Back to blog