R12 search for the corners of a steel plate



How the search is done:
First a vertical search for the plate surface: create a Cartesian route row, 51 positions 1 mm apart on Z (1mm chosen for best straightness). The route can be created anywhere in the workspace so long as it is exactly vertical. Send the robot to an approximate position over the first corner area. The video uses a learned position for each corner but you can also use the teach pad (Cartesian mode). START-HERE shifts the route to start where the robot now is, and the line therefore descends through the plate. CRUN hands over the route to the DSP leaving the CPU free. We used a low speed but high acceleration so the robot can stop quickly. The CPU meanwhile checks the sensor in a loop. As soon as the sensor changes state the CPU tells the DSP to stop and asks it where it got to using DSPASSUME. Trig forward kinematics are used to find out the exact X-Y-Z position of that edge to the nearest 0.1mm. The same procedure is repeated using a straight line in the Y axis and using START-HERE to start the line where it just finished the previous (vertical, Z) search. The robot shifts back in 2mm and searches again using a straight line in the X axis. Finally forward kinematics are used to find out the exact X-Y-Z position of that corner. The procedure is repeated for the other 3 corners and we now have the dimensions of the plate as well as it's orientation as it is slightly tilted in 2 directions.
Here is an example definition for the vertical search. X and Y are similar.
: SENSOR PB 7 ; ( CONNECTED TO PORT B BIT 7 )
: ZSEARCH
ZLINE
START-HERE
SLOW
CONTINUOUS
CRUN
BEGIN
  SENSOR BIT? 0= IF STOP THEN
?RUN 0= UNTIL ( WAIT FOR ROBOT TO STOP )
DSPASSUME ( GET COUNTS FROM THE DSP )
COMPUTE ( FORWARD KINEMATICS )
;