Skip to the lesson
FixTheRobot Explore Robotics / Perception / P5 3D Perception and Point Clouds / P5-T3

Perception · Theory · P5

P5-T3 — Ground and Plane Estimation

The ground is the largest plane in the scene. Find it from the data, because it will not stay flat.

  • Lesson 3 of 6
  • Module 5: 3D Perception and Point Clouds
  • Theory
  • About 10 minutes to read

Almost every ground robot starts perception by removing the ground, so that what remains is something to avoid. A height threshold does that on a perfectly flat floor and fails on the first ramp. The robust way is to estimate the ground as a surface from the points themselves. This lesson writes the plane equation, compares fitting methods, applies RANSAC to planes, explains why the tolerance must grow with range, and describes what to do when the ground is not a single plane.

Learning objectives

After this lesson, you should be able to:

  • Write a plane as n · p + d = 0 and compute the distance of a point to it and the plane through three points.
  • Fit a plane by least squares and by PCA, and say why neither is robust to obstacles.
  • Apply RANSAC to plane fitting and compute the iteration count for a given inlier ratio.
  • Explain the failure of height thresholds on slopes, the need for a range-dependent tolerance, and when one plane is not enough.

The idea: the ground is the biggest plane

Ask what most of the points in front of a wheeled robot belong to. Usually the ground. Obstacles are a minority of the points, and they do not lie in a common plane. That makes the ground the dominant plane in the cloud, and a method that finds the dominant plane robustly finds the ground without being told its height or tilt.

A sensor on a slopeA side view. A LiDAR 1.2 m above a ground that rises at 6 degrees. A dashed horizontal line shows where a flat-ground assumption puts the road. At 10 m ahead the true road is 1.05 m higher than the dashed line, and at 20 m it is 2.1 m higher. A short box obstacle stands on the road at 15 m, much lower than the vertical gap between the lines there.flat-ground assumption: z = −h true ground: z = −h + x tan 6° h = 1.2 mLiDAR 1.05 m at 10 m 2.1 m at 20 m box A slope of 6° moves the ground by about 0.105 m for every metre of range.
On a rising road the flat-ground line is far below the true ground at range. At 20 m the gap is 2.1 m, more than the height of most obstacles, so a height threshold cannot work.

Why not simply threshold the height? Because the height of the ground is not constant. Slopes, kerbs and the pitching of the robot under acceleration all move it, and the error grows with range (range × tan of the slope). The estimated plane carries the tilt and the height with it.

Fit the surface, then measure height above the fitted surface. An obstacle is something that stands out of the ground, wherever the ground is.

The mathematics: planes, fits and RANSAC

The plane

A plane is the set of points p that satisfy

plane equation and distance
n⋅p+d=0n\cdot p+d=0
∥n∥=1\lVert n\rVert =1
signed distance of a point q
dist⁡(q)=n⋅q+d\operatorname{dist} (q)=n\cdot q+d
n
the unit normal (nx, ny, nz); for the ground it points up.
d
the offset: −n · p₀ for any point p₀ on the plane. For a level ground at z = −h, n = (0, 0, 1) and d = h.
dist(q)
the signed distance of q from the plane in metres: positive on the side the normal points to. The height above the ground.

Three points that are not collinear define a plane: n is the normalised cross product (p2 − p1) × (p3 − p1), flipped to point up, and d = −n · p1. A slope of angle α along x gives n = (−sin α, 0, cos α).

Fitting many points

PCA (total least squares): the plane through the centroid p̄ whose normal is the eigenvector of the smallest eigenvalue of the covariance (Lesson P5-T2). It minimises the sum of squared perpendicular distances and treats all directions equally.

Ordinary least squares on z = a x + b y + c: minimises vertical errors; simple (a linear system) and good when the ground is not near-vertical, but biased for steep planes.

Both weigh every point equally, so obstacles (a minority that sits above the ground) pull the plane up and tilt it. They fit the ground well only after the obstacles have been removed, which needs the ground… so a robust method is required first.

RANSAC for planes

Draw three points at random, build their plane, count the points within a threshold t of it, and repeat; keep the plane with most inliers, then refit by PCA to all its inliers (Lesson P4-T4 and Lab P5-L2). The minimal sample is s = 3, so the iterations needed are

iterations for a plane
N≥ln⁡(1−p)ln⁡(1−w3)N\ge \frac{\ln (1-p)}{\ln (1-w^{3})}

With a ground fraction of w = 0.7 and p = 0.99: N = 11. Even with w = 0.4 only 70 are needed. Plane fitting is cheap for RANSAC because the minimal sample is small and the ground usually holds most of the points.

Tolerance that grows with range

A range sensor’s error grows with distance, so the set of ground points within a fixed band is thinner far away. A practical rule lets the tolerance grow linearly:

range-dependent ground test
ground if ∣dist⁡(p)∣<t0+k⋅range⁡(p)\text{ground if}\,\lvert \operatorname{dist} (p)\rvert <t0+k\cdot \operatorname{range}(p)
e.g.t0=0.06 m, k=0.006 m per metree.g.t0=0.06\,\mathrm{m},\,k=0.006\,\mathrm{m}\,\text{per metre}

When one plane is not enough

  • Changing slope: a road that crests or dips is not a plane. Fit a plane per sector (angular slices) or per range band, or fit a surface on a grid, as ground-segmentation methods do.
  • Kerbs, steps, ditches: small height jumps that are the boundary of the drivable surface, not obstacles to remove blindly.
  • Vegetation and rough terrain: no clean plane; the ground has to be estimated as a surface that the lowest points support, not as a plane.
  • A large wall or flat roof: a plane with more points than the ground. Constrain the normal to be nearly vertical and the plane to be near the expected height.

A worked example: a plane from three points, and the cost of assuming flat

Three points on a rising road, in the sensor frame (z up, sensor at the origin): p1 = (2, 0, -1.1), p2 = (6, 0.2, -0.72), p3 = (5, -2, -0.8).

plane through three points
u=p2−p1=(4.00, 0.20, 0.38)u=p2-p1=(4.00,\,0.20,\,0.38)
v=p3−p1=(3.00, −2.00, 0.30)v=p3-p1=(3.00,\,-2.00,\,0.30)
n=u×v∥u×v∥=(−0.0949, 0.0069, 0.9955)n=\frac{u\times v}{\lVert u\times v\rVert }=(-0.0949,\,0.0069,\,0.9955)
(pointing up)\text{(pointing up)}
d=−n⋅p1=1.2848d=-n\cdot p1=1.2848
tilt from the horizontal=5.5∘\text{tilt from the horizontal}=5.5^{\circ}

The road rises at about 5.5°: the normal tilts back from the vertical by that angle. The height of a point q above this ground is n · q + d. For a point at (10, 0, −0.1): 0.24 m above the ground; if instead you assume a flat ground at z = −1.2, the same point is 1.10 m above ground. A true obstacle point only 0.24 m above the road would be classified as a 1.1 m obstacle.

Cost of the flat assumption

A slope of 6° changes the ground height by 0.1051 m per metre of range: 1.05 m at 10 m and 2.10 m at 20 m. A threshold margin of 0.3 m lets the flat assumption work only to a range of 2.9 m on this slope. Beyond that, every ground point is above the threshold and appears to be an obstacle. The failure is not noise: it is systematic, grows with range and is entirely avoided by fitting a plane.

Iterations and the effect of obstacles

Suppose a cloud of 1 000 points has 700 ground points. A random triple is all ground with probability 0.7³ = 0.343, so about 11 samples give a clean one with 99% confidence. The best plane’s inlier count then identifies ground. An ordinary least-squares fit to all 1 000 points would instead tilt towards the 300 obstacle points: if they sit on average 0.8 m above the ground, the fitted plane rises by roughly 0.3 × 0.8 = 0.24 m on average and tilts, which is a larger error than the noise and is entirely due to the obstacles.

Engineering implications and limitations

Constrain the plane. The ground normal is nearly vertical (within, say, 15° of the expected up direction from the IMU) and the plane is near the expected height. A large wall can win the RANSAC vote otherwise.

Use the IMU. The pitch and roll of the vehicle change the apparent ground plane from frame to frame. Rotating the cloud into a gravity-aligned frame first removes most of that and leaves only real terrain slope for the estimate.

Refit and re-test. After RANSAC, refit by PCA to all inliers and re-evaluate with the range-dependent tolerance. This is the cheap step that improves accuracy and reduces false obstacles at long range.

Handle non-planar ground. Use sectors or a grid of local planes, or a ground model such as a Gaussian process or a lowest-point surface, and check the boundaries between pieces. Keep the previous frame’s estimate as a prior for the next.

Do not discard what stands on the ground. Points close to the plane include the bottoms of obstacles, kerbs and low objects. A removal tolerance that is too generous removes real small obstacles; test with objects of the smallest height that matters (for example 15 cm).

Monitor the estimate. A sudden change in the fitted normal, an unusually small inlier fraction or a plane far from the expected height means something is wrong (a wall in front, a failed scan). Fall back to the previous plane and slow down.

Common misconceptions

“Ground removal is a height threshold.”

Only on a flat, level floor. Anywhere else the threshold must follow the ground, which means estimating it.

“Least squares is the best plane fit.”

It is the best for clean data. With obstacles in the cloud it is pulled towards them. A robust step (RANSAC) has to come first.

“The largest plane is always the ground.”

A wall or a flat roof can be larger. Constrain the normal and the height, and use the IMU.

“A fixed tolerance is fine once the plane is right.”

Sensor noise grows with range, so a constant tolerance is too tight far away and too loose near the sensor.

Engineering takeaways

  1. A plane is n · p + d = 0 with ‖n‖ = 1; the signed distance of q is n · q + d; three non-collinear points define a plane.
  2. PCA and least squares fit planes but are pulled by obstacles; RANSAC with three-point samples finds the dominant plane, followed by a PCA refit on its inliers.
  3. N ≥ ln(1 − p)/ln(1 − w³): 11 iterations for w = 0.7 and p = 0.99.
  4. A slope of α moves the ground by range × tan α: 1.05 m at 10 m for 6°. Height thresholds on flat ground fail systematically with range.
  5. Use a range-dependent tolerance t0 + k·range, constrain the plane, use the IMU, and use sectors or grids when the ground is not a single plane.

References and further reading

Standard references; the plane through three points and the slope numbers were computed for this lesson.

  • Fischler, M. A. and Bolles, R. C. (1981). Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography. Communications of the ACM 24(6).
  • Himmelsbach, M., Hundelshausen, F. v. and Wuensche, H.-J. (2010). Fast segmentation of 3D point clouds for ground vehicles. IEEE Intelligent Vehicles Symposium: a ground model made of local line fits per angular sector.
  • Zermas, D., Izzat, I. and Papanikolopoulos, N. (2017). Fast segmentation of 3D point clouds: a paradigm on LiDAR data for autonomous vehicle applications. ICRA: ground plane fitting and scan-line segmentation.
  • Rusu, R. B. and Cousins, S. (2011). 3D is here: Point Cloud Library (PCL). ICRA: plane segmentation with RANSAC.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A ground plane has normal (−0.0872, 0, 0.9962) and d = 1.19 (z up, sensor at the origin). What is the tilt, and what height above the ground does a point at (8, 0, −0.3) have?

Explanation

The tilt is asin(0.0872) ≈ 5°. Height = n · q + d = −0.0872 × 8 + 0.9962 × (−0.3) + 1.19 = −0.698 − 0.299 + 1.19 = 0.193 m: the point is about 19 cm above the ground, a low obstacle or the top of noise.

Question 2

A cloud has 60% ground points. How many RANSAC iterations are needed for 99% confidence with 3-point samples?

Explanation

w³ = 0.216, so N = ln 0.01 / ln(1 − 0.216) = −4.605 / −0.2434 ≈ 19 iterations.

Question 3

A robot’s obstacle detector reports a solid wall 15 m ahead whenever it drives uphill. The code removes points lower than −h + 0.3 m. What is wrong and what is the fix?

Explanation

Assuming a flat ground: on an uphill slope of about 3°, the ground is 15 × tan 3° ≈ 0.79 m above the assumed line at 15 m, so the road itself passes the “not ground” test and looks like a wall. Fit the ground plane from the points (RANSAC then PCA), optionally with the IMU pitch, and measure height above that plane.

What’s next

Next: grouping what remains after the ground is removed into separate objects.

Practice this lesson

Fit a Ground Plane Robustly

Estimate a sloped ground plane with RANSAC where a height threshold fails.

Next lesson

P5-T4 — Clustering and Object Separation

Cluster points into objects and choose distance thresholds.

Nothing below is required to finish this lesson.