Update a Log-Odds Occupancy Grid From Lidar Returns

Last updated: November 29, 2026

Quick Overview

Implement an update step for a 2D occupancy grid: for each lidar return from the sensor cell, mark the cells along the ray as more likely free and the endpoint as more likely occupied, using log-odds with clamping and treating out-of-range returns as misses.

Nuro
Coding & Algorithms
Software Engineer
Nuro
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Implement an update step for a 2D occupancy grid: for each lidar return from the sensor cell, mark the cells along the ray as more likely free and the endpoint as more likely occupied, using log-odds with clamping and treating out-of-range returns as misses.

Occupancy representations underpin drivable-space estimation and give a geometry-based backstop next to learned perception, which matters for an autonomy stack licensed for robotaxis and personal cars. The interviewer looks for an integer ray traversal (Bresenham or DDA), a sound probabilistic update, and sensible handling of max-range returns.

What the Interviewer Expects
  • Implement integer ray traversal without floating point drift
  • Apply free updates to traversed cells and an occupied update to the endpoint only
  • Use log-odds so updates are additive, with clamping to keep the map responsive
  • Treat max-range or no-return beams as free space up to the range limit, not obstacles
  • Use a sparse or bounded structure and discuss memory
Key Topics to Cover
Bresenham line
log-odds
occupancy grid
lidar processing
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle the ego vehicle moving between sweeps, for example a rolling ego-centric grid?
  • How would you deal with dynamic objects that leave ghost trails in the map?
  • How would you vectorize or move this to a GPU for 100k points per sweep?
  • Why might you want a 3D voxel or height map instead of 2D?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Grid cells are integer coordinates. The sensor sits in origin. Each hit is an endpoint cell. Store log-odds in a dict (missing means 0, probability 0.5). Constants: free -0.4, occupied +0.85, clamp ...

High-Level Design

Log-odds turn the Bayesian update into addition: lt=lt−1+log⁡p(occ∣z)1−p(occ∣z)l_t = l_{t-1} + \log\frac{p(occ|z)}{1 - p(occ|z)}. For each beam, walk the cells with Bresenham, add the free term to every cell before the endpoint ...


Submit Your Answer
Markdown supported

Related Questions