Skip to main content

Noise, Sensor Fusion and Lost Drones

Motion and environmental sensor technology has come a long way in recent years. Even so, nothing is perfect and autonomous vehicles cannot work safely with a fuzzy view of the world.

shutterstock_453806701_bbfa0bf367051ddafbc73c8a24f8f8e9af001bf7.jpg

A big requirement for anything autonomous is that it knows its precise location within the operating environment. How precise depends on the vehicle’s range of operation. A small mobile robot may be designed to operate within the confines of a small room and only needs the location to within a few millimetres. A car might need a spatial resolution of centimetres, an aircraft metres and a space probe hundreds of metres. The probe will need more accurate figures if it is intended to orbit or even land on a planet. Generally, anything moving will require sensors that can track movement – often very fast movement. Static applications where sensors take readings at a more sedate pace include weather monitoring and home automation.

  • Dynamic Sensors: Accelerometer, Rate Gyroscope, Magnetometer and Optical Rotation
  • Static Sensors: Temperature, Humidity, Light and Barometric Pressure

One thing that these practical devices will have in common is that all will have ‘noisy’ outputs to a greater or lesser degree. Noise means error and the use of raw sensor data can lead to your weather observations (and subsequent forecasts) being inaccurate, or worse, an autonomous vehicle losing control and causing a fatal accident.

Defining Noise

Noise is, well, noise. It’s the hiss in the quiet spots when listening to a recording. It’s the ‘snow’ on an old pre-digital TV, and it’s the random fuzziness all over the output from a distance sensor that a driverless car computer is relying upon to avoid a collision. To design a suitable filter able to reduce the noise, it must be mathematically characterised. Being noise, it’s unpredictable (non-deterministic) so linear equations are out and statistics are in. For the purpose of assessing the performance of a new filter design, some sort of mathematical model of noise must be available. The most widely used is called Additive White Gaussian Noise (AWGN). It’s not perfect, but close enough to prove a design would work with ‘real’ noise. These are the main features:

  • It is just added to the signal. Hence the term Additive noise.
  • It has a Normal distribution in the time domain with an average or mean value of zero (Fig.1). Hence integrating signal plus noise over a long period will remove the noise.
  • In theory, the frequency domain extends from -∞ to +∞, and the power density is flat all the way. Hence the term White noise.

Fortunately for the designer, simulation programs like MATLAB have built-in AWGN noise generators.

Sensor_Fusion_blog_3_f54d15b2ee9dab078babd003fc4f266f73f741f0.png

The main thing to note from the AWGN equation above is that it defines the general quantity of noise on a signal: it doesn’t provide the exact noise voltage deviation at a specified instant. The variable σ is the Standard Deviation and it defines how ‘bad’ the noise is. The main graph in Fig.1 has been calculated with σ = 1. It shows what the Probability P(n) is that the signal will be deviated by a specific amount n at a particular instant in time. You can see immediately that there is a 40% probability (P = 0.4) that at a certain instant the signal will not deviate from its true value at all. As you slide down the curve, noise affects the signal, but the probability of large excursions (positive or negative) drops off rapidly. The curve never actually reaches the horizontal axis, so there is always a slight possibility of a ‘spike’ larger than 3σ every now and again. The inset graph shows the effect of increasing the value of σ: the curve flattens out, the probability of no deviation falls, and the size of a noise excursion increases. In other words, as σ increases, the overall noise gets worse.

Static Sensor Noise

Having defined the ‘enemy’, let’s look at some embedded systems which rely on accurate sensor measurements to function reliably. The ‘Static’ sensors generally used for environmental monitoring often only have to produce a reading at infrequent intervals. A weather station might only have to take readings of air temperature, humidity and barometric pressure every 15 minutes for example. In between, it operates in a very low power or ‘sleep’ mode, not doing very much. Such remote sensing stations are battery or solar powered and use a wireless link for communication. The measurement rate is so low that there is plenty of time for a ‘burst’ of samples to be taken, perhaps over several seconds and a simple averaging algorithm used to integrate-out the random noise. Technically this is still a real-time system, but one that operates in the time frame of paint drying. No elaborate filtering required here.

Dynamic Sensor Noise reduction with Sensor Fusion

Not long ago, the accelerometers and gyroscopes that made Inertial Navigation possible were very large, heavy and delicate pieces of expensive machinery. Inertial Navigation Units could only be afforded by the Military, Space and Civil aircraft manufacturing sector. The development of MEMS technology (Micro-Electro-Mechanical Systems) changed all that. Practically overnight INUs went from something the size and weight of a domestic fridge to a 5cm-square PCB costing about 30GBP. It meant that hobby R/C aircraft could have the type of guidance system only possible on a fighter jet just a few years before. Ground-based mobile robots could benefit too. Fig.2 shows the placement of a gyroscope device on two types of mobile robot. One system helps keep the balancing robot upright by measuring its ‘tilt’ angle. The other is used to maintain a mobile robot moving on a desired heading.

Sensor_Fusion_blog_4_51058a90086dd9b3a70bb1e0e6b997647159ce8f.png

In each case, an angle θ needs to be measured. The obvious sensor to use is the rate gyroscope which measures the rate of rotation about an axis in degrees/sec. Integrating the output yields the angle in degrees. The gyroscope responds quickly to changes and is insensitive to vibration noise along its axes, but it does have a major flaw: slight offsets in the rate output get integrated into an angle error that increases with time. In other words, it drifts, and a filter designed for zero-mean noise cannot correct for the increasing error. This is where the second sensors come in. For the balancing robot, two accelerometers are used with axes oriented 90° relative to each other. With the robot vertical, the z-axis accelerometer produces an output of +1g because of gravity. The tilt angle θ can thus be found by inserting the measured values for az and ay in this equation:

θ = arctan(ay/az)   where az, ay are normalised to lie in the range ±1g

The snag is that accelerometers are relatively sluggish to respond to changes, and they are liable to produce very noisy outputs in the presence of vibration, such as that from the motors. So now we have two angle sensors each providing nominally the same data, but with different defects. The answer is to combine or ‘Fuse’ the two in such a way as to eliminate the defects and produce a single clean output signal.

Complementary Filtering for the Balancing Robot

Tilt angle θa is derived from az and ay as above, then low-pass filtered to get rid of all the high-frequency noise, leaving a slowly changing or static value for θa. At the same time, the gyroscope rate output is integrated to yield θg, then high-pass filtered to block out the drift signal. The two signals are weighted then added together giving us a responsive ‘tilt’ measurement with no drift. The weighting factors are constants set at the time of programming, perhaps 0.95 for the gyroscope with a complementary 0.05 for the accelerometer. This type of fusion assumes that the sensors’ performance doesn’t change with time or suffer from temporary bursts of heavy interference. There are other algorithms such as the Kalman filter which can adapt to changing noise conditions by reducing the weighting given to a sensor if its output degrades.

The Kalman Filter

The Kalman filter algorithm was developed in the early 1960’s for the purpose of removing zero-mean noise disrupting a signal and is applicable to any kind of system that can be described with a linear equation. It came to fame (in the engineering world at least) with its use in the inertial navigation programs running on the NASA Apollo guidance computer. It’s so good that most real-time sensor-driven applications working in noisy environments still use it today. What makes the Kalman filter so clever? It uses a deceptively simple two-step process of predicting the output, then comparing this prediction with a measurement to update the next prediction. It maintains a figure of ‘uncertainty’ concerning the sensor measurement which is also updated. If a sensor output starts getting noisier, the Kalman algorithm reduces the influence of the measurement on the output and increases the importance of its own estimate. Unfortunately, the algorithm is way too complicated to describe in a few words, but this article is the best I’ve seen so far on the subject, containing a worked ‘real-world’ example with MATLAB simulation code and results. It is heavy on matrix mathematics so I suggest some study in that area if you are not already familiar with it. Key things to know about the algorithm in order to decide if you can/need to use it:

  • The process to be measured must be described by a linear system. An example is a simple linear motion system based on acceleration, velocity and position. An Extended Kalman Filter was developed by people at NASA to deal with non-linear systems but the maths is even worse.
  • A sensor measurement consists of a mean value and its variance. For optimal performance not only must the system model be accurate, but so must these variances for signal inputs. You might find correct values on a datasheet, but some lab testing may be necessary.
  • The noise must have zero mean (as in AWGN). The filter will effectively assume any part of the measurement that isn’t zero-mean, like the gyroscope drift mentioned earlier, is the wanted signal: it will not be recognised as noise and not minimised.

The Kalman filter is often illustrated in literature using just one sensor input, but it can handle two or more providing sensor fusion. Of course, the real-time processing requirement, even for a single input is fairly heavy and gets a lot worse with more. Until fairly recently this presented a severe limitation, but far less so now given 32-bit microcontrollers with floating-point maths units, DSPs and even parallel data manipulation using Single Input Multiple Data (SIMD) hardware such as ARM’s NEON. The algorithm itself can be simplified by declaring some of its many variables equal to 1 or 0 ‘for practical purposes’, but this needs to be done with great care in order not to compromise its amazing power of adaptive noise reduction. Sensor fusion with Kalman filtering offers something else too: increased reliability through intelligent redundancy.

Increasing Reliability with Sensor Fusion

Small multirotor helicopters or drones have become very popular with radio-control aircraft enthusiasts and commercial aerial photographers in recent years. Most of this can be put down to the onboard flight control systems made possible by the miniaturisation of motion sensors, the electronic compass (magnetometer) and powerful microcontrollers. Without ‘fly-by-wire’ computer stabilisation, quadcopters and hexacopters are just not practical. That said, the environment these new sensors operate in is pretty hostile and even experienced ‘pilots’ lose control resulting in ‘stabilisation with a vertical downward trajectory’. This can happen when accelerometer and gyroscopes are overwhelmed by motor vibration and high-G manoeuvring. GPS data is frequently fused with IMU outputs to improve navigation and maintain stable flight if the IMU can’t be relied upon. GPS can lose accuracy at a critical moment though, so professional drones often carry two GPS receivers of different makes. The outputs of two GPS modules and the IMU are ‘fused’ by a Kalman filter which will use its adaptive capabilities to select the best sensor data and ignore the worst. Such redundancy may result in a degraded flight profile but that’s a whole lot better than ‘uncontrolled contact with terrain’.

Oemichen2_f7d436792a9cd48960dfdb61493becd45688e5fa.jpg

Inertial Measurement Units

Although accelerometers and gyroscopes are available as individual chips with analogue outputs, the trend now is to buy them integrated together as one device, often with low-pass filters and ADCs delivering serial data to output pins in SPI or I2C bus format. They are usually ‘3D’ devices providing motion data in three axes and come with internal signal processing, mainly to correct for gyroscope drift. Some include 3D magnetometers as well and are described as ‘9-DOF’ (Degrees of Freedom) devices. As ever with electronics design, PCB track layout and relative positioning of chips on the board are crucial for successful operation. These MEMS chips add an extra dimension, that of mechanical considerations. For example, poor soldering or placement of fixing holes can cause unwanted mechanical stresses and upset calibration or worse. Check out this manufacturer’s design guidelines.

And finally…

This article has only scratched the surface of Sensor Fusion: I haven’t mentioned alternatives to Kalman filters such as those by Madgwick and Mahony, or discussed the fusion of video camera data with Lidar and Radar for autonomous vehicles. One thing’s for sure: motion sensor fusion has never been such a hot topic, whether you’re working on automated factories, driverless cars or deep space probes.

If you're stuck for something to do, follow my posts on Twitter. I link to interesting articles on new electronics and related technologies, retweeting posts I spot about robots, space exploration and other issues.

Engineer, PhD, lecturer, freelance technical writer, blogger & tweeter interested in robots, AI, planetary explorers and all things electronic. STEM ambassador. Designed, built and programmed my first microcomputer in 1976. Still learning, still building, still coding today.
DesignSpark Electrical Logolinkedin