Are the magnetometer axes right? I was measuring a field pointing up and to the south today instead of down and to the north (in N America) as expected. Line up the figure from the datasheet on page 3 with the AHRS. If the datsheet is displayed on a computer screen, then the AHRS should be held in front of you, with the bottom face facing you and the "front" arrow pointing to the right. Then
chip +x points to AHRS -y
chip +y points to AHRS -x
chip +z points to AHRS -z
Now consider the code in ahrs.c, around line 346 (calibration code omitted):
mag_data.scaled.axis[0] = mag_data.raw.axis[1];
mag_data.scaled.axis[1] = mag_data.raw.axis[0];
mag_data.scaled.axis[2] = mag_data.raw.axis[2];
That can't be right: if two axes are swapped, and the chip has a right-handed coordinate system, then that would produce a left-handed coordinate system. The way to flip it back to right-handed is to multiply all of them by -1, too.
Am I crazy? If anyone else can confirm, then I'll go ahead and check in the fix.
Magnetometer axes?
Started by Jonathan Brandmeyer, Nov 04 2010 12:22 AM
2 replies to this topic
#1
Posted 04 November 2010 - 12:22 AM
#2
Posted 04 November 2010 - 12:27 AM
Or is this where the negative signs in the old calibration scale factors come from? Which begs the question: Why is this being done in the calibration scale factors, instead of by the firmware itself?
#3
Posted 04 November 2010 - 04:28 PM
Correct, we rotate the axis of the mag to match the standard used by the INSGPS algorithm. The scaling multiplication is done in firmware which includes the sign swap.



United States








