In view of the shortage of redundancy when using quaternion to describe attitudethe Modified Rodrigues Parameters (MRPs)which is a threedimensional independent vectoris put forward for attitude estimation.The attitude estimation algorithm based on Square Root Unscented Kalman Filter (SRUKF) is established with the outputs of accelerometer and magnetometer as observation vectors.In order to avoid the accelerometer and magnetometer interference by environmentan expert system is introduced to the SRUKF algorithm.The expert system is designed to estimate the information of acceleration and magnetic field to adjust the measurement noise matrix.The experiment results indicate that the algorithm successfully makes the static attitude accuracy less than 0.05°and static heading accuracy less than 0.1°.And it makes the dynamic attitude accuracy less than 0.5°and dynamic heading accuracy less than 1°.The optimization effect is improved significantly.