The dynamics of unmanned aerial systems (UAS) are often nonlinear, especially at high speed and high maneuverability flight. The inherent nonlinearity of the system renders conventional linear control techniques inadequate for achieving optimal control outcomes. Consequently, unmanned aerial vehicle (UAV) trajectory planning is fundamentally a nonlinear optimal control challenge, characterized by the difficulty of swiftly obtaining a stable solution and the propensity to converge on suboptimal local solutions during the solving process. In response to this, a method for autonomous UAV obstacle avoidance trajectory planning is introduced, leveraging a convex optimization-based particle swarm algorithm. The UAV uses sensors to record the information about obstacles, adopts a one-dimensional time-parameterized polynomial trajectory to construct the obstacle avoidance control input, combines the safety penalty function between the navigation path and obstacles to generate the obstacle avoidance trajectory planning objective function, and obtains the path points in the obstacle avoidance trajectory; the particle swarm algorithm is used to solve the objective function, the parameters such as obstacle avoidance control input and safety penalty function are used as particles, and the optimal parameter values are obtained through the iterative updating process of position and speed. Aiming at the acquired obstacle avoidance trajectory path points, the convex optimization algorithm is used to construct a non-convex optimal control model that meets the requirements of energy optimization, and is rooted in the concave-convex process, so that the control model’s objective function and inequality constraint are both convex, while the formula constraint is affine. By transforming the control model into a convex optimization problem, it aligns with the energy optimization requirements. The sequential convex optimization framework is employed to solve this problem, enabling the optimization of the UAV’s trajectory for obstacle avoidance. Experimental outcomes demonstrate that this approach effectively captures the coordinate details of obstacles, navigates through various dense obstacle scenarios, and simultaneously guarantees an energy-efficient path to the target destination.