Measuring distance is critical for safety and quality in construction and operation of engineering structures. This paper proposes a framework to utilize cost-effective and robust ultra-wideband radio technology for wireless sensing of distance, presents a machine learning method based on extreme gradient boosting decision tree, and incorporates error mitigation methods to improve the measurement accuracy. In-situ measurement of distance for a highway bridge in operation was conducted to evaluate the performance of the proposed methods which demonstrated a sub-millimeter accuracy of distance measurement. The proposed methods show desired accuracy, cost-effectiveness, and robustness to the environment, and reveal a tradeoff between the accuracy and frequency of distance measurement. The tradeoff can be used to optimize the sensing system and signal processing program to satisfy the requirements in different applications. This study is expected to advance the capability of measuring distance in various automation processes for construction and operation of engineering structures.