Gmapping uses a particle filter to match current laser scans with past scans, allowing it to detect loop closures and correct the map accordingly.
The standard way to launch Cartographer with a LiDAR sensor is using the demo_lidar.launch file provided in the cartographer_ros package.
The /map topic publishes the occupancy grid map generated by gmapping.
Cartographer fuses odometry with LiDAR data to estimate the robot's pose. Without odometry, pose estimation drifts, causing mapping failure.
Cartographer uses pose graph optimization and loop closure detection, which helps maintain global consistency in large, complex maps, making it better suited for large-scale environments.
