Heading calculation and logging

Hi,

my team and I are currently building a drone, but we have issues with the compass. It seems that the current which goes to the motors is so strong that it influences the internal magnetometer quite significantly. Hence, we installed the GPS module with a magnetometer installed as far away as possible from the power lines. Our problem is that px4 seems not to select the magnetometer from the external GPS module, although we gave it a high priority.

In the debug process, we came along the EKF module. It seems that the EKF module is used to determine the heading of the aircraft (but I’m not 100% sure about this). The problem is that the EKF instances are chosen according to a best error term, where the magnetometer seems not to be taken into account.

My question is at first how the heading is determined by px4 in detail and why the CAL_MAG_PRIO parameter seems to have no influence at all.

What GPS/mag are you using? Usually, an external mag is used by default.

Can you share the output of dmesg if available, and the output of listener sensors_status_mag (or something similar, check uorb top for topic names.