Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exploring Surface Material Detection with a Low-Cost 2D LIDAR

CI

Can a distance-only LIDAR distinguish cardboard, clothing, and glass?

This project started from my curiosity about how different surfaces affect a low-cost YDLIDAR X2. I recorded repeated scans of three materials at several distances, measured their return behavior, and tested whether a classifier trained at some distances could recognize materials at a distance it had never seen.

Out-of-fold replay of recorded material scans

The replay uses real recorded rotations. Each prediction is made by a model that excluded that rotation's entire standoff distance from training. The score bars are random-forest class votes, not calibrated confidence values.

Surface-response measurements and evaluation

The result is promising but not conclusive: 57.5% cross-distance accuracy across 308 rotations, compared with a 33.4% majority-class baseline. Glass produced the clearest signature. Cardboard and clothing were frequently confused.

Why this is a difficult problem

The YDLIDAR X2 reports angle and distance, but it does not provide a return-intensity channel, according to the official YDLIDAR SDK model table. That means the project cannot measure reflectivity directly. Instead, it investigates indirect surface-response signals:

  • fraction of valid returns;
  • range standard deviation and interquartile range;
  • median absolute deviation;
  • adjacent-sample jitter; and
  • frequency of large range discontinuities.

Absolute median range is deliberately excluded from classification so the model cannot simply learn that a material happened to be placed at a particular distance.

Experiment

The included dataset contains repeated forward-facing rotations for:

Material Nominal standoffs
Cardboard 24 cm, 50 cm, 100 cm
Clothing 24 cm, 50 cm, 100 cm
Glass 24 cm, 50 cm, 100 cm

Evaluation uses leave-one-distance-out validation:

  1. Train on two standoff distances.
  2. Test on every rotation from the unseen third distance.
  3. Repeat for 24, 50, and 100 cm.
  4. Combine the held-out predictions into one confusion matrix.
Held-out distance Accuracy
24 cm 63.7%
50 cm 57.3%
100 cm 51.5%
Combined 57.5%

Glass was classified correctly in 99 of 102 held-out rotations. Most remaining errors were confusion between cardboard and clothing.

These measurements come from one setup and a small number of physical material samples. The result is evidence that useful surface-dependent behavior exists in this setup—not evidence of a production-ready material detector.

What drives the prediction?

Feature ablation and distance generalization

Removing discontinuity rate reduced accuracy by 21.4 percentage points, while removing return rate reduced it by 19.8 points. Median absolute deviation and adjacent jitter were also useful. Removing plain range standard deviation slightly improved the result, suggesting that it overlaps with the more robust variation features or adds noise.

The train-distance/test-distance matrix shows another important limitation: a model trained at only one distance generalizes poorly. The 57.5% result depends on training across more than one standoff, which is why all headline predictions use leave-one-distance-out evaluation.

Run the study

Python 3.10 or newer is required.

python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'

lidar-perception report \
  --data data/materials \
  --output-dir docs/images

pytest

Expected summary:

308 rotations, cross-distance accuracy 57.5%, majority baseline 33.4%

That one command regenerates the static study, model diagnostics, and animated replay. The analysis is deterministic: the classifier has a fixed random seed, and the tests operate on the checked-in captures. GitHub Actions runs linting and all tests on Python 3.10 and 3.13 after every push.

Perception and tracking extension

I also used the same sensor pipeline to explore spatial perception: invalid-return filtering, DBSCAN object detection, nearest-target selection, and constant-velocity Kalman tracking through missing observations.

Filtering, clustering, and tracking pipeline

Run the hardware-free pipeline demo:

lidar-perception demo --output pipeline-demo.png

Or process an archived JSON point cloud or legacy text capture:

lidar-perception scan path/to/scan.json \
  --max-distance 1500 \
  --eps 80 \
  --output scan.png

The tracker estimates [x, y, vx, vy] while measuring only [x, y]. Velocity is inferred from successive positions rather than incorrectly treated as a measured zero. It can therefore continue predicting during short measurement dropouts.

Project structure

data/materials/         raw cardboard, clothing, and glass captures
src/lidar_perception/   material analysis and perception pipeline
examples/               hardware-free and optional live examples
tests/                  deterministic unit and integration tests
docs/images/            generated study and portfolio figures

The material-analysis path is:

legacy scan logs
      |
      v
split into rotations --> select forward region --> reject invalid returns
                                                   |
                                                   v
                                    extract response statistics
                                                   |
                                                   v
                              distance-held-out classification

Live sensor use

The optional live example expects a module exposing a YDLidarX2 class with the interface described in lidar_perception.hardware:

python -m pip install -e '.[live]'
python examples/live_demo.py --port /dev/ttyUSB0 --driver-module ydlidar_x2

The driver from the earlier experiment is not included because it had no explicit license. Install a licensed compatible driver separately or supply an adapter. See the project origins for migration and attribution notes.

What I would explore next

  • Collect several independent sessions and multiple samples of each material.
  • Randomize material order and position to reduce environmental confounding.
  • Add incidence angle, ambient light, color, and surface finish as controlled variables.
  • Compare the X2 against a sensor that exposes calibrated return intensity.
  • Evaluate nested group validation by both distance and physical sample.
  • Add an explicit unknown-material class and calibrated confidence thresholds.

Portfolio summary

Designed and evaluated an exploratory surface-material classifier for a distance-only YDLIDAR X2. Collected 308 scan rotations across cardboard, clothing, and glass at three distances; engineered return-stability features; and measured 57.5% leave-one-distance-out accuracy against a 33.4% baseline. Extended the work into a tested perception pipeline using DBSCAN clustering and Kalman tracking through missing observations.

License

MIT

About

Exploring whether a distance-only YDLIDAR X2 can distinguish cardboard, clothing, and glass

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages