The trajectory tracking control of underwater vehicle in three-dimensional space is studied. Firstly, given a series of reference trajectory points in smooth and inertial three-dimensional space, the target state and current state of the underwater vehicle are obtained by establishing the kinematics model and dynamics model of the underwater vehicle, and the speed and force of the underwater vehicle are determined according to a certain reference direction. Using these, the dynamic error is obtained by using PID algorithm. The UUV simulator is simulated with ROS robot operating system, and the simulation results of circular trajectory are given. At the same time, the robustness of the parameters is considered, and the results show that the experiment is effective.