Skip to content

Obstacle Detection System

Electrical/Computer Science · Summer 2026

Overview

During my second internship with Perseuss, I created a wearable LiDAR terrain/obstacle detection wearable IoT, using an ESP32, a LIDAR, and an inertial sensor that alerts the user about changes in ground level or obstacles in their path before they step. The device is designed to help elderly people navigate their surroundings safely. Working with my supervisor, I designed algorithms to compensate for hand tilt, filter noisy measurements, and reliably classify step-ups and step-downs. In addition, I built a working prototype with buzzer/LED alerts and Bluetooth communication to a live browser dashboard.

Obstacle Detection System

Article

Obstacle Detection with a Single-Point LiDAR and an IMU

How a distance reading, a rotation matrix, and a small ESP32 turn into a wearable terrain-alert prototype.

The final prototype: an ESP32 and IMU board inside a 3D-printed red enclosure, with a teal mounting bracket The final prototype: ESP32 and IMU wired into a 3D-printed enclosure, with a printed mounting bracket for the LiDAR.


The core idea

A single point LiDAR reports one number: how far away the thing in front of it is. To turn that number into a statement about the space around a person, you need to know where the sensor is and which way it is pointing.

The point struck by the beam is the sensor's origin plus the measured distance along the beam's direction. In a consistent world frame:

P_w(t) = O_w(t) + L(t) · u_w(t)
QuantityMeaning
P_w(t)Estimated point where the beam returns, in world coordinates
O_w(t)Sensor origin in the same world frame
L(t)Distance reported by the LiDAR along its beam
u_w(t)Unit vector giving the beam's direction in world coordinates

Multiplying a unit vector by a distance gives a displacement, and adding the origin locates the return point. The equation is compact, but it has an important condition that every vector must be expressed in the same coordinate frame.

The equation also shows that L supplies the distance, but not the orientation or the origin. A longer range could mean the ground dropped away, the beam tilted, or the sensor itself moved. Separating those causes is the key challenge of this project.

Two frames and a rotation

The model uses two coordinate frames:

  • The sensor frame moves with the IMU board.
  • The world frame is a local reference in which the floor is the plane z = 0 and positive z points up.

The LiDAR is rigidly attached to the IMU, so its beam direction in sensor coordinates, u_s, is constant. What changes is how the direction looks from the world. A rotation matrix R converts sensor coordinates to world coordinates:

u_w(t) = R(t) · u_s
P_w(t) = O_w(t) + L(t) · R(t) · u_s

Each part has its own role:

  • u_s is a fixed property of the assembly, set by how the LiDAR is mounted.
  • R(t) comes from the orientation estimate and changes continuously.
  • L(t) comes from the LiDAR.

Schematic: a sensor at height H, a beam of length L in direction u, a return point P, and the height e above the reference floor z = 0 Schematic geometry, not to scale. The range follows the beam; height is its vertical projection relative to the reference floor.

From range to height

We assume that the sensor origin is fixed at O = [0, 0, H], where H is the sensor's height above the reference floor. The vertical coordinate of the return, which is the height of the surface the beam hit, becomes:

e(t) = P_z(t) = H + L(t) · u_w,z(t)

A downward beam has a negative vertical component. On a flat floor, range and direction combine to give e near zero. A return above the reference plane gives a positive e, and one below it gives a negative e, within the assumptions of the model.

Why a tilted beam seems to see a lower floor. If we take a sensor 0.85 m above a flat floor, pointed straight down, the ideal reading is 0.85 m. If we tilt the beam 30° from vertical, the path along the beam becomes about 0.981 m, even though the floor has not moved:

u_w,z = −cos(30°)
e = H + L · u_w,z ≈ 0.85 − 0.981 × cos(30°) ≈ 0

Projecting the range onto the vertical axis turns the slanted distance back into a height near the reference floor.

These numbers illustrate the model and are not a measured accuracy result, but they show why the project needs orientation information alongside distance.

Whiteboard sketch titled "Obstacle detection pipeline" showing the beam geometry, the "Perfect World Model" assumptions, and the update equation for the beam direction The model started on a whiteboard. The "perfect world" version assumes ideal sensors, continuous measurements, and a flat floor in the XY plane, and every later piece of the firmware relaxes one of those assumptions.

Tracking orientation as the wearer moves

The gyroscope measures angular velocity in the moving sensor frame, so orientation has to be estimated continuously: establish an initial orientation, then update it with each new measurement.

Starting up. When the device is still, the accelerometer measures gravity. That fixes the local vertical and initializes roll and pitch. Gravity does not indicate anything about the heading around the vertical axis, so yaw starts from a chosen reference rather than a measured direction.

Updating. For a sensor-to-world rotation matrix and body-frame angular velocity ω, the update has the form:

R_{k+1} = R_k · exp([ω_k]× Δt)

The bracket [ω]× is the skew-symmetric matrix that represents a cross product, and the exponential produces a rotation for the elapsed time. The firmware computes it with Rodrigues' formula and periodically restores the matrix's orthonormality to limit numerical error. We keep the frame convention explicit because a mathematically plausible update can describe the wrong physical rotation if the conventions are mixed up.

A rotation matrix's columns are mutually perpendicular unit axes. If its entries drift arbitrarily, it stops rotating vectors and starts stretching or distorting them. That is why the firmware re-orthonormalizes it.

Prediction needs a reference

To integrate the gyro readings, we keep a rotation matrix, and a delta R, and using Rodrigues' formula, take the integral of the gyro readings. When integrating gyro readings, they follow rapid rotation well, but a small bias accumulates into drift. To remove the bias, when the device is still, the accelerometer gives a gravity reference that can correct tilt. While walking, the accelerometer also feels the motion of the body, so its reading requires judgment. Combining the two signals needs a rule for when and how much to trust each.

Kalman filtering as a design approach

Orientation estimation is a sensor-fusion problem. The gyro is accurate over short intervals, but integrating it accumulates drift from residual bias. The accelerometer provides a gravity reference with no drift, but walking adds non-gravitational acceleration. A filter must decide how much to trust each signal at each moment.

Our mathematical exploration included Kalman filtering, which estimates a changing state from uncertain measurements. A prediction step advances the estimate using a motion model (here, the gyro). A correction step then adjusts it using a measurement (here, the accelerometer), weighted by the uncertainty assigned to each. The state for this problem includes orientation and possibly sensor bias. Applying a Kalman filter to 3D attitude also requires care with the geometry of rotations, which makes it considerably more involved than averaging two sensor readings.

The whiteboard sketch above shows this early plan: a Kalman filter (KF) takes the accelerometer and gyro readings and produces the orientation, with a note that the rotation should be represented as a quaternion.

The implemented Mahony-style PI observer

The firmware does not use a Kalman filter. It uses a Mahony-style proportional-integral (PI) attitude observer, which belongs to the family of complementary filters. Each cycle it:

  • Predicts orientation by integrating the gyro.
  • Compares the predicted vertical direction with the measured acceleration direction. The disagreement is the tilt error.
  • Corrects the orientation using that error:
    • The proportional term responds to the current tilt error, pulling the estimate back immediately.
    • The integral term accumulates the error over time into an estimate of residual gyro bias, which is a slower correction that stops drift from building up.

Acceleration gating protects the gravity reference. When the accelerometer magnitude is far from 1 g, movement is contaminating the reading, so the correction is switched off. The gyro keeps integrating, so attitude tracking continues.

This follows the approach in Mahony, Hamel, and Pflimlin, Nonlinear Complementary Filters on the Special Orthogonal Group. The choice reflects an engineering trade-off: Kalman filtering was studied, but the PI observer needs far less computation and its assumptions suit a small ESP32 prototype. Calling the implemented observer a Kalman filter would describe a different algorithm.

Gravity constrains roll and pitch but not absolute heading. Without an absolute heading reference such as a magnetometer, yaw remains relative and may drift. Using quaternions instead of a rotation matrix would not change this.

From model to connected prototype

The prototype brings the mathematics onto real hardware:

  • Microcontroller: ESP32
  • Range sensor: Garmin LIDAR-Lite v4 LED
  • IMU: MPU-6050 (GY-521 board)
  • Interface: I²C between the sensors and the ESP32

Before anything was mounted, the sensors were tested on breadboards with the ESP32 connected to a laptop, reading the LiDAR, the IMU, and an 8 × 8 time-of-flight sensor side by side in the Serial Monitor. The time-of-flight sensor was considered during development but is not part of the single-point processing path described here.

Bench setup: an ESP32 on breadboards wired to a LiDAR module, with a laptop showing the Arduino Serial Monitor streaming LiDAR, time-of-flight, accelerometer, and gyro readings Early bench testing: the sensors on breadboards, with live readings from every sensor streaming into the Serial Monitor.

Over roughly three weeks of iterative development, I assembled and soldered the device, added audible and visual warnings, and streamed readings over Bluetooth/BLE to a live browser dashboard. The dashboard and diagnostic tools exposed the system's internal measurements during testing. The work builds on my earlier robotics experience with MIT BeaverWorks and extends it into embedded C++, sensor processing, and wireless communication.

Mounting and calibration are part of the product

Moving from breadboard to a wearable meant designing and 3D printing mounts. The IMU was fixed to a printed plate, and the LiDAR was bolted into a housing on a printed bracket, so that the beam direction relative to the IMU stays fixed.

The MPU-6050 IMU board on a breadboard that is mounted on a red 3D-printed plate The IMU mounted on a printed plate, so its axes stay fixed relative to the rest of the assembly.

The LiDAR module bolted into a printed housing, held against a blue 3D-printed bracket The LiDAR bolted into its housing and fitted to a printed bracket. How rigidly this holds the beam relative to the IMU determines how well the fixed beam direction u_s can be trusted.

Several quantities must agree before the geometry makes sense, so calibration comes up again and again. Three separate tasks are easy to confuse:

  1. Measure the fixed beam direction. The LiDAR's optical axis must be known relative to the IMU's physical axes. Mounting it perpendicular to the board simplifies the initial model to a beam near [0, 0, ±1], with the sign checked against the actual mounting.
  2. Initialize orientation. Holding the assembly still lets gravity establish the vertical. The chosen starting yaw defines the horizontal reference used afterward.
  3. Estimate gyro bias. When the device is stationary, true angular velocity should be near zero, so averaging the gyro output gives an offset to subtract from later readings.

A mechanical assumption only helps if the optical axis follows it closely. A few degrees of mounting error can noticeably affect projected height, especially at longer ranges. So the project includes a multi-pose calibration routine that estimates the beam direction from flat-floor observations using least squares. For each still pose, the known height H, the measured range L_i, and the gravity-related sensor direction g_i constrain the beam vector:

L_i · (g_i · u_s) = −H

Collecting varied poses gives several equations for one fixed mounting vector. Repeating effectively the same pose adds almost no new geometric information, so the poses need to tilt in different directions. The routine reports its residuals so the fit can be examined rather than accepted just because it produced a number.

Turning height estimates into alerts

A projected height still needs interpretation. Comparing e against a fixed H would make every error source look like terrain: H is approximate, the hand moves, attitude error grows with range, and real floors are not perfectly flat. The firmware instead keeps a running baseline of recent flat returns and examines the deviation from it.

  • Returns classified as flat update the baseline slowly, so slow changes are absorbed.
  • A possible step does not pull the baseline toward itself, so sharp changes stand out.
  • The detection threshold scales with range.
  • Several consecutive agreeing samples are required before a terrain change is committed.
  • Shallow beam angles are rejected, because orientation error dominates the height estimate there.
  • Committed transitions trigger buzzer tones and LED flashes, with different cues for step up, step down, and a vanished floor (an edge).

These mechanisms are meant to reduce unstable decisions. They are not a measured guarantee of false-alarm or detection rates.

Limits and honest caveats

Orientation compensation helps separate where the sensor points from what the surface does. But a device carried on a belt or in the hand also rises, falls, and shifts horizontally as its user walks, and the simplified fixed-origin model does not estimate that translation. The prototype is therefore not immune to walking oscillations. It handles rotation and uses filtering and a local baseline to make measurements more useful, while some motion, timing, and calibration errors remain. An adaptive baseline absorbs slow changes, but it does not recover the wearer's true trajectory or build an absolute terrain map.

Known limitations:

  • Limited field of view. A single-point LiDAR sees one ray at a time, so a hazard outside that ray may go unmeasured.
  • Heading uncertainty. Without an absolute heading reference, yaw can drift. Horizontal coordinates are local estimates, not globally referenced positions.
  • Acceleration ambiguity. Movement can make the accelerometer an imperfect gravity reference even when a simple magnitude gate accepts it.
  • Timing and mounting error. Sensor readings are not perfectly synchronized, and mechanical alignment affects the projected return.
  • Labels, not probabilities. Thresholds and agreeing samples produce classifications, not a validated probability that a path is safe.

Moving toward a worker-worn product would require systematic testing across walking speeds, attachment heights, beam angles, surfaces, lighting conditions, and obstacle types. Missed detections, false alerts, warning time, comfort, and durability would all matter. This project does not include a completed field-validation study or safety certification.

What the project shows

The equations expose both a useful transformation and the assumptions that still need investigation, and that is what makes the project mathematically substantial. It connects linear algebra, attitude estimation, calibration, embedded programming, and a working prototype, and it is open about where the model stops being valid.

Further reading

  • Joan Solà, Quaternion Kinematics for the Error-State Kalman Filter
  • Robert Mahony, Tarek Hamel, and Jean-Michel Pflimlin, Nonlinear Complementary Filters on the Special Orthogonal Group

Gallery · 02 items

  • 01

    Working through the mathematical model

    A major challenge when developing the mathematical model was that the distance measured by the laser changes not only when the terrain changes, but also when the person holding the sensor tilts their hand, and is prone to errors. Working closely with my supervisor, I developed the mathematical model and implemented it in a working prototype. Our firmware combined gyroscope measurements with accelerometer-based tilt correction to estimate the laser’s direction and calculate terrain height. We implemented multiple calibration procedures, rejected measurements taken at shallow viewing angles, and required repeated, consistent readings before classifying a change as a step. This allowed me to carry the mathematical model through to the practical challenges of noisy real-world sensor data. In around three weeks, through multiple iterations, I developed a prototype capable of classifying both step ups and step downs, triggering buzzer and LED alerts when faced with different scenarios, and transmitting data via Bluetooth to a live browser. In addition to software and mathematical models, I designed, built and soldered the wearable, and created diagnostic tools that made the system easier to test, understand, and continue developing. I applied my robotics experience from MIT BeaverWorks and previous projects to implement sensor filtering, PI control loops, and real-time data processing, expanding my knowledge by employing BLE connectivity and learning how to move from mathematical concepts to a functioning physical system.

  • 02 · Video

    Field testing the prototype