# externally calibrating magnetometer before sending it's data to the imu_filter_madgwick ?

Hello,

As far as I understand, imu_filter_madgwick filters and fuses raw readings from IMU, then calculates the orientation. It is not clear to me however if we should externally calibrate the magnetometer before sending it's data to the filter.

Based on the algorithm ( http://www.x-io.co.uk/res/doc/madgwic... ), the reference direction of earth's magnetic field can be computed using the estimated roll/pitch orientation from accelerometer data. But still I am not sure if I need to compensate for the hard iron?