Abstract:To solve the problem of low output accuracy of MEMS gyro in MWD, an online gyro error compensation method based on magnetic-gravity ephemera algorithm (MGMA) is proposed. Firstly, the error source of GYRO while drilling is analyzed and the error compensation model is derived. Secondly, the objective function of MEMS accelerometer is obtained by using the cross product of gravity vector. In addition, considering the adverse effects of strong vibration and impact on the accelerometer during drilling, the relative error constraint of the magnetic mode value is designed based on the strong anti-vibration ability of MEMS magnetometer. Then, on the basis of MA, the search upper and lower bounds are determined adaptively according to the relationship between the gyro and the magnetometer output, aiming at the constant change of gyro error parameters under the influence of harsh environment while drilling. The relative error of gravity mode value is used to design the inertia weight and balance the global exploration and local development ability of the algorithm. Finally, according to the relative error of the magnetic-gravity mode value, the variation perturbation strategy is introduced in the children to reduce the possibility of falling into the local optimal. The experimental results show that the gyro error after MGMA compensation is obviously reduced, and the well inclination error is reduced from 9.75° to 1.52°, and compared with PSO and MA algorithm, it has the advantages of fast speed and high precision.