← All articles

15 November 2026

How Robots Map a Room: How a Robot Knows Where It Is

Illustration of a self-driving robot scanning a room with a laser to build a map

Switch on a robot vacuum and watch it work. An old one wanders randomly: it bumps into a table leg, turns, bumps into a wall, turns. A modern one is different: it drives in neat rows like someone ploughing a field, misses no spot, and returns to its charger by itself when it is done.

The difference is not in the wheels or the brush. It is in a capability that sounds impossible at first: the robot draws a map of the room while knowing where it stands on that map — even though it has never seen this room before. That capability is called SLAM, short for Simultaneous Localization and Mapping: locating and mapping at the same time.

Understanding SLAM means understanding one of the most beautiful ideas in robotics. And the best part: you can let your child try it at home, with no robot at all.

The robot's chicken-and-egg problem

Imagine you are blindfolded, dropped into a strange house, and asked to draw a floor plan of it. You have to walk and draw at the same time, but to draw correctly you need to know where you are. And to know where you are, you need the map. Drawing the map needs position; knowing position needs the map — a circle with no beginning.

The robot faces exactly this problem. It rolls into a room it has never seen. It has no map. It does not know where it is. Yet after one lap, it has both: a map, and its own position on it.

SLAM solves this with a simple loop, repeated hundreds of times per second: predict — observe — correct. The robot predicts how far it has moved, uses its sensors to observe the surroundings, then compares the observation against the map-in-progress to correct both its position and the map. With every loop, both get a little more accurate.

The robot counts its steps with its wheels

The first step of SLAM is prediction: how far has the robot moved, and how much has it turned? The answer comes from its own wheels.

On each wheel sits a sensor called an encoder. Picture a small disc with many tiny slots, attached to the wheel axle, spinning with the wheel. A light sensor counts the slots passing by: each slot is one small step of rotation. Multiply the number of steps by the wheel's circumference, and the robot knows how far it has travelled. Count each wheel separately, and the robot also knows how much it has turned: if the left wheel spins more than the right one, the robot is turning right.

This technique is called odometry — measuring distance with wheels. It is like counting your own steps in the dark: each step is about half a metre, so 20 steps means about 10 metres.

But step-counting has a problem: errors add up. A wheel slips on a smooth floor, thick carpet makes a wheel sink, the robot gets lightly stuck on a table leg while its wheels keep spinning. Each small error piles onto the last, and after a few minutes the robot thinks it is here when it is really over there. Odometry alone is never accurate enough. The robot needs something else: observing the outside world.

Laser eyes and camera eyes: two ways of seeing a room

To observe its surroundings, the robot uses one of two kinds of "eyes": a laser or a camera.

A laser robot has a small spinning turret on top. Inside it, a diode fires infrared laser pulses — thousands per second — in every direction. Each pulse flies out, hits a wall or a table leg, and bounces back. The robot measures the travel time of the pulse and works out the distance to the obstacle. One full 360-degree sweep gives it a "distance picture" of the whole room. This technology is called LiDAR, and it works fine even in total darkness because the laser brings its own light.

A camera robot works differently: it takes pictures continuously and tracks distinctive points in the images — a door corner, the edge of a cupboard, a table leg — watching how they shift between frames. From that shift, the robot works out how it has moved. This is called visual SLAM, or vSLAM. It is cheaper than laser, but it needs enough light and can get "lost" in an empty room with no distinctive features.

Whichever eye it uses, the result is the same: the robot collects distance measurements to fixed objects around it, and uses them as landmarks to correct its position.

The robot's map is not a photograph

When your child looks at the robot vacuum's app, they see a neat floor plan: walls, doors, rooms in boxes. But inside the robot, the map is not a picture — it is a grid of squares.

Imagine the room divided into thousands of tiny squares, like graph paper. Each square is marked with one of three states: free (the robot has passed through and there is nothing there), occupied (a wall, furniture), or unknown (the robot has not scanned there yet). As the robot moves and sweeps its laser, it colours in the squares: squares the laser passes through are free, squares the laser hits are occupied.

This grid is called an occupancy grid. It is simple enough for the small computer inside a robot to handle, yet enough for the robot to plan: which row to drive first, which squares to avoid, and which route back to the charger is shortest.

This is a big lesson for children learning robotics: computers do not "see" the world the way people do. They turn the world into numbers — a grid of squares, one number per square — and then calculate on those numbers. The pretty map in the app is just the number grid redrawn so humans can read it.

When the robot realizes "I have been here before"

There is one important moment in SLAM called loop closure — closing the loop. The robot drives around a kitchen island, comes back to where it started, and recognizes the landmarks around it as identical to the ones it recorded at the beginning. It understands: I have driven in a circle and returned to my starting point.

Why does this moment matter? Because throughout the trip, odometry errors have been piling up: the robot thought it drove straight, but it actually drifted slightly left every metre. When the loop closes, the robot discovers that its whole path is skewed, and it corrects both the map and its position — like drawing a circle whose two ends do not meet, then adjusting the whole line until they join.

Without loop closure, a robot's map would warp like a shaky hand drawing. With loop closure, the map corrects itself. That is why modern robots get more accurate the longer they run, instead of getting more lost.

Try SLAM at home, with no robot

You can let your child experience the SLAM problem with a simple game: blindfold your child, walk them into a room in your house, and ask them to draw a floor plan using only walking and touching.

Your child will do exactly what a robot does: count steps (odometry), touch walls to judge distance (sensors), remember a table corner as a landmark (feature points), and when they return to the starting spot, fix the drawing (loop closure). Ask them: "How sure are you about where you are standing? How do you know?" — that is the central question of SLAM.

Another game: have your child draw the living room from memory, then measure it with a tape measure and compare. Where was the drawing most wrong? Usually the long stretches with no landmarks — exactly like a robot: with no reference points, errors pile up fastest.

From robot vacuums to self-driving cars

SLAM lives in more than robot vacuums. Self-driving cars use SLAM to know which lane they are in. Warehouse delivery robots use SLAM to find shelves. Mars rovers use SLAM to map another planet — where there is no GPS and no pre-existing map at all.

For a child learning robotics, this is an inspiring idea: a robot does not "know everything" in advance. It learns by moving, observing, and correcting mistakes — just like a person learning a new place. The only difference is that the robot does it with numbers, faster, and never forgets a single square on its grid.

Start today, no kit needed

Your child can try programming a robot that avoids obstacles and "remembers the way" today on ManuStem — a browser-based robotics platform, no kit required, for ages 8+, with 28 lessons including 8 Component Lab lessons and 20 Competition Robot lessons, 4 of them free to try. The built-in AI co-pilot helps your child wire circuits, write code, and debug step by step, and the 3D robot preview shows their creation before it runs. Start at stem.manusignal.com — in Vietnamese or English, whichever your child prefers.

Read the Vietnamese version:

Robot tự hành lập bản đồ: robot biết mình đang ở đâu bằng cách nào