# Displaying spacecraft attitude from rotation matrix or quaternion?

Navigation and guidance systems generally use rotation matrices or quaternions to uniquely specify 3D rotations.

But these are not the least bit intuitive, so we like to convert them to Euler angle sequences that we can understand---maybe a roll, pitch, yaw sequence, say.

Trouble is... the conversion limits your angles to +-90 degrees about one axis (y in xyz sequence) and +-180 degrees about the other two axes (x and z in xyz sequence).

This is problematic if you're doing a flipover maneuver in space and your pitch angle extends over the limited 180 degree range imposed on it by the conversion.

Then there are the singularities (gimbal lock) and the sudden erratic angle changes that occur near it (roll and yaw angles suddenly changing by 180 degrees because the mathematics in the rotation conversion can't tell a rotation q apart from a rotation pi-q).

So I'm wondering, how exactly do they extract meaningful intuitive attitude information to present to the crew from the rotation matrices or quaternions employed in their algorithms without the limitations that a conversion to an Euler angle sequence imposes?

• Gimbal lock and similar singularities are not a concern with the proper selection of attitude parametrization representation (e.g. quaternion, or rotation vector representation). Abstracting away the details of those rotations and converting to "yaw pitch roll" can be easier to understand. A practical example is the SpaceX Crew Demo Simulation which shows that pitch yaw and roll is the choice of representing attitude to the astronauts in Dragon capsule, one of the ways at least, I would like to learn more as well. Link here: iss-sim.spacex.com Jan 24, 2021 at 5:11
• Yes, Manny, I know that certain parameterizations, like the rotation matrices and quaternions mentioned in my first paragraph, aren't afflicted with gimbal lock. I also know that euler angle sequences like "roll pitch yaw" are more intuitive to understand, which is why we like to convert to them. My question is not any of that. It's: how do you convert from rotation matrices and quaternions to euler angles without the limitations that come with the conversion---like the limited angle range, the singularity, the errattic sudden axis flipping that occurs near the singularity...
– user36480
Jan 24, 2021 at 6:26
• I see now. We can take a look at Section 6.1.1 of Markley, Crassidis "Fundamentals of Attitude Determination and Control". It is reminded that "All three parameterter representations have discontinuities and singularities". The chapter suggests to implement "filters" ("if" logic?) to provide some type of guarantee to avoid computing singular attitudes. Alternatively, it reccommends the use of Modified Rodrigues Parameters. The scope of that chapter is to use the angles in a Kalman Filter, in which three-parameter representation is preffered. Let us know if this source is somewhat closer! Jan 24, 2021 at 7:05
• Thank you @Manny for the reference! That seems a good book to check out.
– user36480
Jan 24, 2021 at 18:39

I do not know how exactly the attitude is presented to the crew, my experience is tied only to the unmanned spacecrafts, though I would imagine there is no unique preferred solution and it depends on the particular task at hand. I will try to provide some possibilities at least, but first a slight correction.

You mention the rotation matrices and quaternions having unique rotation representations. However, that is only true for rotation matrices, while the quaternions have double covering of the rotation space. Every orientation has two quaternion values attached to it.

Also, a bit about the gimbal locks and singularities. Gimbal lock is a loss of a degree of a freedom in rotations, which is an actual effect of a physical gimbal. But a spacecraft is not physically tied to a gimbal, it is freely rotating in a space and will never experience a loss of degree of freedom of its rotations. On the other hand, some actuators for attitude control might experience it. Gimbal lock is not a problem with representations at all, it does not prevent from knowing the attitude in any way. It is only an analogy to the problem of singularity when Euler angles are used, same conditions apply for both to happen, but instead of loosing a possibility to do something, as with gimbal lock, the singularity removes a possibility to know something.

This knowledge which is lost is not a knowledge of the attitude, it is perfectly clear in which orientation spacecraft is when singularity is reached. What is lost is the path to it. Non singular attitudes have one single path to them from some reference orientation, but a singular attitude has infinite paths. So if the goal is just attitude knowledge, any representation could be used, but a careful selection is required when the attitude change is of concern.

While algorithms have their ways to evade issues with singularities, I see two possible ways for crew members to go about this, building the intuition about the used attitude representation and selection of the appropriate reference frames.

### Building intuition

I am probably biased for the approach of building the intuition, as I have already spent enough time dealing with quaternions, but I claim that if you stare sufficiently long at them, you start to understand them, know them, feel them, form a quintet (quinternion???) with them... sorry, got carried away. Anyhow, the intuition can be improved and then move on using the quaternions directly. If you want to pilot a spacecraft, you need to learn a lot anyway, spacecrafts are not built to be immediately obvious and intuitive for everyone. Training is required and the training includes attitude understanding. This holds for Euler angles too. Crew gets trained to use them and they understand even when the attitude is in singularity. Pilots do have context of how the singularity was reached and they should know how to get out of it towards their goal. A sudden jump in values from -90 to +90 should not be big problem if expected.

### Reference frame selection

Then comes a proper selection of reference frames. You do not have to stick to one and only reference frame all the time. In case of a flipover maneuver from the question, it should be possible to take current attitude as a reference. Then perform actions necessary to get to the attitude which is 180 degrees away. The singularity will not be on this path with Euler angles. If the representations is Modified Rodriguez Parameters, then the singularity will be exactly at this targeted attitude. So in such case, theoretically, you can just guide the spacecraft towards this singularity point, but practically that would be a bit harder. A better approach, for any used representation, is to make your reference frame your targeted attitude, and then the guiding becomes going towards the attitude of zeros. In this situation the Modified Rodriguez Parameters are a really good match, as the guiding becomes always going away from the singularity. Still, even if sticking to the Euler angles, there should exist appropriate reference frame to avoid singularities.

• "if you stare sufficiently long at them, you start to understand them, know them, feel them, form a quintet (quinternion???) with them [...]" Ha ha ha. This made my day. Thank you for the info! Yeah, my struggle is strictly with displaying the spacecraft attitude to the operators---the rotation matrices under the hood ensure that singularity is never a problem. I just want a way to present the attitude in an intuitive format without the sudden axis flipping that occurs, e.g., when you go over 90 deg pitch (if converting to roll-pitch-yaw sequence).
– user36480
Jan 24, 2021 at 18:44
• OK, so switching frames near the singularity may be a way to avoid this. I've been doing this, actually---switching to a reference frame that's rotated 90 degrees from the first, and biasing that second reading by 90 deg, so that when my spacecraft is doing a flipover I can get a continuous consistent reading extending over 180 degrees in range. It just seems like a hack, and I see the nice attitude indicator displays they have everywhere, and I figure there must be a better way to do this? I'm not familiar with Rodrigues parameters, sadly. I'll have to learn about them sometime.
– user36480
Jan 24, 2021 at 18:51
• @a1ex, if you'd like to present the data intuitively and visually, a quaternion or an MRP are probably the simplest method. They both rely on a principal rotation vector, which is a vector fixed in both the initial and final rotations. An excellent source for attitude is Schaub and Junkins "Analytical mechanics of space systems." Jan 24, 2021 at 19:37
• Thanks, @Chris. Few people would understand a quaternion display, though, which is why I need to convert to something like a roll-pitch-yaw sequence. It's that conversion that introduces all the issues mentioned above. The rotation matrices I'm using for navigation and guidance and control are all working very well. What's causing me trouble is converting those matrices into an intuitive attitude display that anyone, even people who aren't engineers, can understand at a quick glance...
– user36480
Jan 24, 2021 at 20:42
• Switching between different reference frames will again produce jumps in values. I do not think there is a solution to this. If we simplify to rotations in one dimension, it goes from 0 to 360 degrees, after which a jump goes to 0, unless you continue going further in which case it is representation with multiple coverings of rotation space. But maybe I am wrong if you say that you have seen nice attitude indicators. Could you point to an example or few? Maybe then we could identify a solution. Jan 24, 2021 at 21:56