Use a Kalman Filter (KF) algorithm with this neat trick to fuse multiple sensors readings. The resulting estimate will be more accurate than what you would get with single sensor.
- First implement a KF or EKF that can handle a single IMU (Accel, Gyro, Mag) and a pressure sensor. One of my Stack Overflow answer can be a good starting point for this.
- The Kalman Filter's prediction and correction equations will be of this form.
X_k1 = A * X_k + B * U_k
Y1 = C * X
Y1 array will contain the different readings (gyro, mag...) from a single IMU along with a single pressure sensor altitude. Similarly Y2 will correspond to the second set of readings.
Just append the output array from different sensors vertically,
Y12 = [Y1; Y2]
Similarly append the C matrix
C12 = [C; C]
New observation equation will be,
Y12 = C12 * X
Use this new observation equation instead of the old one and the Kalman Filter algorithm will fuse the data.