Z Rotation Cubing

Z Rotation Cubing Average ratng: 3,5/5 3399 reviews

Cube rotations (x, y, and z) do not involve the turning of any layers of the cube. Instead, the entire cube is rotated (imagine an x, y, and z axis going through the cube). These are often used to move the cube into a position that makes an algorithm easier to perform. For example, the ZYX convention is equivalent to the sequences z→y→x, x'→y'→z', y→z'→x and y→x→z'. Fortunately, no one describes Euler angles with sequences in which some rotations are about the mobile frame axes and others are about the fixed axes (e.g., sequences like y→z'→x and y→x→z').

My Method

This is the method I currently use to solve a skewb. I came up with it independently and found all the algorithms myself by hand. It's fairly simple, but surprisingly I don't know of anyone else who has come up with this method before.

  • Notation & Algs
  • Beginner's Variation
  • Intermediate Variation
  • Advanced Variation

For simplicity, I'll be using this notation:

This notation is NOT related to FCN I'll be using this instead of FCN because it's much more convenient to describe the algorithms I use. The x, y, and z rotations will be the same rotations as used in FCN.

My method is based off of two very easy algorithms. They're both four moves, and they are the same as the 'sledgehammer' (R' F R F') and the 'hedgeslammer' (F R' F' R) on a 3x3x3 cube. Note that F' L F L' is the same as y' R' F R F', and L F' L' F is the same as y' F R' F' R.

I recommend being familiar with these two algorithms, since you're going to be using them a lot. There are lots of ways to grip the skewb to preform them, there isn't a single best way to do it. Also, figure out for yourself whether you prefer the sledgehammer or hedgeslammer, since you can often control which one you do more often.

These are the four steps:

Step 1 – Solve the first side

Step 2 – Solve the remaining corners

Step 3 – Solve the U center

Step 4 – Solve the remaining centers

The first step is intuitive. Once you become familiar with how the skewb turns, this is an easy step. When you're trying to solve a side for the first few times, the last corner might be a bit tricky. Two-thirds of the time, you will have to take out an already-solved corner in order to solve the last corner. If this is the case, place the corner so that it is in one of the two positions below, and perform the algorithm below it.

L F' L'

R' F R

The second step is where the 4-movers come in. If the upper corners aren't already solved, you will have one of these two cases.

F' L F L'
or
(y2) L F' L' F

R' F R F' (y) R' F R F'
or
L F' L' F (y') L F' L' F

The third step is simple enough.

R' F R F' (y2) R' F R F'
or
F R' F' R (y2) F R' F' R

The last step involves the same algorithms used in step 3. Do a (z) or (z') rotation first, to match one of the cases below.

R' F R F' (y2) R' F R F'
or
F R' F' R (y2) F R' F' R

R' F R F' (y2) R' F R F'
(y2 x')
R' F R F' (y2) R' F R F'
or
F R' F' R (y2) F R' F' R
(y2 x')
F R' F' R (y2) F R' F' R

R' F R F' (y2) R' F R F'
(z2 x')
R' F R F' (y2) R' F R F'
or
F R' F' R (y2) F R' F' R
(z2 x')
F R' F' R (y2) F R' F' R

Z Rotation Cubing

This variation is just like the Beginner's variation, except the second and third steps are combined. These are the steps:

Step 1 – Solve the first side

Step 2 – Solve the opposite side

Step 3 – Solve the remaining centers

The first and third steps are done the same way as in the beginner's variation. There are ten cases for the second step, divided into three categories. The category 2 and 3 cases are eventually reduced to category 1 cases.

Category 1 Cases

F' L F L'

(y2) L F' L' F

(y2) (F' L F L')2
or
(L F' L' F)2


Category 2 Cases

R' F R F' → cat. 1
or
(y2) R' F R F' → cat. 1

R' F R F' → cat. 1
or
(y2) F R' F' R → cat. 1

L F' L' F → cat. 1
or
(y2) L F' L' F → cat. 1

L F' L' F → cat. 1
or
(y2) F' L F L' → cat. 1


Category 3 Cases

R' F R F' → cat. 2
or
F R' F' R → cat. 2

(y2) R' F R F' → cat. 2
or
(y2) F R' F' R → cat. 2

(y) R' F R F' → cat. 2
or
(y2) R' F R F' → cat. 2
or
F R' F' R → cat. 2
or
(y') F R' F' R → cat. 2

This is where it gets a bit crazy. The second and third steps of the intermediate variation are combined into one step.

These are the two steps:

There are 134 cases for the second step. I've organized them into groups based on their 'CLL+U center' case. The sledgehammer and hedgeslammer are named S and H respectively, for simplicity, where the sledgehammer is F' L F L' and the hedgeslammer is L F' L' F. The letter in brackets at the end of algorithm indicate which face is at the Front-Left. Green is (g), orange is (o), blue is (b), and red is (r). In other words, (g) indicates no rotation, (o) indicates a (y) rotation, (b) indicates a (y2) rotation, and (r) indicates a (y') rotation. If an algorithm is missing (indicated by an '-'), it's because it takes 5 sledgehammers/hedgeslammers, making it a bit too inefficient. If you intend to learn these seven cases, I suggest learning optimal algs. For the most of the Last 5 Centers cases, it's not very efficient solving them with sledgehammers and hedgeslammers either. For optimal algorithms, check out Meep's skewb page (note: they're written in FCN).

Click on 'Printable Version' to view all the cases.

If you use a six-axis robot arm, like Mecademic's Meca500 used in this tutorial as an example, you are most probably interested in positioning its tool (end-effector) in various orientations. In other words, you need to be able to program your robot to move its end-effector both to a desired position AND a desired orientation (i.e., to a desired pose). Of course, you can always jog your robot's end-effector or hand-guide it to approximately the desired pose, but this so-called online programming method is tedious and very imprecise. It is much more efficient to calculate and define your desired pose offline. Besides, in order to define the tool reference frame associated with your end-effector (as in the figure shown below), you would need to calculate the pose of that tool reference frame with respect to the flange reference frame.

In 3D space, you need a minimum of six parameters to define a pose. For example, the position of the robot's end-effector, or more precisely of the TCP (tool center point), is typically defined as the x, y and z coordinates of the origin of the tool reference frame with respect to the world reference frame. But how do you then define orientation in space?

'The representation of orientation in space is a complex issue.'

The representation of orientation in space is a complex issue. Euler's rotation theorem states that, in (3D) space, any displacement of a rigid body in such way that a point on the rigid body remains fixed is equivalent to a single rotation about an axis that passes through the fixed point. Accordingly, such rotation can be described by three independent parameters: two for describing the axis and one for the rotation angle. Orientation in space, however, can be represented in several other ways, each with its own advantages and disadvantages. Some of these representations use more than the necessary minimum of three parameters.

The most common way of transforming position coordinates from one Cartesian (3D) reference frame, F, to another, F', is the rotation matrix. This 3×3 matrix can therefore be used to represent the orientation of reference frame F' with respect to reference frame F. However, this representation, while often necessary as we will discover later, is not a compact and intuitive way to define orientation.

Another much more compact way of defining orientation is the quaternion. This form of representation consists of a normalized vector of four scalars. The quaternion is generally used in robot controllers, as it is not only more compact than the rotation matrix, but also less susceptible to approximation errors. Moreover, during an interpolation between two different orientations, the elements of the quaternion continuously change, avoiding the discontinuities inherent in three-dimensional parameterizations such as Euler angles. Nevertheless, the quaternion is rarely used as a means of communication between a user and the controller of the robot because it is unintuitive.

Detailed definition of Euler angles

By far the most common way to communicate an orientation in space to a user, or to allow a user to define an orientation, in a CAD software or in a robot controller, is the use of Euler angles. Because the term Euler angles is often misused, we have prepared this interactive tutorial.

Z Rotation Cubing

'[…] the term Euler angles is often misused […]'

Euler angles are a set (or rather a sequence) of three angles, which can be denoted for example by α, β, and γ. (Often, Euler angles are denoted by roll, pitch, and yaw.) Euler angles are defined as follows: Consider two Cartesian right-handed 3D reference frames, of which one will be arbitrarily called the fixed frame and the other will be referred to as the mobile frame. The two reference frames coincide initially. To define the orientation of a third frame (all three frames share the same origin), the mobile frame is brought, in the order shown below, to coincide with the third frame by rotating the mobile frame

  1. about the x, y, or z axis of the fixed frame or the x', y', or z' of the mobile frame, by α degrees,
  2. then about the x, y, or z axis of the fixed frame or the x', y', or z' of the mobile frame, by β degrees,
  3. and finally about the x, y, or z axis of the fixed frame or the x', y', or z' of the mobile frame, by γ degrees.

The order in which the three rotations is done is important. Thus, we have a total of 216 (63) possible sequences: xyz, yyz, zyz, x'yz, y'yz, z'yz, and so forth. However, a sequence of three rotations in which two consecutive rotations are about the same axis (e.g., yyz) cannot describe a general orientation. In addition, prior to the first rotation, x coincides with x', y coincides with y', and z coincides with z'. Consequently, of all these 216 combinations, there exist only twelve unique meaningful ordered sequences of rotations, or twelve Euler angle conventions: XYX, XYZ, XZX, XZY, YXY, YXZ, YZX, YZY, ZXY, ZXZ, ZYX, ZYZ.

That said, each of the twelve combinations is equivalent to three other sequences. In other words, each Euler angle convention can be described in four different ways. For example, the ZYX convention is equivalent to the sequences zyx, x'y'z', yz'x and yxz'. Fortunately, no one describes Euler angles with sequences in which some rotations are about the mobile frame axes and others are about the fixed axes (e.g., sequences like yz'x and yxz').

Thus, while there are twelve different Euler angle conventions, each is typically described in two different ways: either as a sequence of rotations about the axes of the fixed frame or as a sequence of rotations about the axes of the mobile frame. Therefore, it can be convenient to talk about fixed and mobile conventions, although they are equivalent. For example, the fixed XYZ Euler angle convention is described by the xyz sequence, while the mobile ZYX Euler angle convention is described by the z'y'x' sequence, but both are equivalent, as we will see later.

In robotics, FANUC and KUKA use the fixed XYZ Euler angle convention, while ABB uses the mobile ZYX Euler angle convention. Furthermore, Kawasaki, Omron Adept Technologies and Stäubli use the mobile ZYZ Euler angle convention. Finally, the Euler angles used in CATIA and SolidWorks are described by the mobile ZYZ Euler angle convention.

'At Mecademic, we use the mobile XYZ Euler angle convention.'

At Mecademic, we use the mobile XYZ Euler angle convention, and therefore describe Euler angles as the sequence x'y'z'. Why be different? The reason is that we used to offer a mechanical gripper for handling axisymmetric workpieces (see video), which was actuated by the motor of joint 6. A six-axis robot equipped with such a gripper can only control two rotational degrees of freedom, or more specifically the direction of the axis of joint 6, that is to say the direction of the axis of symmetry of the workpiece. In the chosen Euler angle convention, angles α and β define this direction, while angle γ is ignored because it corresponds to a parasitic rotation that is uncontrollable.

Our applet below will help you understand Euler angles. You can select one of the twelve possible Euler angle conventions by clicking on the x, y, and z boxes of the first, second and third rotation. (The default Euler angle sequence is the one used by Mecademic.) To switch between rotations about the axes of the fixed or mobile frames, you need to double-click on any of these nine boxes. The axes of the fixed frame are drawn in gray while the axes of the mobile frame are in black. Axes x and x' are drawn in red, y and y' in green, and z and z' in blue. Gliding along any of the three blue horizontal arrows with your mouse changes the corresponding Euler angle. Alternatively, you can directly set the Euler angle value (in degrees) in the corresponding textbox below the arrow. Finally, you can drag your mouse over the reference frame to change the viewpoint.

Your browser does not support SVG
α : β : γ :
R = Rx(0°) Rx(0°) Rx(0°) =
n/an/an/a
n/an/an/a
n/an/an/a

Calculating Euler angles via rotation matrices

With the above applet, you will see the orientation of the mobile frame with respect to the fixed frame, for a given set of Euler angles, in the far right subfigure. Unfortunately, however, in practice, the situation is usually the opposite. You frequently have two reference frames, and you want to find the Euler angles that describe the orientation of one frame with respect to the other.

For orientations in which at least two axes are parallel, you could attempt to guess the Euler angles by trial and error. For example, look back at the image at the beginning of this tutorial and try to find the Euler angles used by Mecademic that define the orientation of the tool reference frame associated with the gripper, with respect to the flange reference frame. The answer is α = −90°, β = 0°, γ = −90°. Not so easy to get, is it? To be more efficient therefore, you must learn about rotation matrices after all.

As we have already mentioned, any orientation in space can be represented with a 3×3 rotation matrix. For example, a rotation of α about the axis x, a rotation of β about the axis y, and a rotation of γ about the axis z, respectively correspond to the following three rotation matrices:

Rx(α) =
100
0cos(α)−sin(α)
0sin(α)cos(α)
,
Ry(β) =
cos(β)0sin(β)
010
−sin(β)0cos(β)
,
Rz(γ) =
cos(γ)−sin(γ)0
sin(γ)cos(γ)0
001
.

We will refer to the above matrices as basic rotation matrices. To obtain the product of basic rotation matrices that corresponds to a sequence of rotations, start by writing the basic rotation matrix corresponding to the first rotation. For example, if the first rotation is about the x (or x') axis, then write Rx(ψ), where ψ is the angle of rotation. For every subsequent rotation, post-multiply (right multiply) the current result with the next rotation matrix, if the rotation is about an axis of the mobile reference frame, or pre-multiply (left multiply) the current result with the next rotation matrix, if the rotation is about an axis of the fixed reference frame. Use our applet to see the resulting product of basic rotation matrices. For example, the rotation sequence x'y'z' corresponds to the product R = Rx(α)Ry(β)Rz(γ). Thus, the rotation matrix that corresponds to the Euler angles used by Mecademic is:

R(α, β, γ) =
cos(β)cos(γ)−cos(β)sin(γ)sin(β)
cos(α)sin(γ) + sin(α)sin(β)cos(γ)cos(α)cos(γ) − sin(α)sin(β)sin(γ)−sin(α)cos(β)
sin(α)sin(γ) − cos(α)sin(β)cos(γ)sin(α)cos(γ) + cos(α)sin(β)sin(γ)cos(α)cos(β)
.

Therefore, for a given orientation, you will need to do two things: First, you need to find the rotation matrix that corresponds to your orientation. Second, you need to extract the Euler angles using a couple of simple equations. Let us first show you two ways to find your rotation matrix.

Consider the example shown in the figure below where we need to find the rotation matrix representing the orientation of frameF'with respect to frameF. (Recall that we always represent thexaxis in red, theyaxis in green, and thezaxis in blue.)

Here, it is easy to see that if we align a third reference frame with theF, which will act as a mobile frame, then rotate this frame about itsz' axis atθ − 90°, and then rotate it about itsy' axis atφdegrees, we will obtain the orientation ofF'. Thus, the rotation matrix we are looking for is:

Rdesired = Rz(θ − 90°)Ry(φ) =
sin(θ)cos(φ)cos(θ)sin(θ)sin(φ)
−cos(θ)cos(φ)sin(θ)−cos(θ)sin(φ)
−sin(φ)0cos(φ)
.

Alternatively, we can obtain the above rotation matrix directly. Its first, second and third columns represent the coordinates of the unit vectors along thex,yandzaxis, respectively, of frameF', with respect to frameF.

Now that you have the rotation matrix that represents your desired orientation, you simply need to solve the system of nine scalar trigonometric equationsRdesired=R(α,β,γ), forα,β, andγ. Fortunately, this problem has a generic solution and we'll simply give you the equations to use.

Let the desired orientation of a frameF'with respect to a frameFbe represented by the following rotation matrix:

Rdesired =
r1,1r1,2r1,3
r2,1r2,2r2,3
r3,1r3,2r3,3
.

The Euler angles (in degrees), in keeping with the mobile XYZ convention used by Mecademic, are then obtained according to the following two cases:

Case 1:r1,3 ≠ ±1 (i.e., thez'axis of frameF'is not parallel to thexaxis of frameF).

β = asin(r1,3), γ = atan2(−r1,2, r1,1), α = atan2(−r2,3, r3,3).

Case 2:r1,3 = ±1 (i.e., thez'axis of frameF'is parallel to thexaxis of frameF).

β = r1,390°, γ = atan2(r2,1, r2,2), α = 0.

In the general Case 1, we actually have two sets of solutions where all angles are in the half-open range (−180°, 180°]. However, it is useless to calculate both sets of solutions, so only the first is presented, in which −90° < β < 90°. Also, note that we use the function atan2(y, x) in our solution. Beware that in some programming languages, in some scientific calculators and in most spreadsheet software, the arguments of this function are inverted.

Finally, note that Case 2 corresponds to a so-calledrepresentation singularity. This singularity is present in any three-parameter representation of orientation in 3D space (not only in Mecademic's choice of Euler angles). It is similar to the problem of representing points on a sphere by only two parameters. For example, longitude is not defined on Earth at the South and North Poles on the Earth. In other words, this singularity has nothing to do the singularities of mechanisms (e.g., the so-calledgimbal lock), which correspond to actual physical problems (e.g., the loss of a degree of freedom).

Exercice

Z Rotation Cubing

Consider the following real-life situation that occured to us. We wanted to attach a FISNAR dispensing valve to the end-effector of ourMeca500robot arm. Naturally, the engineer who designed and machined the adapter didn't care about Euler angles and was only concerned with machinability and reachability. In his design, there were essentially two rotations of 45°. Firstly, he used two diametrically oposite threaded holes on the robot flange to attach the adapter, which caused the first rotation of 45°. Secondly, the angle between the flange interface plane and the axis of the dispenser was 45°.

The figure above shows the actual installation (left) and the tool frame (right) that needed to be defined. Note that when using axi-symmetric tools, it is a common practice to allign the tool z-axis with the axis of the tool. This is particularly useful with the mobile XYZ Euler angle convention, since the redutant rotation about the axi-symmetric tool corresponds to the third Euler angle, γ. Thus, the first two Euler angles define the axis of the tool, while the third one can be used to choose the optimal configuration of the robot (i.e., far from singularities).

'When using axi-symmetric tools, it is a common practice to allign the tool z-axis with the axis of the tool.'

Returning to our example, we will show now that it is impossible to come up with the Euler angles according to the mobile XYZ convention by trial and error. Indeed, for this choice of tool reference frame, we can represent the final orientation as a sequence of the following two rotations: R = Rz(45°)Ry(45°). From here, we can extract the Euler angles according to the mobile XYZ convention using the equations previously described and obtain: α = −35.264°, β = 30.000°, γ = 54.735°. Are you convinced now that you do need to master Euler angles for situations like this?

Representation singularities and orientation errors

In the case of the mobile XYZ Euler angle convention, if the z' axis of frame F' is parallel to the x axis of frame F, there are infinite pairs of α and γ that will define the same orientation. Obviously, you only need one to define your desired orientation, so we have arbitrarily set α to be equal to zero. More specifically, if β = 90°, then any combination of α and γ, such than α + γ = φ, where φ is any value, will correspond to the same orientation, and be output by Mecademic's controller as {0, 90°, φ}. Similarly, if β = −90°, then any combination of α and γ, such that αγ = φ, where φ is any value, will correspond to the same orientation, and be output by Mecademic's controller as {0, −90°, −φ}. Note, however, that if you try to represent the orientation of a frame F' with respect to a frame F and the z' axis of frame F' is almost parallel to the x axis of frame F (i.e., β is very close to ±90°), the Euler angles will be very sensitive to numerical errors. In such a case, you should enter as many digits after the decimal point as possible when defining the orientation using Euler angles.

Consider the following situation which has caused worries to several users of our Meca500. You set the orientation of the tool reference frame with respect to the world reference frame to {0°, 90°, 0°}, which is a representation singularity. Then you keep this orientation and move the end-effector in space to several positions. At some positions, because of numerical noise, the controller does not detect the condition r1,3 = ±1 (Case 2, as mentioned above) and calculates the Euler angles as if the orientation did not correspond to a representation singularity. Thus, the controller returns something like {41.345°, 90.001°, −41.345°}, which seems totally wrong and very far away from {0°, 90°, 0°}. Well it's not.

Unlike position errors, which are measured as √(Δx2 + Δy2 + Δz2), orientation errors are not directly related with the variations in the Euler angles, especially close to representation singularities. To better understand this so-called non-Euclidean nature of Euler angles, consider the spherical coordinates used to represent a location on Earth. At the North Pole, the latitude is 90° (North), but what is the longitude? Longitude is not defined at the North Pole, or it can be any value. Now imagine that we move only 1 mm away from the North Pole in the direction of Greenwich. In this case, the latitude will be 89.99999999°, but the longitude will now have the value of 0°. Imagine once again that you return to the North Pole and move 1 mm in the direction of Tokyo. The new longitude will be approximately 140°. Between your two locations, the error in longitude is 140°! However, the real angular error will be approximately 0.00000002°.

The situation described above is similar in all other Euler angles conventions. Depending on the Euler angle convention, the correspoding representation singularity occurs when a specific axis of frame F' is parallel to another specific axis of frame F. In such a representation singularity, the first and third rotation become dependant.

In conclusion, unless you master Euler angles (or use sophisticated offline programming software), and more specifically the convention used for programming your robot, you will hardly be able to program anything but simple pick and place operations. Because robotics is not simple, we do our best to help you understand the basics.

© Mecademic Reproducing this tutorial, in whole or in part, is strictly prohibitted.