circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

April 2004, Issue 165

Mini Rover 7
Electronic Compassing fo Mobile Robotics


by Joseph Miller

SOFT/HARD IRON DISTORTION

As you now, producing a compass heading with a pair of sensors is fairly straightforward. However, there’s trouble in the neighborhood. Magnetic anomalies are all around you. Other magnetic sources and alternate magnetic flux pathways are corrupting your intended signal—the Earth’s magnetic field.

Magnetic fields are generated by electrical current (electromagnetism) in your circuitry and neighboring appliances. There are permanent magnets in your robot’s motors, and there is magnetized metal in the robot’s construction materials.

Items external to the robot, such as appliances, underground pipes, and ducts may have their own fields, and can locally offset or change the direction of the Earth’s field. Items that create offsetting fields are classified as hard iron. A soft iron material is anything that alters the natural path of a magnetic field’s lines of flux. By "natural path" I mean its path through air. Put another way, any material with a relative permeability other than one is a soft iron material. A soft iron also can have a hard iron effect. Usually soft iron and hard iron materials are referred to by the effect they have on the surrounding magnetic field. These effects are easy to recognize when an x-y graph is plotted of the compass sensors output values as the compass is rotated through 360°. Figure 3 illustrates these effects.

(Click here to enlarge)

Figure 3—The x-y plots show various magnetic distortion effects.

All of the plots assume that the culprit material is local, which is to say that it is onboard the robot when it is rotated. These traces, or profiles, can be thought of as the magnetic signatures of the robot’s local environment. Notice how the soft iron effects create an elliptical profile. Soft iron material attracts, bends, and condenses magnetic flux toward itself, creating sparse field densities on its lateral sides. At the same time, it will also create dense magnetic fields in areas that are in line with it and the source field direction, as shown in Figure 4. The distribution and quantity of soft iron material will determine the alignment and offset of the ellipse’s foci.

Figure 4—Here you can see the effects of soft iron distortions in the Earth’s magnetic field.

Nearby electromagnetic fields, ferrous construction materials, and motors make robots especially tough environments for compasses. Before using an electronic compass in a mobile robot, it is a good idea to analyze its magnetic signature by creating an x-y sensor plot. From this plot, you can identify the existence of the aforementioned simple distortions and, more importantly, the more complex ones. The plots should give you an indication of the compass’s chances of providing accurate readings, as well as information to help you make corrective adjustments to the robot or sensor placement.

Modern electronic compasses have little trouble mathematically correcting for simple soft iron and hard iron distortions, sensor gain mismatch, and even sensor misalignment (orthogonality), which are all shown in Figure 3. Electronic compasses calculate the correctional coefficients after completing a one-time calibration procedure that involves rotating the robot or vehicle through at least one complete rotation so that it can analyze the geometry of the x-y sensor data.

When testing your robot and creating plots for your analysis, the patterns to watch for are excessive hard iron offsets and multimode soft iron distortions, which look like lumpy circles or ellipses. Excessive hard iron offsets can bring sensors into their nonlinear regions. This looks like a flat spot on the x-y circle plots, which are perpendicular to the axis of the saturated sensor. It is also a good idea to create plots for the robot when it is rotating both clockwise and counterclockwise, and then compare the two to see if the motor currents affect sensor readings.

Figure 5 shows x-y sensor plots (magnetic signature plots) running on my Mini Rover 7 robot. The red trace shows that the robot has some hard iron offsets but no soft iron distortions. I rotated the robot in both directions under its own power and saw nothing significantly different, although it would be hard to see any rotational offsets with these plots. There are ways to test this.

Figure 5—Here are several magnetic signature plots of the Mini Rover 7 with additional effects.

The slightly elliptical blue trace is the result of placing a 9-V battery next to the compass. I placed a small magnet in the robot when I generated the light blue trace. The dark blue trace is the result of placing a PC chassis next to the robot when it performed a rotation. The small amplitude is to be expected because the external soft iron material attracts the magnetic flux away from the robot, therefore creating an area with a sparse field, much like the one in Figure 4. You should not calibrate the compass in your robot under this condition because it does not represent a normal condition. Any electronic compass with hard iron and soft iron compensation should have no problem producing accurate heading data using any of the vehicle magnetic signatures shown in Figure 5.

As you have seen, with a little effort a compass can adapt itself to your robot’s unique internal magnetic signature by using its built-in calibration algorithm. However, when operating after calibration, your robot will most likely come across external hard iron and soft iron objects, which will alter the Earth’s magnetic field direction.

Figure 4 shows how a soft iron object can alter the heading of a robot as it attempts to keep steady (north in this case) when it moves past the object. Notice that the field density is sparse in this area. As long as the sensors are relatively close (so that they experience the same field density ratios), the compass abilities are not significantly diminished. This is because the heading calculation for a quadrature sensor pair uses the arctangent of the ratio of the two sensors (see Equation 2). The overall field density, or magnitude of the field density, can be monitored by calculating the geometric sum of the two sensors (see Equation 4), which can alert you to such anomalies. This information can be used to weigh your options.

You may decide to temporarily trust differential wheel encoder outputs for tracking heading while the overall measured field density falls outside established thresholds. A Kalman filter or your own statistical algorithm can use this information with other sensor data to make improved estimates of actual heading. It is important to use the compass’s calibrated x-y sensor data to compute field density because it already has been compensated for your robot’s personal magnetic signature. Modern electronic compasses like the PNI V2Xe can report the overall field density in proportion to the field that it experienced at every heading angle during a calibration cycle so that local field distortions do not interfere with the assessment of external magnetic fields.