{"author":{"@type":"Person","name":"Alexander Bock","url":"https://abxk.ai/en/autor/alexander-bock/"},"categories":["Physical AI"],"content":{"markdown":"A robot that enters a new building knows nothing about it. Before it can plan a route to the loading dock or the kitchen, it has to find out where the walls, shelves and doors are. It builds this knowledge from what its sensors see, scan by scan, into a map. The most common kind of map for this is the **occupancy grid**: the floor is divided into small squares, and for each square the robot estimates whether it is free, occupied or still unknown.\n\nThis is part 1 of Level 2 in our learning path Physical AI, which looks at how the systems work inside. We simulated a robot with a lidar sensor driving through a made-up warehouse with four rooms, shelves and doors. You will learn what a lidar scan contains, how a grid map collects evidence from many scans and why the best map is worthless if the robot is wrong about its own position.\n\n## What a lidar sees\n\nA 2D lidar is a laser that spins and measures the distance to the nearest object in many directions. Our simulated sensor sends 360 beams per turn, one per degree, with a range of 10 meters and a measurement noise of about 2 centimeters, typical values for the lidars on delivery and warehouse robots. Every beam tells the robot two things at once: the space along the beam up to the measured distance is free, and the point where the beam stopped is occupied. A beam that hits nothing within its range only says that the space along it is free.\n\n![Three maps of the same floor plan in gray, white and black: after one scan, only a star-shaped patch around the robot is known; after ten scans, the first room is mapped; after all scans, the whole building with its walls, shelves and doors is visible](/images/learn/en/how-robots-build-maps-growth.webp \"The map after 1, 10 and all scans. White is free, black is occupied, gray is still unknown.\")\n\n## Evidence instead of yes or no\n\nThe robot does not simply mark a square as free or occupied after one reading. Sensors make mistakes, people walk through the beam, and glass can reflect a laser in strange directions. Instead, every square keeps a running score, called **log-odds**. Each time a beam passes through the square, the score goes down a little; each time a beam ends in it, the score goes up. Only when enough evidence has collected does the square count as free or occupied. A single wrong reading changes the score, but it cannot overturn many good ones.\n\n| State of a square | What it means | Typical cause |\n|---|---|---|\n| Unknown | No beam has reached it yet | Behind a wall, around a corner, out of range |\n| Free | Many beams passed through it | Open floor, hallways, doorways |\n| Occupied | Many beams ended in it | Walls, shelves, pillars |\n| Unsure | Evidence points both ways | Moving people, glass, edges of objects |\n\n## Our simulation: the map grows with every scan\n\nOur robot drove {{\u003c num \"physical_sims\" \"map_path_m\" \u003e}} meters through the building and took a scan every half meter, {{\u003c num \"physical_sims\" \"map_scans\" \u003e}} scans in total. After ten scans, it had explored {{\u003c num \"physical_sims\" \"map_explored_10_pct\" \u003e}}% of the free floor area, mostly the first room. By the end, it had explored {{\u003c num \"physical_sims\" \"map_explored_pct\" \u003e}}%. The remaining patches lie behind shelves and in corners that no beam could reach from the robot's route. Because the robot in this run knew its exact position, the walls in the map sit where they belong: {{\u003c num \"physical_sims\" \"map_precision_pct\" \u003e}}% of the squares marked as occupied lie on or right next to a real wall.\n\n{{\u003c data \"map-quality\" \u003e}}\n\nThe first scans add the most, and the curve then flattens. Every new room brings a jump, every turn into a known corridor adds little. This is why mapping robots plan their routes to visit places they have not seen yet, a strategy called **exploration**.\n\n## Why the position must be right\n\nThe map is only as good as the robot's knowledge of where it stood for each scan. In a second run, we used exactly the same scans, but the robot placed them at the position it estimated from its wheels and gyroscope. As in our simulation of localization in Level 1, this estimate drifts slowly: here by 0.1 degrees of heading per meter and 2% in distance.\n\n![Two maps of the same building side by side: on the left, sharp walls from the run with the exact position; on the right, the run with a drifting position, where walls appear twice, slightly rotated and shifted, and the map gets blurrier toward the end of the route](/images/learn/en/how-robots-build-maps-drift.webp \"The same scans, placed at the exact position (left) and at a slowly drifting position (right).\")\n\nThe result is a map in which walls appear twice, slightly rotated and shifted. Only {{\u003c num \"physical_sims\" \"map_drift_precision_pct\" \u003e}}% of the occupied squares still lie at a real wall; {{\u003c num \"physical_sims\" \"map_drift_ghost_pct\" \u003e}}% are ghost walls that do not exist. A robot planning with this map would see closed doors where there are openings and open space where there is a shelf.\n\nThis is why mapping and localization are solved together. The method is called **SLAM**, simultaneous localization and mapping. While the robot builds the map, it also compares each new scan with the map so far and corrects its position when the two do not fit. When it returns to a place it has seen before, it can correct the drift of the whole loop at once, which is called **loop closure**.\n\n## What changes in the real world\n\nOur simulation shows the core of the method, but real buildings are harder:\n\n- **Glass and mirrors.** Lasers pass through glass doors or bounce off mirrors, so the map can show walls in the wrong place or none at all.\n- **Moving things.** People, forklifts and doors change the scene. Robots keep their maps up to date and treat moving objects separately.\n- **Three dimensions.** A 2D lidar at one height misses a table top or an overhanging shelf. Many robots therefore combine it with 3D lidar or depth cameras.\n- **Size and memory.** A warehouse of several hectares at 10 centimeters per square needs millions of squares, so large maps are split into tiles and loaded as needed.\n\n## How we ran the simulation\n\nWe drew a floor plan of 24 by 14 meters with four rooms, five shelves and doors, divided it into squares of 10 centimeters and computed the lidar beams against the walls in Python with numpy, with a fixed random seed for the noise. Explored means the share of the free floor area that the map marks as free; on target means the share of occupied squares that lie at most one square from a real wall. The next part of this level uses a map to plan: how a robot or a car finds the shortest route through a real street network.","text":"A robot that enters a new building knows nothing about it. Before it can plan a route to the loading dock or the kitchen, it has to find out where the walls, shelves and doors are. It builds this knowledge from what its sensors see, scan by scan, into a map. The most common kind of map for this is the occupancy grid: the floor is divided into small squares, and for each square the robot estimates whether it is free, occupied or still unknown.\nThis is part 1 of Level 2 in our learning path Physical AI, which looks at how the systems work inside. We simulated a robot with a lidar sensor driving through a made-up warehouse with four rooms, shelves and doors. You will learn what a lidar scan contains, how a grid map collects evidence from many scans and why the best map is worthless if the robot is wrong about its own position.\nWhat a lidar sees A 2D lidar is a laser that spins and measures the distance to the nearest object in many directions. Our simulated sensor sends 360 beams per turn, one per degree, with a range of 10 meters and a measurement noise of about 2 centimeters, typical values for the lidars on delivery and warehouse robots. Every beam tells the robot two things at once: the space along the beam up to the measured distance is free, and the point where the beam stopped is occupied. A beam that hits nothing within its range only says that the space along it is free.\nThe map after 1, 10 and all scans. White is free, black is occupied, gray is still unknown. Evidence instead of yes or no The robot does not simply mark a square as free or occupied after one reading. Sensors make mistakes, people walk through the beam, and glass can reflect a laser in strange directions. Instead, every square keeps a running score, called log-odds. Each time a beam passes through the square, the score goes down a little; each time a beam ends in it, the score goes up. Only when enough evidence has collected does the square count as free or occupied. A single wrong reading changes the score, but it cannot overturn many good ones.\nHow Robots Build a Map: Lidar Scans and Occupancy Grids State of a square What it means Typical cause Unknown No beam has reached it yet Behind a wall, around a corner, out of range Free Many beams passed through it Open floor, hallways, doorways Occupied Many beams ended in it Walls, shelves, pillars Unsure Evidence points both ways Moving people, glass, edges of objects Our simulation: the map grows with every scan Our robot drove 55.6 meters through the building and took a scan every half meter, 119 scans in total. After ten scans, it had explored 42.4% of the free floor area, mostly the first room. By the end, it had explored 94.3%. The remaining patches lie behind shelves and in corners that no beam could reach from the robot\u0026rsquo;s route. Because the robot in this run knew its exact position, the walls in the map sit where they belong: 100% of the squares marked as occupied lie on or right next to a real wall.\nHow the map grows with every scan ScansArea exploredWalls on target 535.2%100.0% 1042.4%100.0% 2062.2%100.0% 4070.3%100.0% 8089.0%100.0% 11994.3%100.0% 119, drifting position93.8%55.9% Source as for the first table on this page.\nThe first scans add the most, and the curve then flattens. Every new room brings a jump, every turn into a known corridor adds little. This is why mapping robots plan their routes to visit places they have not seen yet, a strategy called exploration.\nWhy the position must be right The map is only as good as the robot\u0026rsquo;s knowledge of where it stood for each scan. In a second run, we used exactly the same scans, but the robot placed them at the position it estimated from its wheels and gyroscope. As in our simulation of localization in Level 1, this estimate drifts slowly: here by 0.1 degrees of heading per meter and 2% in distance.\nThe same scans, placed at the exact position (left) and at a slowly drifting position (right). The result is a map in which walls appear twice, slightly rotated and shifted. Only 55.9% of the occupied squares still lie at a real wall; 44.1% are ghost walls that do not exist. A robot planning with this map would see closed doors where there are openings and open space where there is a shelf.\nThis is why mapping and localization are solved together. The method is called SLAM, simultaneous localization and mapping. While the robot builds the map, it also compares each new scan with the map so far and corrects its position when the two do not fit. When it returns to a place it has seen before, it can correct the drift of the whole loop at once, which is called loop closure.\nWhat changes in the real world Our simulation shows the core of the method, but real buildings are harder:\nGlass and mirrors. Lasers pass through glass doors or bounce off mirrors, so the map can show walls in the wrong place or none at all. Moving things. People, forklifts and doors change the scene. Robots keep their maps up to date and treat moving objects separately. Three dimensions. A 2D lidar at one height misses a table top or an overhanging shelf. Many robots therefore combine it with 3D lidar or depth cameras. Size and memory. A warehouse of several hectares at 10 centimeters per square needs millions of squares, so large maps are split into tiles and loaded as needed. How we ran the simulation We drew a floor plan of 24 by 14 meters with four rooms, five shelves and doors, divided it into squares of 10 centimeters and computed the lidar beams against the walls in Python with numpy, with a fixed random seed for the noise. Explored means the share of the free floor area that the map marks as free; on target means the share of occupied squares that lie at most one square from a real wall. The next part of this level uses a map to plan: how a robot or a car finds the shortest route through a real street network.\n","words":1068},"date":"2026-10-18","description":"How a robot turns lidar scans into a map of free space and walls, shown in our simulation, and why the map falls apart as soon as the robot's position drifts.","image":"https://abxk.ai/images/cover/how-robots-build-maps.webp","json":"https://abxk.ai/en/physical-ai/learn/how-robots-build-maps/index.json","kind":"page","language":"en","learning_path":{"category":"physical-ai","level":2,"level_name":"Intermediate"},"modified":"2026-10-18","section":"physical-ai","seo_title":"How Robots Build Maps: Lidar and Occupancy Grids","tags":["mapping","lidar","occupancy-grid","slam","robotics"],"title":"How Robots Build a Map: Lidar Scans and Occupancy Grids","translations":[{"json":"https://abxk.ai/de/physical-ai/learn/how-robots-build-maps/index.json","language":"de","url":"https://abxk.ai/de/physical-ai/learn/how-robots-build-maps/"}],"url":"https://abxk.ai/en/physical-ai/learn/how-robots-build-maps/"}