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?
Rotating a User Frame by its own Z axis
-
Nation -
November 29, 2016 at 6:54 PM -
Thread is Resolved
-
-
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] ;
-
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.
-
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
-
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
Display More/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
-
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.
-
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.
-
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
-
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
-
Hi Chris,
dies ist das englischsprachige Forum. Wenn Du Dein Anliegen in Englisch formulierst, wirst Du vermutlich mehr/bessere Hilfe erhalten.
Alternativ kannst Du auch im deutschsprachigen Forum fragen:
---
Hi Chris,
this is the english forum. If you ask in english you probably will get more / better help.
Alternatively, you can also ask in the German-language forum.
-
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
-
You can't calculate the rotation and complete shifting of the pallet with only two measurement points. You need a third measurement.
-
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.
-
Hello, does anyone have an example of how I can calculate the rotation around Z and the displacement in X and Y?
-
It's all covered in this thread. Read from the top.