External compass orientation

Hi,

I know that setting external compass orientation is possible via SENS_BOARD_X_OFF… parameters before flight. I was looking for compensation for vehicle roll and pitch in the code, i.e. if the vehicle rolls or pitches during flight, that is surely affecting the magnetometer reading, but I couldn’t find where it is done. Can someone point it out in the firmware code?

Another question about compass orientation is that how much of an error is acceptable when mounting the compass? For example, if I set the orientation to 0 degrees on all axes, and I mount the compass 5 degree off on roll axis, how much does that affect compass reading and heading estimation?

Thanks for any help in advance!

The vehicles movement during flight shouldn’t affect the mag reading at all.
Any offset on any axis will be automatically compensated for after calibration.
The autopilot then has a reference to its local frame and the earth’s magnetic field is all around. :wink:

1 Like

@Christian-Born Thanks a lot, I could finally find this in the codebase, too!

Do you know anything about the acceptable mounting error of the compass relative to the flight controller?

Another question about compass orientation is that how much of an error is acceptable when mounting the compass? For example, if I set the orientation to 0 degrees on all axes, and I mount the compass 5 degree off on roll axis, how much does that affect compass reading and heading estimation?