TLDR; I can convert XYZWPR to Matrix on old controllers, but I can't go back from Matrix to XYZWPR.
I've developed a software package that is used to translate a custom robot scripting language into Fanuc TP code automatically. Part of the setup is a collection of utility TP programs to do things like convert between different pose representations, do specific transforms on poses, etc, and many of these TP programs rely on being able to convert XYZWPR poses into their homogeneous transform / matrix representation, and back again, like so:
I'm now trying to make a version of this project that will work on older versions of the Fanuc TP language. I'm currently developing on version 5.30 (the oldest version available in Roboguide) which runs on an R-J3 controller. From this (Fanuc Robot Forum) post, it seems like the $PR_CARTREP system variable wasn't introduced until a later version, but you can still get the matrix representation by using the UFRAME trick. However, I can't convert any of the poses back. The Matrix representation seems "infectious" in the sense that if you have a pose in Matrix form, copying it into other poses also makes them Matrix-ey and the only way I've discovered so far to change them back is to manually change the representation in the "Data" screen on the pendant.
Any ideas would be very appreciated, Merry Christmas!

Need help switching between XYZWPR and Matrix representation on a RJ3 controller
-
Tarnarmour -
December 27, 2024 at 10:17 PM -
Thread is Resolved
-
-
- Best Answer
You could manually calculate the WPR sections from the rotation matrix, and then place them into a PR with XYZWPR rep element by element.
I've got c# code that does that here. Shouldn't be too hard to convert it to Karel. Converting it to TP would be a bit of a challenge.
-
Tarnarmour
December 30, 2024 at 11:35 PM Selected a post as the best answer. -
Okay it was not very fun but I'm doing it manually now and it works. Here's the relevant code in case any poor soul ends up in the same boat in the future.
Code
Display More1: ! R_TO_ZYX(source) converts a matrix rep in PR[source] into a XYZWPR rep ; 2: R[16] = PR[AR[1], 2]; 3: R[17] = PR[AR[1], 1]; 3: IF R[16] < 1e-5 AND R[16] > -1e-5 AND R[17] < 1e-5 AND R[17] > -1e-5, JMP LBL[1]; 4: CALL ATAN2(R[16], R[17], 19); 5: R[16] = (-1) * PR[AR[1], 3]; 6: R[18] = R[16] * R[16]; 7: R[17] = 1 - R[18]; 8: CALL SQRT(R[17], 17); 9: CALL ATAN2(R[16], R[17], 20); 10: R[16] = PR[AR[1], 6]; 11: R[17] = PR[AR[1], 9]; 12: CALL ATAN2(R[16], R[17], 21); 13: PR[82, 1] = PR[AR[1], 10]; 13: PR[82, 2] = PR[AR[1], 11]; 13: PR[82, 3] = PR[AR[1], 12]; 13: PR[82, 4] = R[21]; 13: PR[82, 5] = R[20]; 13: PR[82, 6] = R[19]; 14: PR[AR[1]] = PR[82]; 15: JMP LBL[99]; 16: LBL[1]; 17: R[16] = PR[AR[1], 3]; 17: R[20] = -90; 18: IF R[16] > 0, JMP LBL[2]; 19: R[20] = 90; 20: LBL[2]; 21: R[16] = PR[AR[1], 8]; 22: R[17] = PR[AR[1], 7]; 23: CALL ATAN2(R[16], R[17], 19); 13: PR[82, 1] = PR[AR[1], 10]; 13: PR[82, 2] = PR[AR[1], 11]; 13: PR[82, 3] = PR[AR[1], 12]; 13: PR[82, 4] = 0; 13: PR[82, 5] = R[20]; 13: PR[82, 6] = R[19]; 14: PR[AR[1]] = PR[82]; 15: LBL[99];