RobotStudio event

External axis GetPosition method


I am using the PC SDK (5.10) to get external values into a .Net application (Visual Studio 2005). I use the following code:

        JointTarget jnt = controller.MotionSystem.ActiveMechanicalUnit.GetPosition();
        textBox1.Text = jnt.ExtAx.Eax_a.ToString();
        textBox2.Text = jnt.ExtAx.Eax_b.ToString();
        textBox3.Text = jnt.ExtAx.Eax_c.ToString();

All ExtAx values are 0, even though actual external axis positions are not 0.

If I use the following code:

        textBox3.Text = exJnt.RobAx.Rax_1.ToString();
        textBox4.Text = exJnt.RobAx.Rax_2.ToString();
        textBox5.Text = exJnt.RobAx.Rax_3.ToString();

then the correct values of the external axis positions are returned. Printing the object exJnt to screen gives:
[eax_a, eax_b, eax_c, eax_d, 0 0] [0 0 0 0 0 0]

Does this mean that I cannot get access to RobAx values?
Why are the Rax values returning Eax values??

I thought that it may have something to do with the ActiveMechanicalUnit property but there is no GetPosition() method associated with MechanicalUnit, as stated in the PC SDK Reference. The PC SDK Reference also states that GetPosition does not support external axes but another thread on this forum says it is supported ( ID=1812&KW=external+axis)

Any help appreciated,
neil2008-4-2 15:37:42


  • Hi Neil,

    I had the same problem. The getposition doesn't return the external axis. You have to walk through the mechanical units with a foreach loop to get the external axis.

    MotionSystem msystem = ctrl.MotionSystem;

    foreach (MechanicalUnit munit in msystem.MechanicalUnits)
    Console.WriteLine("MechUnit " + munit.ToString());
    Console.WriteLine("Tool " + munit.Tool.ToString());
    Console.WriteLine("JointPosition: {0}", munit.GetPosition());

    This is working for me.

  • Hi Neil and Berrie!

    Yes, there is a bug in the PC SDK. The joints values are always copied to the Rax values even though it is an external axis. This will be fixed in the next release. Until then you'll have to do as Berrie described.

    Thank you very much for letting us know about the problem.

    Best Regards,