Using accelerometers


To make it tangible, we are going to consider the example of my mobile phone. First thing I am going to do is to attach a right handed coordinate frame to it and I am going to have the z-axis out of the face of the screen. The y-axis is vertically upwards on the phone and the x-axis is horizontal from left to right. I am going to call this frame B and that stands for the body frame or the body-fixed frame. This is a very common notation in aerospace and also in robotics. Now we are going to place one accelerometer aligned with each of the axes that we have attached to the phone. So, one accelerometer would be in XB direction and one in the YB direction and one in the ZB direction.

Modern mobile phones, are packed full of inertial senses. They contained three accelerometers, three gyros and three magnetometers. Like everything else that we've talked about in this lecture series, we are going to attach a coordinate frame to the phone. You have to look reasonably deeply into the documentation to find the coordinate frame conventions for the phone, but for an iPhone like this, the convention is the x-axis is to the right and the y-axis is to the top of the phone and the z-axis is out of the screen. So, I am going to fix one of my standard coordinate frames to the phone, so we understand what's what.

There are many apps that you can get for your phone, that report the acceleration measurement recorded by the sensors built into the phone itself. Unfortunately, many of these apps introduce a negative sign. That means that if the phone is sitting flat on the table, it reports a value of minus 1G in the negative z or down with the direction but as we discussed in the previous section, acceleration of a device sitting flat on a table should be 1G in the positive upward z direction.

So, here we have the plumb bob, which is hanging down under the force of gravity, so it is aligned parallel to the gravitational acceleration with the same gravitational acceleration is parallel to the z-axis. If I rotate the phone like this, so now, the gravitational acceleration is parallel to the y-axis and now I can rotate the phone, so the gravitational acceleration is parallel to the x-axis.

Let us consider now the problem of determining the orientation of the phone with respect to a world coordinate frame. The world coordinate frame is shown here in blue and its orientated so that the z-axis is upwards and parallel to the gravity vector. Frame B, the body frame is attached rigidly to the phone. Now I can write an expression for the orientation of the phone with respect to the world coordinate frame and I will do that in terms of yaw, pitch and roll angles which are successive rotations about the z-axis, the y-axis and then the x-axis. This is the gravitational acceleration in the world frame because the world z-axis is parallel to the gravitational acceleration vector. We note here that G is positive. We are talking about acceleration in the world frame is G in the upward direction. It is very easy to rotate this gravitational acceleration with respect to the world frame into the body frame. This is what the sensors in the phone actually measure. They are measuring gravity with respect to frame B. It is really important to note that this assumes that the phone is not accelerating. The only acceleration on the body is that due to gravity. Now, I can expand out the right hand side and I can replace the left hand side with the gravity actually measured by the sensors in the phone. I have a very simple vector equation. If I take the first row in this vector equation. I can rearrange it to get a solution for the pitch angle theta. If I take the quotient of the last two rows in the vector equation, I get this expression for the roll angle of the phone. Two very simple equations based on the measured acceleration give me the roll and pitch angle of the phone with respect to the world coordinate frame. Then you note in this equation that yaw angle does not appear. A simple way to think about why this is the case, is that the gravity vector has got three elements but its length is fixed therefore we can define it by only two pieces of information. The third element of the gravity vector is redundant. In this case, the two pieces of information that we need are the roll angle and the pitch angle. We do not need the yaw angle. To measure the yaw angle, we need to use a different sensor and that sensor is actually a compass and that is the topic of our next section.

An important consideration when we use three accelerometers, is that it measures only two independent variables. The length of the vector is fixed, so therefore, we can describe that vector just in terms of two angles. We can see that very clearly when the phone is configured like this. Zero acceleration in the Z and the X directions. The acceleration is all in the Y direction. So the accelerometer measurements are exactly the same with the phone orientated like this, or like this or like this. It makes absolutely no difference.

Accelerometers today have very low cost but very, very high in performance. Part of the reason for this is that they are manufactured in enormous quantities. They're use to trigger airbags in cars. They're used in digital cameras to work out whether the camera is in landscape or portrait mode. They're used in your phone for all sorts of different applications and they're used for stabilization of unmanned area of vehicles from low cost toys like this to much more sophisticated systems.


There is no code in this lesson.

We learn how to use information from three accelerometers to determine orientation.

Professor Peter Corke

Professor of Robotic Vision at QUT and Director of the Australian Centre for Robotic Vision (ACRV). Peter is also a Fellow of the IEEE, a senior Fellow of the Higher Education Academy, and on the editorial board of several robotics research journals.

Skill level

This content assumes an understanding of high school-level mathematics, e.g. trigonometry, algebra, calculus, physics (optics) and some knowledge/experience of programming (any language).

More information...

Rate this lesson


Check your understanding

Leave a comment