A robust measuring technique for the wavefront is one of the key parts for a stable adaptive optics system in the practical fields. Also, the measurement resolution of the wavefront is important for improving the performance of an adaptive optics system. In this paper, we propose a robust measuring technique for the wavefront using a Shack-Hartmann wavefront sensor for an adaptive optics system. The proposed measuring technique for the wavefront uses an iterative center of mass algorithm with the hierarchical sizes of a searching window and the hierarchical threshold values. The measurement accuracy and stability are investigated using the proposed hierarchical algorithm and compared with the conventional algorithm of the wavefront in the experiments. Also, we describe the hardware configuration of the adatptive optics system operating in our laboratory.