Inverse kinematics of robot is the basis of robot assembly, which directly determines the pose of robot. Because the traditional inverse solution algorithm is limited by the robot topology structure, singular pose and inverse solution accuracy, it affects the use of robots. In order to solve the above problems, an improved particle swarm optimization (PSO) algorithm is proposed to solve the inverse problem of robot. This algorithm initializes the particle population based on joint angle limitations, accelerating the convergence speed of the algorithm. In order to avoid falling into local optima and premature convergence, we have proposed a nonlinear weight strategy to update the speed and position of particles, enhancing the algorithm’s search ability, in addition introducing a penalty function to eliminate particles exceeding joint limits. Finally, the positions of common points and singular points are selected on PUMA 560 robot and redundant robot for inverse kinematics simulation verification. The results show that, compared with other algorithms, the improved PSO algorithm has higher convergence accuracy and better convergence speed in solving the inverse solution, and the algorithm has certain universality, which provides a new solution for the inverse kinematics solution of the assembly robot.