Attitude Quaternions

So I've decided that I'm going to build an autonomous drone. I'm using 3 gyroscopes and 3 accelerometers with measurements combined using a complimentary filter to get the plane's orientation relative to the fixed Earth coordinate system. The gyroscopes measure the angular velocity about each of the 3 Cartesian axises of the airplane in the plane's coordinate system. From what I understand, I "have" to use quaternions to convert the rotations from the ever-changing coordinate system of the plane to the fixed coordinate system of the the Earth, meaning that I want to convert rotations about the plane's axises to the equivalent rotations about the Earth's axises to get the true orientation. While I believe I understand the concepts fine, I'm not too sure about the math. If someone would be willing to explain, step by step, how one would create/manipulate a quaternion or quaternions to convert angular rotations from one coordinate system to angular rotations in another that would be incredibly helpful.
You don't have to use quaternions, however it simplifies the math and makes it easier to achieve the real-time processing which would be required in your drone.

I don't really have enough experience with quaternions to give you the details on how to convert from your 6 axis measurement to a quaternion. But this look promising:
Last edited on
It has been a while since I've played with the math, and I have no interest in doing this for you... but the basic concepts are pretty simple, actually.

The problem with Euler rotational systems is called 'gimbal-lock'. It has to do with the fact that some angles are not particularly easy to manage with floating-point mathematics, resulting in a jittering about an axis (because the underlying angle cannot be represented with sufficient precision to be correct).

Quaternions fix this by working in an imaginary cubic space, so that the values can be normalized to a more manageable floating-point range. (You don't actually have to care about the imaginary roots to use any of this.)

Transformations to your system work the same as before: multiply by an appropriate 2D transformation matrix.

(Just keep in mind that matrix multiplication is not commutative, so you have to make sure to do things in the proper order each time!)

Here are a couple of sites that will help get you started:

The reading is fairly straight-forward and I think it should help you get going.

Good luck!
Just some non-math advice: Since you're building a drone, you should research the laws of country/state you are in concerning air space and drone operation. I've heard some stories of hobbyists getting into deep trouble because they didn't have the proper papers and licenses. I'm not exactly sure, but it could be that these laws only apply to camera-mounted drones, but it varies from place to place anyways.
Legality should not be a problem here. A drone like this should easily qualify as an ultralight aircraft or just a regular model plane here in the US. But as usual check local laws. Those people get into trouble for doing stupid crap like trying to fly through the middle of downtown or too close to an airfield (private airfields count and aren't always clearly visible), which is a safety hazard for obvious reasons. Otherwise this isn't any different from flying a model plane.

@ OP: So how far are you trying to go here? I have to say I've built dozens of free flying devices in my life and I've never touched on any of this.
Last edited on
I plan on this thing being able to traverse from way point to way point completely on its own, then return to where I launched it from. The only thing I will be doing manually is takeoff and landing. I've searched around and haven't been able to find any laws that I would be in violation of, so long as it stays less than 700 feet off the ground and obviously out of restricted airspaces.

As for the original topic of quaternions, thank you all for the references. I'll definitely be looking at them and working out the math and trying to wrap my mind around all of it. Right now I'm in the middle of all my AP exams and I have my final presentation for an engineering class that I'm in, but once all of that is out of the way this project will resume.
Topic archived. No new replies allowed.