RobotStudio event

TCP Orientation shift

Hi, how can we shift the Defined TCP(TCP&Z) orientation. I needed the TCP to be shifted in /Rz by a given angle in the declaration. Is it possible to do it instead of creating new TCP with Elongated z and x.

Thanks in Advance!

Best Answers

  • Elderwild
    Elderwild
    Answer ✓
    If you know the angle you need to change it to, you should be able to use a Quaternion calculator set to the current values, then input the Euler angle change to give you the new Quaternion values, which you should be able to manually update for the desired TCP.
  • Elderwild
    Elderwild
    Answer ✓
    Hi Elderwild,
    Thank you for the solution. Actually I tried to do the same but couldn't find a user friendly Quaternion calculator. Can you suggest me one if possible. Will be very helpful. 
    AlanVictor,

    Here is a pretty good one I just got from one of our integrators. It might take a bit to get set up to the current values. It looks like you may be able to import what you have. I haven't had a ton of time to play with it yet so give it a shot.
    https://www.tobynorris.com/work/prog/csharp/quatview/
  • lemster68
    lemster68 ✭✭✭
    Answer ✓
    I prefer Rapid.

    %%%
      VERSION:1
      LANGUAGE:ENGLISH
    %%%
    
    MODULE TCP_ValuesZYX
      VAR num anglex;
      VAR num angley;
      VAR num anglez;
      VAR num nFKAnswer;
      PERS orient orient2:=[0.707107,0,-0.707107,0];
    
      PROC convert_toZYX()
        anglex:=EulerZYX(\X,orient2);
        angley:=EulerZYX(\Y,orient2);
        anglez:=EulerZYX(\Z,orient2);
      ENDPROC
    
      PROC query_tcp()
        VAR num q1;
        VAR num q2;
        VAR num q3;
        VAR num q4;
    
        TPReadNum q1,"Please enter the value for q1";
        TPReadNum q2,"Please enter the value for q2";
        TPReadNum q3,"Please enter the value for q3";
        TPReadNum q4,"Please enter the value for q4";
        orient2.q1:=q1;
        orient2.q2:=q2;
        orient2.q3:=q3;
        orient2.q4:=q4;
        convert_toZYX;
        TPWrite "The Euler angle x is "\Num:=anglex;
        TPWrite "The Euler angle y is "\Num:=angley;
        TPWrite "The Euler angle z is "\Num:=anglez;
        TPWrite "Thanks for using Lee Justice's";
        TPWrite "program. :>)";
        TPWrite "Have a great day";
        TPReadFK nFKAnswer,"Press OK to finish",stEmpty,stEmpty,stEmpty,stEmpty,"OK";
      ENDPROC
    ENDMODULE</code>%%%
      VERSION:1
      LANGUAGE:ENGLISH
    %%%
    
    MODULE TCP_adjust
      VAR orient orient1:=[1,0,0,0];
    
      PROC tcp_orient()
        VAR num anglex;
        VAR num angley;
        VAR num anglez;
        VAR num nFKAnswer;
    
        TPWrite "This routine is use to calculate";
        TPWrite "The quaternions based upon EulerZYX";
        TPWrite "angles.";
        TPWrite "Remember EulerZYX goes Z rotation,";
        TPWrite "Then Y rotation,";
        TPWrite "and then X rotation";
        TPReadNum anglex,"Please enter the value for x rotation";
        TPReadNum angley,"Please enter the value for y rotation";
        TPReadNum anglez,"Please enter the value for z rotation";
        orient1:=OrientZYX(anglez,angley,anglex);
        TPWrite "Based upon your inputs,";
        TPWrite "Quaternion 1 is "\Num:=orient1.q1;
        TPWrite "Quaternion 2 is "\Num:=orient1.q2;
        TPWrite "Quaternion 3 is "\Num:=orient1.q3;
        TPWrite "Quaternion 4 is "\Num:=orient1.q4;
        TPReadFK nFKAnswer,"Press OK to Finish",stEmpty,stEmpty,stEmpty,stEmpty,"OK";
      ENDPROC
    ENDMODULE</pre><div><br><pre class="CodeBlock"><code>



    Lee Justice
  • Markus Näslund
    Answer ✓
    If you already have defined a TCP orientation and want to rotate it in its local frame I would use the PoseMult function in RAPID, see example below

        PROC AdjustTCPOrientation(PERS tooldata Tool \num Rz |num Ry |num Rx)
            VAR orient AddOrient;
            VAR num rotX:=0;
            VAR num rotY:=0;
            VAR num rotZ:=0;
            IF Present(Rz) rotZ:=Rz;
            IF Present(Ry) roty:=Ry;
            IF Present(Rx) rotx:=Rx;
            AddOrient:=OrientZYX(rotZ,rotY,rotX);
            TPWrite "Previous orientation for tool "+ArgName(Tool) + ":"\Orient:=Tool.tframe.rot;
            Tool.tframe:=PoseMult(Tool.tframe,[[0,0,0],AddOrient]);
            TPWrite "New orientation for tool "+ArgName(Tool) + ":"\Orient:=Tool.tframe.rot;
        ENDPROC
        
        PROC ExampleUse()
            
            AdjustTCPOrientation myTool \Rz:=45;
    
        ENDPROC
    
    Br
    Markus
    //Markus Näslund

Answers

  • Hi Elderwild,
    Thank you for the solution. Actually I tried to do the same but couldn't find a user friendly Quaternion calculator. Can you suggest me one if possible. Will be very helpful. 
  • Lemster, as always, YOU ROCK! 
    Markus, Neat and to the Point, you Rock as well.

    Thanks for showing me up, yet again with your vastly greater experience and knowledge base.


  • Thank you Lemster and Markus. Both the answers are very much convincing. 
    Thank you Elderwild for the software. Will definitely be useful for me.
  • If you want you can download a software I made some years ago that converts from EulerZYX to Quaternions and back. It also has some functionality that makes life a little easier, like paste a robtarget in q1 and the software will find the quaternions and paste all four at once etc.

    Here is a link if you trust me enough to try it :) 
    https://www.dropbox.com/s/z0zv2wmyz8q0zap/EulerToQuaternion_1.2.0.1.zip?dl=0



    //Markus Näslund
  • I wrote a small function to solve the problem. It corresponds to Markus' solution, is only slightly shorter and can calculate both a rotation and a displacement. The core of the solution is line 6. If you want to understand it, print it out, put it under your pillow and sleep on it for the night.  :)