This paper mainly studies an autonomous path-planning and real-time path-tracking optimization method for snake robot. Snake robots can perform search and rescue, exploration, and other tasks in a variety of complex environments. Robots with visual sensors such as LiDAR can avoid obstacles in the environment through autonomous navigation to reach the target point. However, in an unstructured environment, the navigation of snake robot is easily affected by the external environment, causing the robot to deviate from the planned path. In order to solve the problem that snake robots are easily affected by environmental factors in unstructured environments, resulting in poor path-following ability, this paper uses the Los algorithm combined with steering control to plan the robot in real time and control the robot’s steering parameters in real time, ensuring that the robot can stably follow the planned path.