Compass calibration not used

Hi everybody. I need the current compass heading in a companion computer. I’m using a heading calculation provided by code in the mavlink repository ( That code appears to work fairly well if I DON’T use compass calibration offsets. If I do use calibration offsets the returned heading is way, way off. Having a hard time understanding how uncalibrated magnetometer values can provide an accurate heading value, but it appears that they do. Input to this calculation is RAW_IMU magnetometer readings. BTW I have run the compass calibration procedure in Mission Planner and the returned offset values are far from zero (in the 200 mgauss range). So the compass does appear to need calibration. My only current guess is that the RAW_IMU values are already using the calibration offsets. But I can’t find anywhere in either the .py code or in the C++ code where that might be happening. Any help or suggestions would be appreciated.