Calculating Euler Angles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Two common methods for defining a working plane for 3+2 machining is to use the actual rotary table positions to define the working plane, typically on machines that don’t support TCP, or to output a G68.2 style block using Euler angles. HSM post processors have access to functions that will define the Euler angles for a given tool orientation using the Matrix.euler--- attributes, where ‘---‘ designates the rotation order for the axis rotations defining the Euler angles, for example XYZ, YZY, etc.
The programming manual for each control will define whether it expects Euler angle input and what order the rotations are in. In the current version of HSM the rotation order does not match up with the designated rotation order in the Matrix.euler--- attributes, which makes it difficult to get the desired rotations for the G68.2 block. The following table contains a list of the possible Euler angle rotation orders and the corresponding Matrix.euler--- attributes to use to obtain the proper rotation values for these orders.
Rotation Order Matrix Attribute XYX eulerXZX_R XYZ eulerZYX_R XZX (no solution) XZY eulerYZX_R YXY eulerXYX_R YXZ eulerZXZ_R YZX eulerZYZ_R YZY eulerXYZ_R ZXY (no solution) ZXZ (no solution) ZYX (no solution) ZYZ eulerYXZ_R
A new function Matrix.getEuler2() has been added to the post processor so that the requested Euler angles match the specified order. The argument passed to the getEuler2 function defines the order of the Euler angle calculations, such as EULER_XZX_R, EULER_XYZ_R, etc. To use this new function and add backward support for previous versions of HSM you will need to use code similar to the following example.
eulers = workPlane.getEuler2 ? workPlane.getEuler2(EULER_XYZ_R) : workPlane.eulerZYX_R;
Notice that Euler angle orders in the two methods do not match in the above command. The eulerZYX_R attribute is taken from the above table that shows the corresponding Euler order for the proper Euler angle calculation order.
The euler2.cps post processor is furnished in this post. You can use this post processor to gain a better understanding of Euler angles, to test the Euler angle calculations, and to help to determine the correct Euler angle order to use when sample output from another CAM system is provided. When you post against euler2.cps using the default property settings it will calculate the Euler rotations for each possible Euler order and output the results in a .dmp file.
Order Results Euler Angles Forward Vector Right Vector XYZ good -119.805, 29.406, -130.601 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 XYX good 127.371, 124.538, 53.413 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 XZX good -142.629, -124.538, -36.587 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 XZY good 90, -41.41, 139.107 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 YXY good -138.59, -90, -40.893 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 YXZ good 131.41, -49.107, 90 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 YZX good -138.59, 40.893, -90 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 YZY good 131.41, 90, 49.107 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 ZXY good -90, 48.59, -130.893 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 ZXZ good 146.995, 115.659, 33.69 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 ZYX good 130.893, -30, 120 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491 ZYZ good -123.005, -115.659, -56.31 0.5, 0.75, -0.433 -0.5669, 0.6614, 0.491
You can then find the output rotations that match the known rotations and use the corresponding Euler angle order in your post. If you are using a version of HSM that does not support the new getEuler2 function, then the results will list BAD for every possibility (some may be marked as good for common 90 degree rotations), which you can ignore and you will use the Euler Matrix attribute listed in the table that has the rotations that correspond to your requirements.
If you know the required Euler angles, forward vector (tool axis), and optionally the right vector (X-axis) of the work plane, then you can enable the findAngleOrder property and enter these values into their associated properties. You can run the post against any model and only the angles and vectors entered into the property table will be tested. The output .dmp file will only display the results that match the specified angles and vectors. Once again if the getEuler2 function is not supported, then you will have to use the associated Matrix attribute listed in the table that corresponds to the returned Euler order displayed in the .dmp file.
Order Results Euler Angles Forward Vector Right Vector XYZ good -90, 0, -135 0.7071, 0.7071, 0 -0.7071, 0.7071, 0

Bob Schultz
Sr. Post Processor Developer
