The existing trajectory planning research mainly considers the safety of the obstacle avoidance process rather than the anti-rollover requirements of heavy vehicles. When there are driving risks such as rollover and collision, how to coordinate the game relationship between the two is the key technical problem to realizing the anti-rollover trajectory planning under the condition of driving risk triggering. Given the above problems, this paper studies the non-cooperative game model construction method of the obstacle avoidance process that integrates the vehicle driving risk in a complex traffic environment. Then it obtains the obstacle avoidance area that satisfies both the collision and rollover profit requirements based on the Nash equilibrium. A Kmeans-SMOTE risk clustering fusion is proposed in this paper, in which more sampling points are supplemented by the SMOTE oversampling method, and then the ideal obstacle avoidance area is obtained through clustering algorithm fusion to determine the optimal feasible area for obstacle avoidance trajectory planning. On this basis, to solve the convergence problems of the existing multi-objective particle swarm optimization algorithm and analyze the influence of weight parameters and the diversity of the optimization process, this paper proposes an anti-rollover trajectory planning method based on the improved cosine variable weight factor MOPSO algorithm. The simulation results show that the trajectory obtained based on the method proposed in this paper can effectively improve the anti-rollover performance of the controlled vehicle while avoiding obstacles.