- Mon Oct 18, 2010 5:44 am
#111621
Ok, so it seems a lot of people are confused about the differences between magnetometers, accelerometers and gyroscopes. I've answered my share of questions about them, and am making this post so I don't have to keep typing the same things over and over. We'll start by looking at what each of the devices do, and then look at how combining them can give us our position in space.
Magnetometers:
Simply put magnetometers measure the variations in a magnetic field. The earth, being a rock filled with ferro-magnetic minerals, has a strong magnetic field that can be read by a magnetometer to give you an idea where north is. The actual angle to magnetic north won't quite get you to the North Pole, because the alignment of the magnetic field is a little off, and varies from place to place. Ultimately the magnetometer's most basic function is to act as a compass, providing a reference to north that can be used for navigation.
Accelerometers:
An accelerometer measures acceleration. It can be tuned to measure the acceleration due to gravity, but more commonly it is used to measure a device's movements. The frame of reference (meaning what you're measuring) is the device itself. These come in one, two, or three axis. The device measures acceleration, not velocity. Acceleration, for those that slept through physics class, is defined as the change in velocity as a function of time. If you drop a ball off a tower, the ball will gain 9.8 meters/second velocity over the course of every second. This is commonly referred to as m/s/s (meters per second per second) or m/s2 (meters per second squared). (Of course dropping a ball off a tower, the ball will encounter air resistance, and won't accelerate as quickly, but the 9.8m/s2 or 32ft/s2 will get you close. This also ignores terminal velocity, which is again, a topic that's beyond the scope of this introduction.)
Gyros (aka Angular Rate Sensors):
Gyroscopes measure rotational velocity. These are the devices used to measure pitch roll and yaw rates. These measurements combined with time can give you your current attitude (pitch/roll/yaw angle). Like accelerometers they come in one, two or three axis versions. (There are other types of gyros out there, but that's the most common, and the only one sold by SFE.)
How they all can be fused together:
The science of dead reckoning has been known by sailors the world over since at least the 1200s (probably earlier, because the Vikings were raiding villages all over the coast from the 700s on). Dead reckoning is the process of estimating ones current position based on knowing speed and direction. This method of navigation has been used for centuries, and allows you to get close to where you want to go, but it's not horribly accurate over a long period of time. An accelerometer and a timer is all you really need to determine your position (referred to as a fix). By calculating your linear velocity and applying how much time has elapsed, you can find out your distance travelled. This is not very accurate as it provides no reference, and no angle compensation.
Fixing the angle compensation issue is a simple matter of adding a gyroscope into the mix. Since the gyro measures rotation (angular velocity) it complements the features of the accelerometer nicely. Adding the gyro allows you to add pitch, roll and yaw into your calculations, improving accuracy, and allowing control of more complex devices. The problem with this system, is that without a known reference point you can't extract anything more than where you are relative to the starting point. In addition to this the device has no way of compensating for the natural drift in the figures returned from the gyro and accelerometer.
Compensating for drift and adding accuracy with other sensors:
Because gyros can drift over time, and measurement accuracy is not perfect, you need some way of re-calibrating your measurements and sanity checking your output. Using a magnetometer you can obtain a fixed reference point (north) that allows you to check your calculations against known figures. The three devices work in unison to provide you a fairly accurate picture of where you are, and where you're pointed.
Another way to improve accuracy would be the addition of a GPS. This allows you to check your position against a reference, and update your calculations based on a known figure.
Moving On From Here:
Hopefully the information here helps people understand the differences between the types of sensors, and how they can be used together. The next step would be to implement one of the algorithms used to determine position based on the data from sensors. You'll also probably want to filter your incoming input data (like a Kalman Filter). Building an IMU requires patience and some math skills. At a minimum you should know the Pythagorean Theorem, right triangle geometry/trigonometry (including the SIN/COS/TAN ratios), and some basic vector addition and subtraction.
(For those into mathematics check out: http://code.google.com/p/imumargalgorithm30042010sohm/ --Written by forum user sebmadgwick)
theBecwar
(If anyone has any information to update this, or noticed something I screwed up, please let me know so I can fix it.)
Magnetometers:
Simply put magnetometers measure the variations in a magnetic field. The earth, being a rock filled with ferro-magnetic minerals, has a strong magnetic field that can be read by a magnetometer to give you an idea where north is. The actual angle to magnetic north won't quite get you to the North Pole, because the alignment of the magnetic field is a little off, and varies from place to place. Ultimately the magnetometer's most basic function is to act as a compass, providing a reference to north that can be used for navigation.
Accelerometers:
An accelerometer measures acceleration. It can be tuned to measure the acceleration due to gravity, but more commonly it is used to measure a device's movements. The frame of reference (meaning what you're measuring) is the device itself. These come in one, two, or three axis. The device measures acceleration, not velocity. Acceleration, for those that slept through physics class, is defined as the change in velocity as a function of time. If you drop a ball off a tower, the ball will gain 9.8 meters/second velocity over the course of every second. This is commonly referred to as m/s/s (meters per second per second) or m/s2 (meters per second squared). (Of course dropping a ball off a tower, the ball will encounter air resistance, and won't accelerate as quickly, but the 9.8m/s2 or 32ft/s2 will get you close. This also ignores terminal velocity, which is again, a topic that's beyond the scope of this introduction.)
Gyros (aka Angular Rate Sensors):
Gyroscopes measure rotational velocity. These are the devices used to measure pitch roll and yaw rates. These measurements combined with time can give you your current attitude (pitch/roll/yaw angle). Like accelerometers they come in one, two or three axis versions. (There are other types of gyros out there, but that's the most common, and the only one sold by SFE.)
How they all can be fused together:
The science of dead reckoning has been known by sailors the world over since at least the 1200s (probably earlier, because the Vikings were raiding villages all over the coast from the 700s on). Dead reckoning is the process of estimating ones current position based on knowing speed and direction. This method of navigation has been used for centuries, and allows you to get close to where you want to go, but it's not horribly accurate over a long period of time. An accelerometer and a timer is all you really need to determine your position (referred to as a fix). By calculating your linear velocity and applying how much time has elapsed, you can find out your distance travelled. This is not very accurate as it provides no reference, and no angle compensation.
Fixing the angle compensation issue is a simple matter of adding a gyroscope into the mix. Since the gyro measures rotation (angular velocity) it complements the features of the accelerometer nicely. Adding the gyro allows you to add pitch, roll and yaw into your calculations, improving accuracy, and allowing control of more complex devices. The problem with this system, is that without a known reference point you can't extract anything more than where you are relative to the starting point. In addition to this the device has no way of compensating for the natural drift in the figures returned from the gyro and accelerometer.
Compensating for drift and adding accuracy with other sensors:
Because gyros can drift over time, and measurement accuracy is not perfect, you need some way of re-calibrating your measurements and sanity checking your output. Using a magnetometer you can obtain a fixed reference point (north) that allows you to check your calculations against known figures. The three devices work in unison to provide you a fairly accurate picture of where you are, and where you're pointed.
Another way to improve accuracy would be the addition of a GPS. This allows you to check your position against a reference, and update your calculations based on a known figure.
Moving On From Here:
Hopefully the information here helps people understand the differences between the types of sensors, and how they can be used together. The next step would be to implement one of the algorithms used to determine position based on the data from sensors. You'll also probably want to filter your incoming input data (like a Kalman Filter). Building an IMU requires patience and some math skills. At a minimum you should know the Pythagorean Theorem, right triangle geometry/trigonometry (including the SIN/COS/TAN ratios), and some basic vector addition and subtraction.
(For those into mathematics check out: http://code.google.com/p/imumargalgorithm30042010sohm/ --Written by forum user sebmadgwick)
theBecwar
(If anyone has any information to update this, or noticed something I screwed up, please let me know so I can fix it.)
Last edited by thebecwar on Mon Nov 08, 2010 2:28 am, edited 1 time in total.
~tB~