# How to compute the orientation error between two 3D coordinate frames?

For my master thesis in robotics I have to compute the orientation error between two coordinate frames, called E and H. Their orientation is expressed through rotation matrices (3x3) with respect to a "world frame", W. Remark: writing $$R_A^B$$ I'm indicating the orientation of frame A with respect to frame B.

What I have understood is that I have to do the following operation:

$$R_{error} = R_E^W * R_W^H$$

is it correct? If yes, that error in which frame is expressed? Thanks a lot Ale

• @morbo I learn this is the error from my book of robotics ("Robotics: Modelling, Planning and Control" from Bruno Siciliano) if you're interested. However your comment was not useful in any sense.. – Xela95 Mar 8 '20 at 16:27

The rotation error between two frames can be viewed in two ways:

1. The orientation of one frame as seen from the other, calculated by multiplying the inverse of the observing frame by the observed frame. For frames $$E$$ and $$H$$, this error in your notation would be $$\tag{1} {R_{1}}^{E}_{H} = (R^{W}_{E})^{-1}R^{W}_{H} = R^{E}_{W}R^{W}_{H}$$ for $$H$$ as seen from $$E$$, or $$\tag{2} {R_{1}}^{H}_{E} = (R^{W}_{H})^{-1}R^{W}_{E} = R^{H}_{W}R^{W}_{E}$$ for $$E$$ as seen from $$H$$. These matrices encode the rotations around local axes (the axes of the superscript frame) that map the superscript frame to the subscript frame, $$\tag{3} R^{W}_{E}{R_{1}}^{E}_{H} = R^{W}_{H}$$ and $$\tag{4} R^{W}_{H}{R_{1}}^{H}_{E} = R^{W}_{E}$$

2. The orientation that would be reached by starting at one frame and moving by the inverse of the second frame's orientation relative to the world, $$\tag{5} {R_{2}}^{E}_{H} = R_{H}^{W} (R_{E}^{W})^{-1} = R_{H}^{W} R_{W}^{E}$$ or $$\tag{6} {R_{2}}^{H}_{E} = R_{E}^{W} (R_{H}^{W})^{-1} = R_{E}^{W} R_{W}^{H}$$ These matrices encode the rotations around the world axes that map the frames to each other, $$\tag{7} {R_{2}}^{E}_{H} R^{W}_{E} = R^{W}_{H}$$ and $$\tag{8} {R_{2}}^{H}_{E}R^{W}_{H} = R^{W}_{E}$$

The fundamental source of there being two interpretations of rotational error is that rotations are not commutative, and so our intuition that the differences $$A + (-B)$$ and $$(-B) + A$$ should be the same does not hold in this case.

The equations have a left-right duality. When we take the difference by putting the inverse rotation on the left (globally rotating the second frame by the inverse of the first), we find the (local) rotation error that maps between the frames when placed to the right of the starting frame, and when we put the inverse rotation on the right (locally rotating the first frame by the inverse of the second), we find the (global) rotation error that maps between the frames when placed to the left of the starting frame.

• Thank you for your answer! I think the same as you but doing some test in Matlab this revealed not correct.. The error computed in your way has a physical interpretation, mine not.. however in simulation my formulation give the correct error and I cannot understand why.. – Xela95 Mar 8 '20 at 16:30
• What seems to be wrong when you try the formulas I gave in Matlab? – RLH Mar 8 '20 at 17:33
• I realized that you may be looking for the rotation error that is the rotation around world axes that would take frame E to frame H, rather than the rotation around the axes of frame E. See my expanded answer for more details. – RLH Mar 8 '20 at 18:54
• exactly!! In my book of robotics, the error is computed in the way I've written in the question, and is explained as the rotation that frame H has to do in order to overlap to frame E – Xela95 Mar 9 '20 at 10:33

A rotation matrix represents the rotation between two frames. Therefore, it does not make sense to talk about in which "one" frame the error rotation is expressed. Namely, the rotation matrix $$R^B_A$$ represents the rotation from frame $$B$$ to frame$$A$$. Therefore, the error rotation matrix you defined as

$$R_{error} = R^W_E R^H_W$$

can also be seen as the rotation from frame $$H$$ to frame $$W$$ and then from frame $$W$$ to frame $$E$$, which is equivalent to $$R^H_E$$.

• This operation describes the expression of a vector in frame $H$ as seen in frame $E$, not the orientation error between the two frames. – RLH Mar 7 '20 at 21:16
• @RLH Then how does your answer differ from mine, because I think we say the same thing? – fibonatic Mar 7 '20 at 22:17
• Rereading your answer, I see where you’re coming from. The difference between our answers is that yours focuses on the rotation matrices as objects that act on vectors, rather than as representations of the frame orientations in their own right, and the OP asked about rotation errors. I’d remove th downvote if I could, but I’m locked in on it until there’s an edit to your answer. – RLH Mar 7 '20 at 22:46
• @RLH Fair point. I mainly tried to exaggerate that point because in the question it is asked in which frame the error is expressed. – fibonatic Mar 7 '20 at 22:50