RobotStudio event

TCP Position check

grth46
grth46
edited October 10 in RAPID Programming
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 :wink:

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.
Post edited by grth46 on

Comments

  • DenisFR
    DenisFR ✭✭✭
    Hello,
    You can use Distance function for that.
    You can found all information in "RAPID Instructions, Functions and Data types" documentation under RS File-Help pane.
  • DenisFR said:
    Hello,
    You can use Distance function for that.
    You can found all information in "RAPID Instructions, Functions and Data types" documentation under RS File-Help pane.

    Hi Denis, thanks for your reply. I looked up the distance function in the instruction manual, but I'm not sure how I should include this function in my module. The Distance function basically calculates the length of a vector between two points and returns the value as a variable of datatype num.

    I assume you think that with this it may be possible to calculate the deviation between the desired position and the actual position the TCP arrived to and therefore compensate. But the fuction only calculates length, not direction and how should this help with accuracy?

  • DenisFR
    DenisFR ✭✭✭
    edited October 11
    Hello,
    Instead check each coordinate, you can use directly trans.
    IF Distance(checkpos.trans,D{h}.trans)<0.01 THEN
    In the same time, you can convert your jointtarget directly as robtaget using CalcRobT
    IF Distance(CalcRobT(E{g},tooldata_1\WObj:=WO_MIKO,D{h}.trans)<0.01 THEN
    To be sure your robot is at its position you can use:
    MoveAbsJ E{g},v_swap,fine,tooldata_1\WObj:=WO_1;
    WaitTime\InPos,1;

  • Hello Denis,
    I managed to use the distance function in my module for this application and it works as intended. I have to say that I hoped that there would be a generally different approach to check if my robot is in the correct spot despite the comparison of TCP position, but your advice definetly helped to further simplify my code without losing any functionality.
    So thank you for that!