1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Rotating a User Frame by its own Z axis

  • Nation
  • November 29, 2016 at 6:54 PM
  • Thread is Resolved
  • Nation
    Typical Robot Error
    Reactions Received
    546
    Trophies
    9
    Posts
    1,924
    • November 29, 2016 at 6:54 PM
    • #1

    I am trying to rotate a user frame around its own Z axis using TP. I know this is easy to do in Karel, but I do not have the luxury. Has anyone done anything like this before?

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

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

  • lexx905
    Reactions Received
    11
    Trophies
    3
    Posts
    82
    • November 29, 2016 at 7:24 PM
    • #2

    You can update any coordinate UFrame

    PR[GP1:3,1]=651.349 ;
    PR[GP1:3,2]=(-3.139) ;
    PR[GP1:3,3]=1500.34 ;
    PR[GP1:3,4]=0 ;
    PR[GP1:3,5]=0 ;
    PR[GP1:3,6]=AR[1] ;

    UFRAME[1]=PR[3] ;

  • Nation
    Typical Robot Error
    Reactions Received
    546
    Trophies
    9
    Posts
    1,924
    • November 29, 2016 at 7:53 PM
    • #3

    That works if the the user frame's z axis is lined up with the robot's z axis, but I need to rotate around the user frame's z axis for a frame in any orientation relative to the robot's coordinate system. A general solution.

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

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

  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • November 30, 2016 at 1:07 AM
    • #4

    I have found two ways to do this, a good way and a hacky way.

    Good way: If you purchase the vision support tool option, which is cheap, it includes a matrix math function. Done.

    Hacky way: Move the robot to the origin point, with an R offset applied. Set UFrame_num=0, then record LPOS into a PR. Finally, set your UF = to that PR. (In fact it doesn't even have to be at the origin, but that reduces the math you need to do.)

    Sent from my VS985 4G using Tapatalk

    Edited once, last by HawkME (November 30, 2016 at 1:09 AM).

  • Nation
    Typical Robot Error
    Reactions Received
    546
    Trophies
    9
    Posts
    1,924
    • November 30, 2016 at 6:03 PM
    • #5
    Quote from HawkME


    Hacky way: Move the robot to the origin point, with an R offset applied. Set UFrame_num=0, then record LPOS into a PR. Finally, set your UF = to that PR. (In fact it doesn't even have to be at the origin, but that reduces the math you need to do.)

    I was originally considering going this way, but while manipulating the $MCR_GRP[1].$MACHINELOCK to lock motion while I did the move, so it was hidden from the user. I didn't as it felt really hacky, as you said.

    I did find a way to do it without buying anything, and in TP. I do it by using the matrix representation of a PR to do matrix multiplication manually. Nice thing about this code, is that with two line changes, you can tell it to rotate about a user frame's X or Y axis as well.

    Here is my code:

    Code
    /PROG  RZ_UFRAME	  Macro  
    /ATTR                          
    OWNER		= MNEDITOR;            
    COMMENT		= "Rotate UF about Z";
    /APPL
    /MN
       :  ! AR[1] is the UFrame index ;
       :  ! AR[2] is the amount of ;
       :  ! degrees ;
       :  !Store passed in arguments ;
       :  R[80:ARG 1]=AR[1]    ;
       :  R[81:ARG 2]=AR[2]    ;
       :   ;
       :  !Check argument values. ;
       :  IF R[80:ARG 1]<1 OR R[80:ARG 1]>9,CALL FAULT(1) ;
       :  IF R[81:ARG 2]<(-180) OR R[81:ARG 2]>180,CALL FAULT(1) ;
       :   ;
       :  !Tell the robot to store frames ;
       :  ! as transform rep. ;
       :  $PR_CARTREP=(0) ;
       :   ;
       :  !Store the frame we want to ;
       :  ! shift as transform rep. ;
       :  PR[90:Scratch1]=UFRAME[R[80]] ;
       :   ;
       :  !Force the following PR as a ;
       :  ! cart rep ;
       :  PR[91:Scratch2]=LPOS    ;
       :  PR[91,1:Scratch2]=0    ;
       :  PR[91,2:Scratch2]=0    ;
       :  PR[91,3:Scratch2]=0    ;
       :  PR[91,4:Scratch2]=0    ;
       :  PR[91,5:Scratch2]=0    ;
       :  PR[91,6:Scratch2]=R[81:ARG 2]    ;
       :   ;
       :  !Frame 9 is a temp storage ;
       :  ! frame. Use it to convert the ;
       :  ! above PR from cart rep to ;
       :  ! transform rep. ;
       :  UFRAME[9]=PR[91:Scratch2] ;
       :  PR[91:Scratch2]=UFRAME[9] ;
       :   ;
       :  !Set PR[92] as a transform rep ;
       :  ! by setting it to an existing ;
       :  ! transform rep. ;
       :  PR[92:Scratch3]=PR[90:Scratch1]    ;
       :   ;
       :  !Preform matrix multiplication ;
       :  ! of only the rotation portion ;
       :  ! of the two matricies. ;
       :  PR[92,1:Scratch3]=((PR[90,1:Scratch1]*PR[91,1:Scratch2])+(PR[90,4:Scratch1]*PR[91,2:Scratch2])+(PR[90,7:Scratch1]*PR[91,3:Scratch2])) ;
       :  PR[92,2:Scratch3]=((PR[90,2:Scratch1]*PR[91,1:Scratch2])+(PR[90,5:Scratch1]*PR[91,2:Scratch2])+(PR[90,8:Scratch1]*PR[91,3:Scratch2])) ;
       :  PR[92,3:Scratch3]=((PR[90,3:Scratch1]*PR[91,1:Scratch2])+(PR[90,6:Scratch1]*PR[91,2:Scratch2])+(PR[90,9:Scratch1]*PR[91,3:Scratch2])) ;
       :  PR[92,4:Scratch3]=((PR[90,1:Scratch1]*PR[91,4:Scratch2])+(PR[90,4:Scratch1]*PR[91,5:Scratch2])+(PR[90,7:Scratch1]*PR[91,6:Scratch2])) ;
       :  PR[92,5:Scratch3]=((PR[90,2:Scratch1]*PR[91,4:Scratch2])+(PR[90,5:Scratch1]*PR[91,5:Scratch2])+(PR[90,8:Scratch1]*PR[91,6:Scratch2])) ;
       :  PR[92,6:Scratch3]=((PR[90,3:Scratch1]*PR[91,4:Scratch2])+(PR[90,6:Scratch1]*PR[91,5:Scratch2])+(PR[90,9:Scratch1]*PR[91,6:Scratch2])) ;
       :  PR[92,7:Scratch3]=((PR[90,1:Scratch1]*PR[91,7:Scratch2])+(PR[90,4:Scratch1]*PR[91,8:Scratch2])+(PR[90,7:Scratch1]*PR[91,9:Scratch2])) ;
       :  PR[92,8:Scratch3]=((PR[90,2:Scratch1]*PR[91,7:Scratch2])+(PR[90,5:Scratch1]*PR[91,8:Scratch2])+(PR[90,8:Scratch1]*PR[91,9:Scratch2])) ;
       :  PR[92,9:Scratch3]=((PR[90,3:Scratch1]*PR[91,7:Scratch2])+(PR[90,6:Scratch1]*PR[91,8:Scratch2])+(PR[90,9:Scratch1]*PR[91,9:Scratch2])) ;
       :   ;
       :  !Store the newly rotated frame ;
       :  ! back. ;
       :  UFRAME[R[80]]=PR[92:Scratch3] ;
       :   ;
       :  !Tell the robot to store frames ;
       :  ! as cart rep. ;
       :  $PR_CARTREP=(1) ;
    /POS
    /END
    Display More

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

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

    Edited once, last by Nation (November 30, 2016 at 6:59 PM).

  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • November 30, 2016 at 7:24 PM
    • #6

    Nice bit of code there and free is always good!

    The Vision Support Tools is about $200 list price and includes some other nice functions. If you are interested here is what the same code looks like with that option.


    Simple case of rotating 90 degrees.

    Code
    :  PR[3:A MATRIX]=UFRAME[1] ; <-could use Argument here
    :;
    :  PR[4]=PR[4]-PR[4];
    :  PR[4,3]=90; <-could use argument here
    :;
    :  !PR5 = PR3*PR4, R6=ERR CODE ;
    :  CALL MATRIX(3,4,5,6) ;
    :  UFRAME[1]=PR[5:C MATRIX] ;
  • Nation
    Typical Robot Error
    Reactions Received
    546
    Trophies
    9
    Posts
    1,924
    • November 30, 2016 at 8:48 PM
    • #7

    Ha, pretty amazing to see the ~70 lines of code reduced to 6.

    For $200 I should have just went that route. Probably a wash at that price. I assumed it would be the Fanuc standard of $500.

    Kinda of annoying that on the R30iA controller I could have just dropped in the matrix.pc file and been done. At least this was an interesting challenge.

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

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

  • hoitzing
    Reactions Received
    24
    Trophies
    1
    Posts
    128
    • June 21, 2023 at 1:27 PM
    • #8
    Quote from Nation

    I know this is easy to do in Karel, but I do not have the luxury.

    I do have the luxury, but am wondering how you would achieve this in an easy way in Karel? I can handle rotation matrices, but I'm new to computations/manipulations with rotations expressed in euler angles.

    My approach would be:

    1) manually express the user frame's WPR rotation as a rotation matrix R_uf

    2) multiplying matrix R_uf by a rotation matrix around the specified axis (R_z in your example) to get R_uf' = R_uf*Rz

    3) translating R_uf' back into WPR/euler angle representation.

    I'm interested to know if I can save some complexity here

    EDIT:

    The penny might just have dropped.. Would this work:

    1) create a new XYZWPR P at the user frame's origin, with the desired rotation around Z (all elements 0, except P.R=[angle])

    2) express the position in world coordinates (UF : P)

    3) set the outcome as a user frame

    and it's as simple as that?

    EDIT2: yes it is! just tested it

    Edited 2 times, last by hoitzing: tested (June 21, 2023 at 3:01 PM).

  • Chris0402
    Posts
    3
    • December 3, 2024 at 1:19 PM
    • #9

    Hallo,kämpfe seit einiger Zeit mit einem Problem,ich bekomme durch eine MIR eine Palette zum Roboter gebracht diese stellt die Material Palette aber nie 100 % gleich ab. Ich nehme mit einem Sensor 2 Punkte und rechne mit den werten in der PR Matrix die verdrehung aus ,was ich nicht hin bekomme ist den Versatz in X und Y der da durch ensteht zu korregieren. Beispiel :

    UF 1 vom World X : 2070 Y : 300 Z : -600 W : 0 P : 0 R : 90

    Jetzt drehe ich das UF 1 um 2 Grad dann wird daraus :

    UF 1 vom World X : 2070 Y : 300 Z : -600 W : 0 P : 0 R : 92

    Also X und Y sind immer noch gleich,In Robquide kann ich das UF ja beliebig verschieben und mein Problem simulieren und sehe die geänderten Werte im UF . Und dann sieht das so aus :

    UF 1 vom World X : 2092.05 Y : 317.83 Z : -600 W : 0 P : 0 R : 92

    So liegt das UF wieder geau auf der ecke meiner Palette,ich weis nur nicht wie ich das im TP Programm errechnen kann. Kann mir vieleicht jemand helfen ?


    Gruss Chris

  • HalbesYoyo
    Persona non grata
    Reactions Received
    47
    Trophies
    3
    Posts
    151
    • December 3, 2024 at 1:29 PM
    • #10

    Hi Chris,

    dies ist das englischsprachige Forum. Wenn Du Dein Anliegen in Englisch formulierst, wirst Du vermutlich mehr/bessere Hilfe erhalten. :winking_face:

    Alternativ kannst Du auch im deutschsprachigen Forum fragen:

    https://www.roboterforum.de

    ---

    Hi Chris,

    this is the english forum. If you ask in english you probably will get more / better help. :winking_face:

    Alternatively, you can also ask in the German-language forum.

    https://www.roboterforum.de

  • Chris0402
    Posts
    3
    • December 3, 2024 at 1:36 PM
    • #11

    Sorry ,

    Hello, I've been struggling with a problem for some time. I get a pallet brought to the robot via a MIR. But the robot never places the material pallet 100% evenly. I take 2 points with a sensor and calculate the rotation using the values in the PR matrix. What I can't do is correct the offset in X and Y that this creates. Example:

    UF 1 from World X: 2070 Y: 300 Z: -600 W: 0 P: 0 R: 90

    Now I rotate the UF 1 by 2 degrees and it becomes:

    UF 1 from World X: 2070 Y: 300 Z: -600 W: 0 P: 0 R: 92

    So X and Y are still the same. In Robquide I can move the UF as I like and simulate my problem and see the changed values in the UF. And then it looks like this:

    UF 1 from World X: 2092.05 Y: 317.83 Z: -600 W: 0 P: 0 R: 92

    So the UF is again exactly on the corner of my palette, I just don't know how to calculate that in the TP program. Can someone help me?

    Regards Chris

  • hermann
    Reactions Received
    407
    Trophies
    9
    Posts
    2,614
    • December 4, 2024 at 8:50 AM
    • #12

    You can't calculate the rotation and complete shifting of the pallet with only two measurement points. You need a third measurement.

  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • December 4, 2024 at 11:45 PM
    • #13

    Actually there is a way in this specific scenario since you have a fixed origin point and fixed W and P angles.

    You need to matrix multiply the original UF with a PR that only has that angle correction in the R element, and everything else set to 0. Then the resulting PR will be your corrected user frame.


    I use that method frequently with only 2 points.

  • Chris0402
    Posts
    3
    • December 5, 2024 at 8:54 AM
    • #14

    Hello, does anyone have an example of how I can calculate the rotation around Z and the displacement in X and Y?

    Images

    • Rotation Z OK X and Y not OK.png
      • 83.78 kB
      • 888 × 722
      • 10
  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • December 6, 2024 at 12:56 AM
    • #15

    It's all covered in this thread. Read from the top.

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download