3D Robotics

### FAQ: What's the difference between a gyro and an accelerometer? Do I need both?

[Marc Ramsey gave a fantastically clear and concise answer to a question that's asked here every week, so I'm going to reprint it here with some slight edits as a FAQ that we can link to from the front page.] Q: What's the difference between a gyro and an accelerometer? Do I need both? An accelerometer measures acceleration. A 3-axis accelerometer will tell you the orientation of a stationary platform relative to earth's surface, once that platform starts moving, however, things get more complicated. If the platform is in free-fall, it will show zero acceleration. If it is accelerating in a particular direction, that acceleration will simply be added to whatever acceleration is being provided by gravity, and you will not be able to distinguish. A 3-axis accelerometer in an aircraft in a properly coordinated turn with a 60 degree angle of bank, for instance, will show 2 G "vertical" acceleration in the aircraft, despite the fact that the aircraft is tilted 60 degrees relative to the horizon. So, accelerometers alone can't be used to keep in an aircraft in a particular orientation. A gyro measures rate of rotation around a particular axis. If a gyro is used to measure the rate of rotation around the aircraft roll axis, it will measure a non-zero value as long as the aircraft is rolling, but measure zero if the roll stops. So, a roll gyro in an aircraft in a coordinated turn with a 60 degree bank will be measure a rate of zero, same as an aircraft flying straight and level. You can approximate the current roll angle by integrating the roll rate over time, but you can't do so without some error creeping in. Just to make life more interesting, gyros drift with time, so additional error will accumulate over a period of minutes or even seconds, and eventually, you'll have a totally inaccurate idea of your current roll angle relative to the horizon. So, gyros alone can't be used to keep in an aircraft in a particular orientation. So, in a nutshell: Accelerometers are right in the long term but wrong (noisy) in the short term. Gyros are right in the short term but wrong (drifiting) in the long term. You need both--each to calibrate the other--to be right all the time. But even that only works in for pitch and roll. For yaw, which is orthogonal to gravity, the accelerometers can't help you, so you need something else to correct your drifting yaw gyro. That's either magnetometers (electronic compasses, which are vulnerable to magnetic interference and intertial forces) or GPS. GPS has a relatively slow update rate (1 to 10 Hz) and is subject to short term errors. It is possible to use GPS alone to keep a very stable and slow flying airframe on a particular ground track on a calm day. An inertial measurement unit (IMU) combines (fuses) information from two or more sensors, such as gyros, accelerometers, magnetometer, and/or GPS, to determine orientation and velocity vector relative to the earth. The computations are fairly complex, and special filtering is often required to eliminate the measurement noise these silicon devices are subject to, so a "low cost" off-the-shelf IMU with decent specs can easily cost \$1000 to \$5000 US. Infra-red horizon sensing "copilots" are inexpensive and work fairly well as long as they have a clear view of the horizon. Unfortunately, mountains, clouds, haze, buildings, etc., will confuse them. [Chris here: I think IR stabalization is more effective than people give it credit for, and is actually rarely confused in standard usage. Both Paparazzi and AttoPilot are built on it, and they work great. See this interview for more.] In the end, the techniques used to stabilize a UAV will be very much dependent on the intended use, budget, and how comfortable one might be working with sensor fusion, Kalman filters, etc.

• Not to resurrect this thread, but I just published a brief explanation of how to combine rate gyro and accelerometer data: http://www.chrobotics.com/library/attitude-estimation

Fundamentals of Attitude Estimation | CH Robotics
• @Chris: +1

Nice explanation.

• Is this actually easier solution?
Anyway to measure the speed of the wheels is necessary to implement an encoder and you need to use a microcontroller TIMER module as a counter and perform conversions, among other actions.
With a gyroscope or an accelerometer also I have to use a microcontroller ADC module and perform other actions.
I want to use another technology for this design because it could also be used for other projects. Can you tell me then what should I use for the wheelchair, a gyroscope or an accelerometer?

• Mario - instead, can you measure the wheel velocity and regulate it so that it is constant on a slope or on a flat surface?  It seems like that would be an easier solution.

• Hello! I want to implement a sensor on a wheelchair to determine the inclination angle and thus control the power in the motors of the wheelchair. So that, if the surface on which the chair is moved is a climb, the power in the motors must increase, or if the surface is a slope, then the power in the motors must decrease. I don’t know if to use an accelerometer or a gyroscope better. Can you help me with this, please?

• [quote]So, in a nutshell: Accelerometers are right in the long term but wrong (noisy) in the short term. Gyros are right in the short term but wrong (drifiting) in the long term. You need both--each to calibrate the other--to be right all the time.[/quote]

Actually its not noise in the accelerometers which causes the problem.  The fact is that even with perfect accelerometers, you can fly a manouver which keeps the accelerations in all direction exactly on zero ( plus gravity ) and change the attitude and heading of the aircraft arbitrarily.  A simple case is a coordinated turn combined with a spiral dive.  The turn keeps the X and Y accelerometers on zero, and the dive keeps the Z accelerometer on zero ( plus gravity ).  And yet the aircraft ends up on a totally different heading.  So no integration of even perfect accelerometers will detect the turn you just made.  Even worse, you can pass through any arbitrary attitude, even inverted, and the accelerometers will read exactly nothing.  So you cannot, even in principle, measure the flight path using accelerometers alone.  Even combining them with gyros does not help, since the gyros will measure the rotation rates, and integration will give you the rotations, but the accelerometers will ( eventually ) remove those rotations, or add to them in totally unpredictable ways, depending on the actual manouver you perform.

• How inclinometers relate to the gyros and whether they can be used instead of the gyros?
• Today i was preparing my lecture so i find my problem solution
Its outstanding effort to answer question. i lke it
Have fun
• 3D Robotics
Borgel,

Google "Kalman filter". That's the usual method.