Bench Notes
Put a new robot vacuum down in a living room, press start, and it faces a problem that sounds like a riddle. To build a map of the room, it needs to know where it is. To know where it is, it needs a map. It has neither. Twenty minutes later the app shows a tidy floor plan, with the sofa, the coffee table and the hallway door in the right places.
The trick is called SLAM, short for simultaneous localisation and mapping. The robot builds the map and works out its own position on it at the same time, and each guess improves the other. Here’s what happens on that first lap, and where it goes wrong.
The spinning turret
Most robot vacuums that make proper maps carry a small LiDAR turret on top. Inside, a laser and a receiver spin together and measure the distance to whatever the beam hits, all the way round. Slamtec’s RPLIDAR C1, a 2D LiDAR the company lists for robot vacuums, is a good example. It turns ten times a second and takes 5,000 samples a second, so about 500 points per turn, one every 0.72°. It reaches 12 m on a white wall but only 6 m on a black one.
One turn gives the robot a slice through the room at turret height: a ring of dots along the walls, the front of the sofa, the legs of the coffee table. A point every 0.72° sounds plenty until you do the sums. At 1.5 m, neighbouring points are about 2 cm apart, and at 3 m almost 4 cm, so a chair leg on the far side of the room can fall between them.
The robot is also moving while the turret spins. At 0.3 m/s, with the turret turning ten times a second, it covers 3 cm during a single turn. The software has to correct each scan for that motion before using it, or straight walls come out slightly bent.
Wheels, a gyro and drift
Between scans, the robot keeps track of itself the way a sailor without GPS does: dead reckoning. Encoders count how far each wheel has turned, and an IMU measures how fast the robot is rotating. A typical choice is a 6-axis part such as ST’s LSM6DSV16X: a 3-axis accelerometer and a 3-axis gyroscope in a 2.5 × 3.0 mm package, with sensor fusion built in. Add up those small movements and you have an estimate of where the robot is.
That estimate is good for a few seconds and gets worse from then on, because every small error stays in the sum. A wheel that slips on the edge of a rug reports distance the robot never travelled. A gyro with a slight bias turns a straight run into a gentle curve. Heading errors are the expensive ones: just 1° of heading error puts the robot about 9 cm off to one side after 5 m of driving, and the error keeps growing.
This is where the scans earn their keep. Each new scan is lined up against the map built so far, a step called scan matching, and the best fit corrects the position the wheels reported. Most of the time that keeps the drift small. Over a long lap, though, small corrections still add up, and the far end of the room can end up a few centimetres from where it should be.

The sofa, second time round
The real fix comes when the robot returns somewhere it has already been. Picture it finishing a lap of the living room and arriving back at the sofa it scanned at the start. By its own reckoning, the sofa is now slightly to the left of where it first saw it. The scan disagrees: the shape of the sofa and the corner behind it match the earlier scan almost exactly.
That match is a loop closure, and it’s the most important moment of the run. Graph-based SLAM, the approach used by slam_toolbox in ROS 2 and by many other systems, keeps the robot’s path as a chain of poses. Each pose is a spot where a scan was taken, linked to the next by what the wheels and scan matching said about the step between them. A loop closure adds one more link, which says “this pose and that earlier one are the same place”. An optimiser then spreads the accumulated error back along the whole loop instead of dumping it on the last step, and walls that had started to double up snap back into single lines.
Getting a loop closure wrong is worse than missing one. Two corners that look alike can fool a careless matcher into joining the wrong places, and the map folds over itself. Good systems want a strong match before they accept one.

From dots to rooms
The finished map is usually an occupancy grid: the floor divided into small squares, each marked free, occupied or unknown. Squares of 5 cm are a common choice, and it’s the size Nav2’s example configurations use. The app then splits the grid into rooms, typically at narrow gaps such as doorways, and gives each one a name you can change.
From there the owner takes over. A no-go zone drawn round the dog’s bowl becomes a patch of grid that the planner treats as a wall. Many vacuums can also keep a separate map for each floor of a house and recognise which floor they’ve been carried to. Cleaning routes are planned on the grid, usually as neat back-and-forth lanes, room by room.
What trips it up
Mirrors are the classic case. A floor-length mirror reflects the laser, so the robot sees what looks like open space and maps a room that doesn’t exist on the other side of the wall. Lab tests on LiDAR robots show the same effect, with objects appearing behind the mirror’s surface. Dreame’s advice to owners is to cover the bottom of the mirror, at turret height, with frosted film.
Thick rugs are the other common culprit, and they trouble the wheels rather than the laser. The wheels sink and slip, the odometry over-reports, and if the robot gets stuck and struggles free, its sense of where it is can shift. Scan matching usually pulls it back. A rug in a plain room with few distinctive shapes gives the matcher little to grip, though, and that’s where maps start to warp.
For engineers, both cases teach the same thing: no single sensor gets the final word. Firmware that checks the wheels against the gyro, and the scan against both, copes with a real living room far better than any one sensor on its own.

If you’re building one

A robot like this usually splits its work between two processors, and that split matters more than any single algorithm.
The real-time side runs on a microcontroller, often under an RTOS. It closes the motor control loops, reads the wheel encoders and the IMU, and watches the bumpers and the downward-facing cliff sensors. It has to keep doing that whatever else happens: if the Linux side hangs, the robot must still stop at the top of the stairs.
The heavier work runs on an embedded Linux processor: the LiDAR driver, SLAM, route planning, Wi-Fi and the link to the app. For prototyping in ROS 2, slam_toolbox and Nav2 give you graph-based SLAM and a full navigation stack to start from. A near-field sensor such as the VL53L9, which we looked at in our last Bench Notes post, can sit alongside the LiDAR as an extra obstacle layer for things below turret height.
We’ve worked on the embedded Linux processors that systems like this run on, so the split between the real-time side and the Linux side is the part we know best. Our embedded Linux work and robotics work with ROS 2 go into more detail.
Next time a robot vacuum slips round a coffee table without touching it, remember it’s running a small version of what warehouse and delivery robots do all day. If you’re designing a machine that has to find its own way, talk to an engineer →
Sources: Dreame, LiDAR navigation in robot vacuums and why your robot vacuum’s map broke; Slamtec, RPLIDAR C1 specifications; STMicroelectronics, LSM6DSV16X product page; Damodaran et al., Experimental analysis of the behavior of mirror-like objects in LiDAR-based robot navigation, Applied Sciences, 2023; Nav2, Mapping and localization.
