In recent years, with the widespread application of indoor inspection robots, efficient motion planning has become crucial. Addressing the issue of discontinuous and suboptimal robot trajectories resulting from the independent nature of global and local planning, we propose a novel optimal path-planning method for wheeled mobile robots. This method leverages differential flatness to reduce dimensionality and decouple the problem, achieving globally optimal, collision-free paths in a two-dimensional flat output space through diagonal search and polynomial trajectory optimization. Comparative experiments in a simulated environment demonstrate that the proposed improved path search algorithm reduces search time by 46.6% and decreases the number of visited nodes by 43.1% compared to the original algorithm. This method not only ensures the optimal path and efficient planning but also ensures that the robot’s motion trajectory satisfies the dynamic constraints, verifying the effectiveness of the proposed optimal path planning algorithm for wheeled mobile robots.