Algorithm Name
Robust Least-Squares Rectangle Fitting (with robust loss)
Description
This sample estimates an oriented rectangle for each detected object in a 2D LiDAR scan. The scan is first segmented into clusters (each cluster represents one object), then robust least-squares fitting is applied per cluster to output one rectangle per object. Using a robust loss reduces the influence of outliers within each cluster, improving stability under noise and partial occlusions.
Plan for Implementation
- Integration and Interface
- Add a new sample script under
src/simulations/perception/point_cloud_rectangle_fitting/ following the existing L-shape fitting sample structure (same I/O and plotting style).
- Rectangle Parameterization + Initialization
- Reuse the existing clustering/object-segmentation step, then run the fitter independently for each cluster to produce multiple rectangles in a scene.
- Parameterize rectangle as
(cx, cy, theta, width, length) (or half-sizes).
- Use a stable initialization (PCA-based orientation + extents, or the existing L-shape estimate as an initial guess).
- Ensure width/length remain positive during optimization (e.g., optimize half-sizes or log-parameters).
- Residuals and Optimization
- Define one residual per point as the distance to the closest rectangle edge (≈ 0 when the point lies on the rectangle boundary).
- Solve with
scipy.optimize.least_squares using a robust loss (soft_l1 or huber) and an f_scale value in meters that matches expected inlier noise.
- Use a solver method compatible with robust losses (e.g.,
trf).
- Visualization and Testing
- Add a Matplotlib animation showing the rectangle updating during optimization (iterations / parameter updates).
- Add unit tests with synthetic rectangles: edge points + Gaussian noise + injected outliers (animation disabled).
- Validate using measurable errors (e.g., center error, yaw error, size error, and/or IoU vs ground truth rectangle).
References
SciPy least_squares (robust losses: huber, soft_l1, cauchy):
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html
Robust regression / M-estimation overview (intuition for downweighting outliers):
https://pmc.ncbi.nlm.nih.gov/articles/PMC6167755/
Algorithm Name
Robust Least-Squares Rectangle Fitting (with robust loss)
Description
This sample estimates an oriented rectangle for each detected object in a 2D LiDAR scan. The scan is first segmented into clusters (each cluster represents one object), then robust least-squares fitting is applied per cluster to output one rectangle per object. Using a robust loss reduces the influence of outliers within each cluster, improving stability under noise and partial occlusions.
Plan for Implementation
src/simulations/perception/point_cloud_rectangle_fitting/following the existing L-shape fitting sample structure (same I/O and plotting style).(cx, cy, theta, width, length)(or half-sizes).scipy.optimize.least_squaresusing a robust loss (soft_l1orhuber) and anf_scalevalue in meters that matches expected inlier noise.trf).References
SciPy least_squares (robust losses: huber, soft_l1, cauchy):
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html
Robust regression / M-estimation overview (intuition for downweighting outliers):
https://pmc.ncbi.nlm.nih.gov/articles/PMC6167755/