In this study, we establish the monocular vision system of the grinding path, complete the calibration experiment, automatically extract the grinding path type value points of the engine piston skirt, use the edge detection operator to detect the contour of the grinding path, and use Harris corner point detection to obtain the pixel coordinates of the grinding path type value points, in this study, the robot trajectory planning method and its evaluation criteria are proposed, the trajectory planning under joint space is carried out for the data points, and simulation experiments are conducted, the time-optimal trajectory optimization model is established, the kinematic constraints are imposed on each joint, and the time-optimal trajectory optimization of the grinding trajectory is carried out based on five-order B-spline trajectory planning with the improved particle swarm algorithm, and the optimal trajectory is obtained, and the robot running time is reduced by The optimal trajectory is obtained, and the robot running time is reduced by 3.186 s, which verifies the effectiveness of the new algorithm for grinding path time optimization.