Hey all
I have a Hitechnics compass sensor. It is giving readings with errors up to 30*.
For example: I place the bot on the ground and draw a parallel line against the side of it (parallel also with the sensor). Then I look at the reading on screen, and turn the bot around so it's lined up with the same line but facing the exact opposite direction. Results are up to 30 degrees off what I expect.
The sensor is mounted completely flat, ~5" from the NXT and motors and I have even performed calibration routines as described on the Hitechnics site and LeJOS API docs.
Is this normal? I was hoping to use the compass to assist odometry but this seem unlikely now!
Or should I be looking to return it to Hitechnics?
The only thing I can think of to fix it is creating a look up table by rotating the bot and calculating real bearings via tachometer readings and storing them vs compass readings to fix the skewed areas.
Thanks
Inaccurate Hitechnic Compass
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Inaccurate Hitechnic Compass
have you tried doing the same thing in a different part of your house/building? You may find that things like stoves, or radiators or structural steel are having an effect on the compass reading... This is a general problem with the compass. As you said you may be able to create a map to correct the readings. Or perhaps have a location that the robot can return to (when for instance you estimate of odometry errors has exceeded a threshold) that has a known magnetic state and only use the compass to correct things when back in that area....
Re: Inaccurate Hitechnic Compass
5-10 degrees deviation indoors (Inclination, Variation...) is normal to my own observations.
But 30° sound exorbitant.
Have you once calibrated the compass before?
But 30° sound exorbitant.
Have you once calibrated the compass before?
-
- Posts: 76
- Joined: 29 Sep 2010, 06:57
Re: Inaccurate Hitechnic Compass
There was a long discussion about this a little while ago in another thread:
https://sourceforge.net/apps/phpbb/mind ... p?f=4&t=85
The short answer is that the sensor itself can be very accurate, but is highly susceptible to errors due to stray magnetic fields or tilt.
Is the amount of error the same each time (to within two degrees), or different?
Matt
https://sourceforge.net/apps/phpbb/mind ... p?f=4&t=85
The short answer is that the sensor itself can be very accurate, but is highly susceptible to errors due to stray magnetic fields or tilt.
Is the amount of error the same each time (to within two degrees), or different?
Matt
Re: Inaccurate Hitechnic Compass
Have you once calibrated the compass before?
Re: Inaccurate Hitechnic Compass
Thank you all for your replies, I apologise for my slow response, I have been very busy.
doc-helmut: Yes I calibrated the compass several times, following the instructions on the hitechnics website. I wrote a program to rotate the bot 1.75 turns at a speed of about 40 seconds per turn whilst calibrating it.
matt: Thanks for the link, this is very interesting to me. I actually had a lecture on kalman filters just today, so this is a good tie in. Yes the error is repeatable (at least it was in the location I was testing). It produced the same errors each time.
As for what is causing it, I think the idea about iron/steel in the building is correct. I live in a brand new apartment building and I imagine it probably has a steel frame and supports.
Thanks again for the helpful responses.
doc-helmut: Yes I calibrated the compass several times, following the instructions on the hitechnics website. I wrote a program to rotate the bot 1.75 turns at a speed of about 40 seconds per turn whilst calibrating it.
matt: Thanks for the link, this is very interesting to me. I actually had a lecture on kalman filters just today, so this is a good tie in. Yes the error is repeatable (at least it was in the location I was testing). It produced the same errors each time.
As for what is causing it, I think the idea about iron/steel in the building is correct. I live in a brand new apartment building and I imagine it probably has a steel frame and supports.
Thanks again for the helpful responses.
-
- Posts: 18
- Joined: 28 Sep 2010, 23:57
Re: Inaccurate Hitechnic Compass
Given the type of error you were stating, as much as 30 degrees off, I suspect that your sensor is not properly calibrated. The problem with the NXT-G program for calibrating the compass is that you can't tell if it succeeded or not. The sensor has a built-in mechanism to reject a calibration attempt if it finds that something was not right. The problem with doing this in NXT-G is that you have no idea if the calibration took or not.
Below is an NXC program for calibrating the sensor. This program will query the sensor after the calibration and let you know with a sound signal as well as a message on the NXT screen. To adapt the program your robot, make sure that the DRIVE_MOTOR and COMPASS constants are set correctly. The program also displays the current compass heading on the NXT screen which is useful to verify the calibration.
If after the calibration the sensor still appears to have a large error, double check the level of the sensor and then recalibrate and test again.
Gus
Below is an NXC program for calibrating the sensor. This program will query the sensor after the calibration and let you know with a sound signal as well as a message on the NXT screen. To adapt the program your robot, make sure that the DRIVE_MOTOR and COMPASS constants are set correctly. The program also displays the current compass heading on the NXT screen which is useful to verify the calibration.
Code: Select all
//=====================================================================
// HiTechnic Compass Calibrate Program
//
// Use this program to calibrate your HiTechnic compass sensor.
// Attach the Compass sensor to a robot driving base. Make sure
// that the sensor is perfectly level. If the sensor is not level
// you will not get accurate compass readings. If necessary, use
// a small carpenters level to check the mounting of the sensor.
//
// This program will display on the screen, both before and after,
// the calibration procedure, the current compass sensor reading.
// To start the calibration procedure, press the Enter button on the
// NXT. After calibration the NXT will play a tone and display a
// message indicating if the calibration was successful or not.
//
// The constant DRIVE_MOTOR should be OUT_A, OUT_B, or OUT_C
// and correspond to one drive motor of your robot. Driving
// this one motor should make your robot turn in place.
#define DRIVE_MOTOR OUT_B
// Set the constant COMPASS to correspond to the port that
// the HiTechnic Compass sensor is attached to.
#define COMPASS S4
// This is the power and time (in milliseconds) that the robot
// spends turning. With the specified power and time, the robot
// should rotate at least one full rotation, more is okay. Power
// should be as low as possible and still have a smooth driving
// of the robot.
#define DRIVE_POWER 30
#define DRIVE_TIME 20000
//=====================================================================
// bool HTCompassCalibrateStart(const byte & port)
//
// Set HiTechnic Compass to Calibrate mode. While in Calibrate mode,
// robot should slowly turn more than 360 degrees for duration of about
// 20 seconds. Call HTCompassCalibrateStop to stop calibration mode.
//
bool HTCompassCalibrateStart(const byte & port)
{
int count;
byte inI2Ccmd[];
char outbuf[];
ArrayInit(inI2Ccmd, 0, 3);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x41; // Mode:
inI2Ccmd[2] = 0x43; // Calibrate
count=0;
return I2CBytes(port, inI2Ccmd, count, outbuf);
}
//---------------------------------------------------------------------
// bool HTCompassCalibrateStop(const byte & port)
//
// Stop the Calibration mode that was started by
// HTCompassCalibrateStart. Returns true if the calibration was
// successful.
bool HTCompassCalibrateStop(const byte & port)
{
int count;
byte inI2Ccmd[];
char outbuf[];
bool bSuccess;
if (port > IN_4)
return false;
ArrayInit(inI2Ccmd, 0, 3);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x41; // Mode
inI2Ccmd[2] = 0x00; // Normal Read
count=0;
bSuccess = I2CBytes(port, inI2Ccmd, count, outbuf);
if (bSuccess) {
Wait(100);
// Read back location 0x41 to see if successful
ArrayInit(inI2Ccmd, 0, 2);
inI2Ccmd[0] = 0x02;
inI2Ccmd[1] = 0x41; // Mode
count=1;
bSuccess = I2CBytes(port, inI2Ccmd, count, outbuf);
if (bSuccess) {
bSuccess = (outbuf[0] == 0);
}
}
return (bSuccess);
}
//=====================================================================
//
task main()
{
int heading;
bool bSuccess;
SetSensorLowspeed(COMPASS);
Wait(100);
TextOut(0, LCD_LINE1, "HiTechnic");
TextOut(0, LCD_LINE2, " Compass Sensor");
TextOut(15, LCD_LINE8, "[Calibrate]");
while(true) {
heading = SensorHTCompass(COMPASS);
TextOut(0, LCD_LINE4, "Heading: ");
NumOut(8*6, LCD_LINE4, heading);
// Check for Enter button
if (ButtonPressed(BTNCENTER, false)) {
// Wait for release
while(ButtonPressed(BTNCENTER, false));
TextOut(0, LCD_LINE4, "Calibrating...");
// Start turning robot
OnFwd(DRIVE_MOTOR, DRIVE_POWER);
HTCompassCalibrateStart(COMPASS);
// Calibrating while robot is turning
Wait(DRIVE_TIME);
// Stop Calibration
bSuccess = HTCompassCalibrateStop(COMPASS);
Off(OUT_B);
if (bSuccess) {
PlaySound(SOUND_UP);
TextOut(0, LCD_LINE6, "Cal. success!");
} else {
PlaySound(SOUND_LOW_BEEP);
TextOut(0, LCD_LINE6, "Cal. failed.");
}
}
Wait(100);
}
}
Gus
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests