As an important research direction of mobile robots, SLAM is the core technology to realize intelligent autonomous mobile robots. For positioning, the robot needs a consistent map, for obtaining a map, the robot makes a good estimate of its position. This interdependence between positioning and mapping makes the SLAM problem difficult and necessary. This article first summarizes the representation method of the environment map, uses the ROS mobile robot to map the indoor environment, compares the mapping effect of the Gmapping algorithm and the Cartographer algorithm, analyzes the results of the mapping, and proposes the optimal mapping plan. Aiming at the problem of simultaneous localization and mapping of robots, a ROS-based solution is proposed. Compare Dijkstra, A * algorithm and Dynamic Window Approach, and choose the best navigation algorithm.