RobotStudio event

Getting Link position

Good morning,
I am developing an add-in in RobotStudio that needs to extract the position and orientation of Link4, Link5 and Link6 of the robot. Yesterday I tried the following code, but I got some values that were not correct, or at least not where I expected them to be.

This is my code:
foreach (GraphicComponent gc in robot.GraphicComponents)
            {
                Logger.AddMessage(new LogMessage(gc.Name + " => X: " + gc.Transform.X + " | Y: " +  gc.Transform.Y + " | Z: " + gc.Transform.Z + " | RX : " + gc.Transform.RX + " | RY : " + gc.Transform.RY + " | RZ : " + gc.Transform.RZ));
            }

Am I doing it wrong? Is there another way to get this value?
Thanks in advance,
Stefano

Answers

  • ssickss
    ssickss
    edited September 6
    I think i figured it out.

    By using Mechanism.GetJointTransform(int index) and passing it the index of the joint you want to find, you will get a matrix with the position and orientation of the joint (its Euler XYZ and Euler ZYX)
    Post edited by ssickss on
  • DenisFR
    DenisFR ✭✭✭
    Hello,
    You can have a look how I update a virtual mechanism with a real one here:

  • Hello @DenisFR,
    thanks for your time and for your response,

    I see that you extracted the robot joints via
    Mechanism.GetJointValues()

    So I think that this is the correct way to go, to use the values inside Mechanism and not GraphicComponents, so:
    *To get joint values of the robot you use Mechanism.GetJointValues(), that returns an array of double as result;
    *To get the position and the orientation of the link of the joints you use Mechanism.GetJointTransform(), which gives you a Matrix4 result. Inside of it you can look for Transform and EulerXYZ/EulerZYX rotation values.