Hello again!
With this I think I have a rather specific concern, so because of that I will clarify the context at first, which can be a lot of reading for all the lazy people out there ![]()
I’m currently working on a project for an measuring application on an IRB 6700 for product quality. The basic functionality of this program should be a simple cycle between moving along a path around a workobject, stopping when the TCP reaches a predefined position, executing a measurement routine, returning to the path and then moving to the next position.
So far I have the whole project prepared in a RobotStudio station, where I have created the robtargets for my measuring points. Then I duplicated these targets with an offset to the part and created an collision free path along these offset targets to efficiently position the robot. In the rapid module I declared an array for the robtargets and jointtargets to be able to cycle through these positions in a single loop.
And here it gets interesting: As there can be multiple jointtargets for the robot to reposition between two measurement points the array counters won’t be matched when running the procedure. So I now needed to find a way to tell the robot, when it is in the correct position to execute the measuring routine. To test the functionality of all the other procedures at first I just wrote a list of array counter values for the correct positions, that trigger an IF condition.
IF h = 4 AND h = 7 AND h = 12 AND …
And that would be just fine, but the point here is that I want to design this module have cross compability along every different measuring object I want to import into the station. Also there can be a lot of positions that will be measured on the part.
An initial solution for the definition of the IF condition was to replace the counter values with a TCP check. I basically read the TCP position after every move cycle with CRobT and a comparison should check if the TCP matches the position of one of the predefined Robtargets for the measuring points.
PROC target_selection()
FOR g FROM 1 TO 31 DO
MoveAbsJ E{g},v_swap,fine,tooldata_1\WObj:=WO_1;
Waittime 1;
checkpos:=Crobt(\Tool:=tooldata_1\WObj:=WO_MIKO);
pos1x:=Round(checkpos.trans.x\Dec:=1);
pos1y:=Round(checkpos.trans.y\Dec:=1);
pos1z:=Round(checkpos.trans.z\Dec:=1);
f := FALSE;
WHILE f = FALSE DO
target:=D{h};
pos2x:=Round(target.trans.x\Dec:=1);
pos2y:=Round(target.trans.y\Dec:=1);
pos2z:=Round(target.trans.z\Dec:=1);
IF pos1x = pos2x AND pos1y = pos2y AND pos1z = pos2z THEN
t_mes;
h := 1;
f := TRUE;
ELSEIF h = 14 THEN
h := 1;
f := TRUE;
ELSE
Incr h;
ENDIF
ENDWHILE
ENDFOR
ENDPROC
As you can see in the while loop I have to round the coordinate entries because the robot will always have a small deviation from the desired position, which depends on load and speed. This code generally works as intended but I also lose precision. I’m still pretty new to RAPID and don’t know all features or tricks there are so maybe some of you RAPID veterans knows a better way to do this.