Which Compass to Use?

I want to implement a compass in the robot (I understand it is very sensitive to magnetic fields, but I still want to experiment); which compass sensor is recommended?
I couldn’t really find any useful info other than the HiTechnicCompass header file (http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NMC1034 ?) which seems to have an I2C interface.

The HiTechnic Compass plugs directly into the i^2c port on the digital sidecar. Programming it in C++ with the WPI library is incredibly simple, see program below.

Here’s the WPI doc on it:
http://www.virtualroadside.com/WPILib/class_hi_technic_compass.html


#include "WPILib.h"

class CompassBot : public SimpleRobot {

	HiTechnicCompass compass; // Define compass object

public:
	float angle;

	CompassBot(void):
		compass(1) // Initialize to i2c port 1
	{
		GetWatchdog().SetExpiration(0.1);
	}

	void Autonomous(void) { }

	void OperatorControl(void) {
		while (IsOperatorControl()) {
			angle = compass.GetAngle(); // Get the angle (returns float)
			printf("Current Angle: %f", angle); // Print angle
		}
	}

};

START_ROBOT_CLASS(CompassBot);

I second the HiTechnic compass. I found it to have a normal accuracy of +/-2-3 degrees, and a worst case accuracy of +/- 5 degrees. Your results may very, but I found the only issue to be the lag getting info from the sensor.

If you need quick response times you should look at using the included gyro. It is almost as simple to configure and use as the compass.

I will third the HiTechnic but might I sugest a gyro. The gyro only floats by a couple degrees throughout the match it you mount it flat and it isn’t as sensative to interference.