Get current position in UFRAME

  • Hello,

    In a Karel program, I want to get the current TCP position in UFRAME.
    I can't simply use the function CURPOS(i,j) since it gives the TCP cartesian position and the coordinates are not the same as in UFRAME..

    Can you help me please?

  • Alternately you can use the ':' operator to get the position of the TCP expressed in the Frame you want.

    ex :

    position = POS(0.0, 0.0, 100.0, 0.0, 0.0, 0.0, C)
    tool_in_frm= frame:position

    tool_in_frm should have the [0, 0, 100, ...] coordinates calculated in the user frame.

  • Thank you for your help!

    I get the same coordinates with the CURPOS function and with this code..
    Before editing your message you wrote something about the utool, now you deleted this line, was it not necessary?

  • This program seems to work when I check the contents of currentp.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • User frames are defined with respect to the world frame; so you should set the frame to an XYZWPR position with all elements 0. Either create your own zeropos variable, or use the sysvar $MOR_GRP[1].$NILPOS

  • You do not even need karel for this if you only want to get the coordinates in the CURRENT selected frame.

    There are some system variables where you can get this info, just check this ones:

    $SV_INFO[1].$CART_POS -> Actual position in the World coordinates.

    $SV_INFO[1].$CART_POS_UF -> Actual position in the current selected uframe.

    I use the second one a lot while in BG logic in order to capture an orientation when a sensor is triggered, it works pretty well. I suppose you can also use it inside a karel routine if you need to.

    Edit: ohh, sorry, I haven't seen this was a necro, but I think it may be usseful for anyone who needs to do this on the future.

  • Are you able to change the uframe? if you are insert new line before position and insert UFRAME_NUM=

    And after the = add you desired uframe number. After the postion insert another UFRAME_NUM= and add after the equals the other uframe you had on before.

    Hope this helps

Advertising from our partners