With the advancement of autonomous driving technology, trajectory planning has emerged as one of the core technologies to achieve safe and efficient vehicle driving. An algorithm for single-vehicle trajectory planning based on the Optimal Control Problem (OCP) is proposed in this paper, which can not only plan a safe and efficient path for autonomous vehicles, but also realize the obstacle avoidance function. Firstly, the OCP is modeled for the cycle trajectory planning problem. Secondly, this paper transforms it into a Nonlinear Programming (NLP) with all discrete methods, and uses the interior point method to solve it. Then, the Y-type intersection is selected as the verification scene, and through a series of simulation experiments, the efficiency and safety of the algorithm in different driving environments are verified. The model and algorithm proposed in this paper are not only applicable to Y-type intersections, but also can be extended to other complex traffic roads, providing a new idea and method for trajectory planning in intelligent transportation systems.