Skip to content

fix: use fixed-size Eigen vectors for plane-fit members (resolves #62)#81

Merged
LimHyungTae merged 1 commit into
masterfrom
fix/eigen-fixed-size-vectors
May 9, 2026
Merged

fix: use fixed-size Eigen vectors for plane-fit members (resolves #62)#81
LimHyungTae merged 1 commit into
masterfrom
fix/eigen-fixed-size-vectors

Conversation

@LimHyungTae
Copy link
Copy Markdown
Member

Summary

Replaces Eigen::VectorXf with Eigen::Vector3f for normal_, singular_values_, and pc_mean_ in cpp/patchworkpp/include/patchwork/patchworkpp.h.

The dynamic vectors are accessed at fixed indices (e.g. pc_mean_(0), singular_values_.minCoeff()) before being sized, which crashes at startup when the input is a partial (non-360°) point cloud — for example, the OS1 128 Ouster pointcloud reported in #62 that does not start at azimuth 0.

The fix matches the maintainer's own recommendation in #62 and the SVD output type (JacobiSVD<MatrixX3f> returns a Vector3f for singular values and matrixU().col(2) is a Vector3f).

Why this re-issues #72 instead of merging it

#72 had the correct fix but the commit was unsigned, and master now requires signed commits. This PR re-applies the same diff with MatteGombia as author and a signed committer, plus a Co-authored-by: trailer for full credit.

#66 attempted the same fix but used Vector2f for singular_values_, which would silently change ground segmentation behavior because singular_values_.minCoeff() (used as the flatness measure at cpp/patchworkpp/src/patchworkpp.cpp:221) operates on the third (smallest) singular value — that's the one perpendicular to the fit plane.

Test plan

  • cpp build clean on macOS arm64 (FetchContent Eigen 3.4)
  • pytest 4/4 pass (2 patchworkpp + 2 patchwork) on data/000000.bin
  • CI matrix (Ubuntu 22/24, Windows, macOS 14, ROS humble/jazzy)

Closes

normal_, singular_values_, and pc_mean_ were declared as Eigen::VectorXf
(dynamic-size). When a partial (non-360°) point cloud is processed
— e.g. an OS1 128 Ouster pointcloud that doesn't start at azimuth 0 —
the dynamic vectors are accessed at fixed indices before being sized,
producing an immediate crash at startup.

Switch all three to Eigen::Vector3f. Matches the SVD output (Vector3f
from JacobiSVD<MatrixX3f>) and the existing per-index accesses
(e.g. singular_values_.minCoeff(), pc_mean_(0..2), normal_(0..2)).

Co-authored-by: MatteGombia <matteogombia@gmail.com>

Closes #62
@LimHyungTae LimHyungTae merged commit dcdd4bf into master May 9, 2026
18 checks passed
@LimHyungTae LimHyungTae deleted the fix/eigen-fixed-size-vectors branch May 9, 2026 23:18
TechRufy pushed a commit to ubm-driverless/patchwork-plusplus that referenced this pull request May 13, 2026
Includes the partial-pointcloud crash fix from url-kaist#81 (Eigen::VectorXf →
Eigen::Vector3f for normal_, singular_values_, pc_mean_).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants