The main purpose of this paper is design and implementation of a new linear observer for an attitude and heading reference system (AHRS), which includes three-axis accelerometers, gyroscopes, and magnetometers in the presence of sensors and modeling uncertainties. Since the increase of errors over time is the main difficulty of low-cost micro electro mechanical systems (MEMS) sensors producing instable on-off bias, scale factor (SF), nonlinearity and random walk errors, development of a high-precision observer to improve the accuracy of MEMS-based navigation systems is considered. First, the duality between controller and estimator in a linear system is presented as the base of design method. Next, Legendre polynomials together with block-pulse functions are applied for the solution of a common linear time-varying control problem. Through the duality theory, the obtained control solution results in the block-pulse functions and Legendre polynomials observer (BPLPO). According to product properties of the hybrid functions in addition to the operational matrices of integration, the optimal control problem is simplified to some algebraic equations which particularly fit with low-cost implementations. The improved performance of the MEMS AHRS owing to implementation of BPLPO has been assessed through vehicle field tests in urban area compared with the extended Kalman filter (EKF). Copyright © 2021 ISA. Published by Elsevier Ltd. All rights reserved.