Magnetometer support in new APM code

Hi all,

 

I'm trying to get the best result from my magnetometer, without a big succes at the moment !

As explained here : http://code.google.com/p/ardupilot-mega/wiki/MagnetometerTest , there is a rotation matrix to apply when you have soldered your magnetometer as explained here : http://code.google.com/p/ardupilot-mega/wiki/Magnetometer

 

So I tried every matrix commented below in the magnetometer initialization code :

 #if MAGNETOMETER == ENABLED
  APM_Compass.Init(); // I2C initialization
  APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_RIGHT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_LEFT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_FORWARD_LEFT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_BACK );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_BACK_RIGHT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_BACK_LEFT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_FORWARD_RIGHT );
  // APM_Compass.SetOrientation( APM_COMPASS_COMPONENTS_DOWN_PINS_FORWARD );
 
  APM_Compass.SetOffsets(0,0,0);
  APM_Compass.SetDeclination( 0.0133 );
 #endif

The resulting heading is quite the same for all of this rotation matrix : result is ok when you rotate on the yaw axis, but when you give a bit of pitch, yaw is moving, and when you give 180° on the roll axis, the yaw axis is reversed...

 

So before to go further, what is the correct rotation matrix to apply as suggest in http://code.google.com/p/ardupilot-mega/wiki/MagnetometerTest ?

 

Thanks !

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity