30% off your first 3 months

Get the deal

LiDAR SLAM vs visual SLAM

by DuckyHelperNov 12, 20265 min read
Robotics

TL;DR:

  • SLAM builds a map while working out where the robot is in it. LiDAR SLAM matches distance scans, visual SLAM matches features in camera images.

  • LiDAR measures range directly and works in the dark but struggles in long featureless corridors. Cameras are cheap and rich in detail but need light and texture, and a single camera cannot tell scale.

  • Stereo depth is Z = f × b / d, and depth error grows with the square of distance.

Your robot is in an unknown office with no GPS. It must make a map and know where it is on that map, at the same time. That chicken-and-egg problem is SLAM, short for simultaneous localization and mapping (see the glossary entry on SLAM). Two popular ways to do it use different sensors, and they fail in different places.

How each one works

LiDAR SLAM uses a laser scanner that measures the distance to surrounding surfaces, giving a ring of range readings, a scan. The robot compares each new scan with the previous one or with the map and finds the small movement that lines them up, a process called scan matching. Chaining those movements gives the path, and the aligned scans give the map.

Visual SLAM uses one or more cameras. It finds distinctive points in each image (corners, edges, texture), follows them from frame to frame, and solves for the camera movement that explains how the points shifted. The map is a set of 3D points or a model of the surroundings.

Worked example: mapping an office both ways

A wheeled robot drives a 40 m loop around an office floor. Wheel odometry alone drifts: say it gains an error of 1 cm for every metre travelled. After the 40 m loop, the robot thinks it is 40 × 0.01 = 0.40 m away from where it started, although it has returned to the same spot.

  1. LiDAR run. The scanner gives, say, 360 range readings per scan. Matching successive scans corrects most wheel slip, so the drift is smaller than odometry alone. Walls and furniture give strong geometric structure. When the robot returns, its scan matches the first one, a loop closure, and the software spreads the remaining error back along the path. The map snaps shut.

  2. Visual run. A stereo camera pair with focal length f = 700 px and baseline b = 0.12 m sees a poster on a wall. Its left and right images differ by a disparity of d = 21 px. Depth: Z = f × b / d = 700 × 0.12 / 21 = 4.0 m.

  3. Depth error. If the disparity is off by 1 pixel, d = 20 gives 700 × 0.12 / 20 = 4.2 m, and d = 22 gives about 3.82 m. The error is roughly Z² / (f × b) × Δd = 16 / 84 × 1 ≈ 0.19 m. At twice the distance (8 m) it would be about 64 / 84 ≈ 0.76 m, four times larger.

  4. The camera recognises the same poster when the robot returns, so visual loop closure works too, using appearance. The map has the same loop-closing correction.

Compare the numbers. A typical LiDAR measures range directly with an error that is roughly constant with distance (a few centimeters in this illustration, check your datasheet), while stereo depth error grows with the square of distance. Close up, cameras do well. Far away, LiDAR holds up better. A monocular camera, only one lens, has a further problem: an object twice as big and twice as far looks the same, so the map's scale is unknown unless another sensor, such as an inertial unit, supplies it.

Sensors, strengths, failure cases

Aspect

LiDAR SLAM

Visual SLAM

Strengths

Direct, accurate range. Works in the dark. Maps are easy to use for planning obstacles

Cheap, light and low-power sensors. Rich detail for recognising places. Cameras also serve other tasks

Failure cases

Long plain corridors where every scan looks the same. Glass and mirrors. Heavy dust or fog. Fewer clues about identity of places

Dark rooms and bright glare. Blank white walls with no texture. Motion blur. Repeated patterns that look alike. Scale ambiguity with one camera

Cost and effort

Sensor costs more and can be bulky. Moving parts in spinning units

Needs more computing to process images. Calibration of lenses matters

A general comparison. Specific sensors and software vary.

Many robots fuse both, plus wheel odometry and an inertial unit, so each covers the other's weak spot. For how combining sources works mathematically, see how self-driving cars combine their sensors.

Safety: Never open a LiDAR housing or stare into an emitter, and keep spinning heads clear of fingers and cables. Use the sensor within its documented voltage and mounting guidance.

Where it goes wrong

  • Corridor problem. Scan matching can slide along a featureless corridor without noticing, because every position along it looks identical.

  • Wrong loop closure. Two similar-looking rooms are taken as the same place, and the map folds in on itself.

  • Moving people. Walking people appear in scans and images as part of the map. Systems filter out moving objects.

  • Rolling shutter and blur. Fast turns smear images.

  • Lighting changes. A map made in the morning may not match the view at night.

  • Compute limits. Real-time SLAM on a small computer needs careful settings.

How real robots use it

Warehouse and cleaning robots mostly use LiDAR SLAM or a low-cost camera version. Drones, phones and headsets favour visual and inertial approaches because cameras are light. Joint sensors on the robot itself, covered in absolute and incremental position sensing, feed the odometry that SLAM corrects. The mapping idea underlies the navigation described in how mobile robots navigate a warehouse floor.

Try it yourself

Take two photos of the same room object from two spots 12 cm apart, side by side, as a poor man's stereo pair. Measure how many pixels a corner shifts between them (disparity). Use Z = f × b / d with a focal length in pixels from your phone's camera data, and compare to a tape measure.

Frequently asked questions

Which is better for a first robot?

A small 2D LiDAR with a ready-made SLAM package is often the quickest path to a working map. Visual SLAM is a good second project.

What is a loop closure?

Recognising that the robot has returned to a place it has been before, so the accumulated drift can be corrected across the whole path.

Get started

DuckyHelper can
do more

It sees your screen and works in any app you use. Try it for 10 minutes, no card.

Get it for Mac, Windows or Linux

Share

Questions and jobs

Do anything

Ask it a question or hand it a job, in any app.

Doing jobs for you is in early access on Mac. Asking works on Mac, Windows and Linux.