In this tutorial, you’ll learn how to use Google’s Cartographer with ROS2 to perform advanced 2D SLAM (Simultaneous Localization and Mapping). Cartographer is a real-time SLAM algorithm that provides loop closure and accurate map construction in dynamic environments. We’ll use a simulated TurtleBot3, but the steps are adaptable to real robots.
Start the robot simulation and the Cartographer SLAM launch file. Example with TurtleBot3:
ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=true
Use keyboard teleoperation or predefined waypoints to guide the robot around the map:
ros2 run turtlebot3_teleop teleop_keyboard
Once the robot has explored enough, save the generated map using map_server:
ros2 run nav2_map_server map_saver_cli -f ~/cartographer_map
– Errori TF:
verificare che esistano i frame corretti (` base_link` , ` odom` , `laser`, ecc.) – i dati LIDAR non vengono visualizzati:
assicurati che `/scan` stia pubblicando e che il sensore funzioni – La mappa si sta spostando o è deformata:
controlla la messa a punto del modello di movimento nei parametri di Cartographer – Il file di avvio si blocca:
assicurati che Cartographer sia correttamente costruito e reperito nel tuo spazio di lavoro