## Friday, February 10, 2012

### AVC: Is a Compass Necessary?

 LSM303DLH on Pololu Board
While building my 2012 AVC entry, basic questions keep coming up. What sensors are really needed to reliably run around the course?

Do we really need a compass?

Looking at 2011 top finishers, 3rd place Team XYZZY used an ArduPilot board to create a tilt-compensated compass, adding GPS, and a wheel encoder.

The 2nd place finisher, Team Minuteman, ran only a gyro and wheel encoders using a record-playback approach.

Team Tobor placed 1st for the second year in a row using fairly sophisticated mathematics to fuse data from a 1-axis gyro, 2-axis compass (effectively), encoders, and a GPS.

What if we just use a gyro, let's say an Analog Devices ADXRS610 like the one used by Team Tobor. How much error are we talking about? Let's find out using simple math and GNU Octave (free matlab-ish tool)...

MEMS gyros suffer from drift which can be minimized, per the datasheet, to 200°/hour using their 3-point calibration technique. That works out to 0.0556°/second. The course is about 270m long and at last year's speeds of about 5m/s, it takes approximately 60 seconds to complete.

I wrote a simple Octave script (download: gyrodrift.m) to answer the question, assuming a constant speed and a straight track for simplicity. Define the time step dt to be 0.100 seconds, and define the distance delta to be velocity times dt

dt = 0.100; % delta time
dx = v*dt;

Now define positions, x, along the course (I'm assuming a straight course for simplicity) with a step of dx meters. Then define time values given the position values.

x=0:dx:271; % position at each time step given speed
t=x/v; % time values at each dt

Now we can figure out the cumulative gyro error in degrees at each time step:

h=t*0.0556; % cumulative error in degrees at each time step

That gives us what we need to compute the position error at each position step

dxerr = dx*sin(h*pi/180); % pos error per step

From which we can, at long last, compute the cumulative position error over the course through numerical integration:

xerr = cumtrapz(dxerr); % cumulative sum; integrate numerically

Wrap all that in a function, and plot the results. For a speed of 5m/s, we get a total position error of  just over 7m by the race's end.

But, if you want to win the AVC in 2012 you sure as heck better be going faster than 5m/s. Let's say the speed-doubling trend continues and you run 10m/s. By the end, position error is 3.6m.

So is a position error of 3 meters too much?  Ultimately, each AVC entrant has to decide for himself or herself. Among the things to consider:
• This is the same amount of error you can expect from your GPS, best case scenario.
• If the robot goes faster, cumulative position error reduces, all else being equal.
• The datasheet claims a minimum error 40°/hour with more extensive calibration
• You can probably find MEMS gyros with better drift performance; the ADXRS610 is obsolete.
• One could calculate heading from wheel encoders to improve heading estimates.
• Turns may have some residual effect on gyro readings after returning to a straight course. I haven't tested this myself.
• Compasses are not perfect, suffering from possible soft-iron distortion, poor heading accuracy (1-2 ° is typical), external interference, etc.
Some time ago, I made a design decision without really running the numbers. It's much better to analyze first, then decide.

What would you choose?

1. The lesson pulled from the AVCs so far is twofold: One, Don't rely on GPS.

Two, whatever position system you rely on most has to really work. It has to be calibrated, compensated if possible, etc.

Other than that, the finish order last year was, in my opinion, largely due to luck. Scott's robot, Tobor was 'luckier' in that it was a more consistent finisher overall, which statistically improved it's chance of going through the hoop on a faster run.

This year, you must go fairly fast (20 MPH or so I think will be sufficient) and you need to have a good chance of going through the hoop each run.

That means you need a reliable robot that can consistently complete the course and actively tries to go under the hoop each time.

2. This is an interesting question and a good analysis. You took the relative error of the gyro and accumulated the error of the calculated absolute position.

My intuition suggests that the circuitous nature of the AVC course will assist in a magnetic compass's absolute error being minimized. Restated: the sum of the error of an absolution heading approaches zero as the vehicle's heading is integrated about 360-degrees during the course of the event.

Because a gyro's error is relative, I do not believe it will benefit from the course being a complete circuit. Conversely, if the course were not a circuit, the magnetic compass would not have the advantage.

But my debate position would be to utilize both sensors and an algorithm such as the kalman filter to make the best estimate of the heading. A good AHRS will do this (fuse a tilt-compensated compass heading with gyro readings). I also can't argue with the results of DPA's jBot which used the fused compass heading from an AHRS and wheel encoders to perform accurate dead reckoning navigation (http://www.geology.smu.edu/dpa-www/robo/Encoder/imu_odo/)

!!Dean
deanandara.com/Argonaut