Aiming at the problems of dung beetle algorithm in trajectory planning, such as easy to fall into local optimum, long flight distance and high energy consumption, this paper proposes an improved dung beetle algorithm for trajectory planning of quadrotor UAV. The algorithm introduces chaotic mapping, changes the probability distribution of the initialised population, and further proposes to introduce Lé vy flights at the greedy dung beetle update position to improve the convergence speed of the algorithm. Finally, by comparing the Keplerian optimisation algorithm, the lemur optimisation algorithm, the dung beetle algorithm and the improved dung beetle algorithm for trajectory planning in two environments, the experimental results show that the algorithm proposed in this paper has the advantages of faster convergence speed, shorter flight distance, and is not easy to fall into the local optimum.