Euler Angles from Unit Vectors

  • Hello,

    I have been trying to generate orientation positions for the flange in respect to a single point.

    I chose to calculate the direction of the vector from the tcp position to this point, in which the orientation of X vector from tcp is inversed from this calculated vector, Y vector parallel to the base, and Z vector pointed to the base. The image below shows the original reference frame from the base (Red - X, Green - Y, Blue - Z), the red dot as the point, and the frames with thin lines, the calculated pose.

    4JSYTNE.png


    To obtain the rotation matrix from the unit vectors i simply fit them in each respective column of the matrix:


    Rmat =

    XxYxZx
    XyYyZy
    XzYzZz


    From this link from this forum, i know that Kukas rotation order is Rz-Ry-Rx which then to obtain the Euler angles (A,B,C as kuka uses) is then:

    C = atan2(Yz, Zz)

    B = asin(-Xz)

    A = atan2(Xy,Xx)


    The A,B,C values obtained from this are not however the expected from the image above. The image below is an example using RoboDk to simulate one pose:

    OmvDJLe.png

    Target 2 X vector should have been following the direction of the position of Target 1 to Target 2.


    Am i not able to use the unit vectors in such way to calculate the Euler Angles?

  • AD
  • .. Kukas rotation order is Rz-Ry-Rx ...

    Just one thing:

    Should be: Rz - Ry' - Rx'', means second rotation is around the y-axis already rotated by Rz and third rotation is rotation around the x-axis aleady rotated by Rz and Ry. Now you can think again about your calculations.

  • From this link from this forum, i know that Kukas rotation order is Rz-Ry-Rx which then to obtain the Euler angles (A,B,C as kuka uses) is then:

    C = atan2(Yz, Zz)

    B = asin(-Xz)

    A = atan2(Xy,Xx)


    this calculation only works if angle B is not equal +/- 90 degrees

    Here I would suggest that you are following the suggestion from fubini in the "link"


    I would be also helpful to get the values you are using to make the calculations

    • Helpful

    KUKA has a built in function (At least I thought it was built in):


    Even if you aren't writing this code for KRL, its pretty easy to read this code and convert it to whatever language you are working with. It says that T[,] is an output, but thats only because kuka forces more complicated variables to be declared as outputs. Its actually being used as an input in this scenario. Last note, a lot of other programming languages use radians by default, but not KRL, so keep that in mind if porting this over into a different language.

  • The A,B,C values obtained from this are not however the expected from the image above. The image below is an example using RoboDk to simulate one pose:

    posts #3, #4 and #5 tells you how to calculate the angles correctly.


    Useful would be getting the values you use for the calculation in order to find the problem you have





    Checking you screen shot shows that target 2 is actually the flange coordinate system with an angle b of 135 deg (rough guess)


    angle b must be in the range of +/90 deg. Doing frame2mat and afterwards an mat2frame will correct this (angle a and angle will change their values and angle b will be in the allowed range.


    could this be the problem?

  • Thank you all. I found out the problem was in the way i created the Rotation matrix from the unit vectors of the target frames.

    By constructing it like this i managed to get the Euler angles like i said:

    Rmat =

    XxXyXz
    YxYyYz
    ZxZyZz


    The poses simulated from the script:

    tfT6dqy.jpg


    The results obtained with robodk (inputting the angles manually obtained from the script):

    PwMPub9.jpg



    Checking you screen shot shows that target 2 is actually the flange coordinate system with an angle b of 135 deg (rough guess)


    angle b must be in the range of +/90 deg. Doing frame2mat and afterwards an mat2frame will correct this (angle a and angle will change their values and angle b will be in the allowed range.


    could this be the problem?

    Yes it can be, i am aware of that but ill just make a specific condition for that to give the same orientation or ill implement the code that micahstuh posted from kuka.


    I feel like i made the problem a bit confusing but this was just so i can get the orientation of a pose given the vector from the pose coordinates to the target point in space, and the XZ plane of the orientation. The whole idea is that I define a number of poses, the given angle from the base and the distance to the target. This is mainly to use a camera that has manual focus so it needs to face an object with the same orientation in all poses, but i can also use the same concept for other projects like welding,non planar 3d printing, etc..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now