Wednesday, March 01, 2006

HiTechnic's Digital Compass

Previously, we reported that HiTechnic will have a digital compass ready for Mindstorms NXT in time for the launch. Today, Steve from HiTechnic sent us more details about the product.


© HiTechnic.
A picture of the new NXT Compass sensor


Why Do You Need a Compass?


A common way for a robot to know its position, it to count the number of rotations its motors, a process called dead reckoning. Dead reckoning is a great technique, but there are two physical problems with it. Slipping wheels cause errors, and collisions may throw it off course. Another problem with dead reckoning is that if you want the robot to retrace a previous path, it must be exactly in the same position. Often, it is very hard to position the robot so accurately at its starting position. Turning the robot by one degree is hardly visible.

A high accuracy compass makes it a lot easier to determine your position. You still count the number of rotations of your motors to understand how far the robot has traveled, but you use the compass to steer the robot in the right direction. When the robot starts, it does not matter as much whether the robot is a few degrees off course. Using its compass, it will immediately correct to drive in the intended direction.

More advanced software can combine the directional calculations of dead reckoning with digital compass measurements to provide the best performance, but this is beyond the level of the average Lego Mindstorms NXT builder.

If you are building a walking robot, dead reckoning is even more complicated. In these cases, the compass may be all you have to go on.


HiTechnic’s NXT Compass


HiTechnic's new compass for Lego Mindstorms NXT is well suited for its job. The compass is accurate to 1 degree, which is just what you need to rely on it for navigation. Reading the compass is very easy. The compass returns a value from 0 to 359 degrees that indicates the direction the sensor is currently pointing in.

Off course, there is only 1 degree difference between 359 and 0 degrees. Since a robot easily slips one degree, you may be fluctuating from 0 to 359 and back. Make sure your robot software shouldn't overreact to such seemingly large differences!

A compass works by detecting the magnetic field of the Earth. Magnetic sources nearby can seriously disrupt any compass, and electric motors create a magnetic field when they work. Putting a compass on a robot can therefore create very strange results. Fortunately, the effect can be compensated by measuring the distortion of the local magnetic fields. Measuring and storing the amount of compensation is called calibration. To calibrate the compass, you need put it in calibration mode, and drive the robot in a circle.

On HiTechnic's legacy RCX compasses, there is a button on the sensor that puts the compass into calibration mode. For the NXT, HiTechnic has raised the bar. You can put the compass into calibration mode from within your program. So when the robot wakes up, you can automatically put the compass sensor into calibration mode, have the robot turn (at least) 360 degrees, and finalize the calibration. How cool is that?

HiTechnic's NXT Compass remembers the calibration values, even when powered off. So after you build the robot, you only need to perform the calibration once. However, if you use the robot later at a different location, you may still need to recalibrate the sensor to compensate for the local magnetic environment. Perhaps you could provide a calibration option in your software? For instance, "if the touch sensor is pushed when starting up, then recalibrate". As a result, you can hide the compass sensor somewhere in the body, and trigger the calibration by pressing an external sensor (or button) when the robot starts. You could even use my previous post on Bluetooth, to recalibrate the robot using your mobile phone as remote control.

Because the calibration is under software control, you can also prevent calibration when it is not appropriate. For instance, recalibrating in the middle of a maze or halfway on its route is bound to disorient the robot! It would be better to drive the robot back to its base station and recalibrate there. With HiTechnic's NXT Compass, it is up to you to decide when you allow to the sensor to recalibrate, and what other actions you take when it does!


Accurate When Horizontal


The compass sensor is designed to be accurate when horizontal, although you may get away with not mounting it perfectly horizontal. Steve from HiTechnic explains the errors related to the horizontal position:
Compass dip, or the angle of the earth's magnetic field (up or down) at the earth's surface, together with pitch and roll which produce compass errors will not typically be a factor in using this sensor because of the relatively small distances and slow speeds involved unlike a compass in an aircraft for example, which will be more prone to dip error, especially when close to the poles, and errors when rolling in and out of turns.

Any compass error will depend on a number of factors including distance from the equator (the closer to each pole, the greater the dip angle) and pitch and roll angles, and the heading relative to these factors. Compasses on ships are gimbaled so they can stay horizontal to compensate but in the typical NXT application I don't expect these to be significant factors. Keeping the Compass Sensor horizontal and calibrating it for each installation will minimize errors.


Illustration of dip angle

If you didn't get that, don't worry. Just keep the sensor horizontal and recalibrate the sensor from time to time!


Technical Specifications


For the technically inclined, here a short note by Steve from HiTechnic on the NXT compass and its calibration:


© HiTechnic.
Interior of the NXT Compass sensor


The compass uses a Honeywell dual magnetometer. The results obtained from the two magnetometer channels are processed by an onboard PIC micro controller which computes the ArcTan of the two channels' readings and outputs a magnetic reading value between 0 - 359.

To ensure accuracy in every installation, the compass should be calibrated to negate the effects of any local magnetic interference from sources such as the NXT. The onboard firmware can be set to calibration mode under program control from the NXT.

The compensation consists of measuring the response of the two channels during a complete revolution of the device and computing the locus of the readings. This locus should be circular, centered on (0,0). Calibration coefficients are calculated and are those values necessary to adjust the raw readings to make them circular and centered on (0,0). Once calibrated, the NXT Compass will retain the compensation values, even when powered off.

5 Comments:

At March 01, 2006 2:30 PM , Blogger Louis Davis said...

This is very interesting. I am looking forward to working with the digital compass whenever I can get my hands on an NXT.

I was wondering how they were able to get the proprietary connector and case. Do they have an arrangement with Lego that provides them with these things.

I would love to have access to at least the connectors for my own creations.

 
At March 02, 2006 11:33 PM , Anonymous Daniel Wittenaar said...

As far as i know is that the owner of HiTechnics is 1 of the MPU users..

That means that they have helped to 'design'the NXT.. So i think that is why he has those connectors.. Just from lego..

 
At March 03, 2006 12:36 PM , Anonymous Filip said...

In addition to what Daniël said, I think the specifications will be available after the product launches in August, and to those who are currently selected for the Mindstorms Developer Program.

 
At March 17, 2006 4:20 PM , Anonymous Anonymous said...

Is this Steve from HiTechnic part of LEGO MUP or MDP? How does he have all this information about NXT ?

 
At March 20, 2006 10:45 AM , Anonymous Filip said...

John Barnes, owner of HiTechnic, was one of the original 4 MUPpets. He was selected because Lego was impressed with the sensors he built for Lego Mindstorms RIS (RCX). Steve Barker works at HiTechnic and does a great job of keeping in touch.

Steve Hassenplug was also member of the original 4 MUPpers, but is not related to HiTechnic.

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home