Based on a heuristic optimization algorithm, this paper proposes a new algorithm named trajectory-planning beetle swarm optimization (TPBSO) algorithm for solving trajectory planning of robots, especially robot manipulators. Firstly, two specific manipulator trajectory planning problems are presented as the practical application of the algorithm, which are point-to-point planning and fixed-geometric-path planning. Then, in order to verify the effectiveness of the algorithm, this paper develops a control model and conducts numerical experiments on two planning tasks. Moreover, it compares with existing algorithms to show the superiority of our proposed algorithm. Finally, the results of numerical comparisons show that algorithm has a relatively faster computational speed and better control performance without increasing computational complexity.