From b8d26e8c82a569bca7715fb69fc5a1d77ccb7718 Mon Sep 17 00:00:00 2001 From: Hyungtae Lim Date: Thu, 21 May 2026 12:25:58 +0900 Subject: [PATCH] fix(patchworkpp): clear ringwise_flatness every ring (#69) ringwise_flatness was only cleared inside `if (!candidates.empty())`, so when a ring finished with no revert candidates the accumulated flatnesses leaked into the next ring's `temporal_ground_revert` call, polluting its mean/stdev statistics (and therefore the revert decision threshold) with flatnesses from a coarser/finer ring. Move the clear outside the if-block so it runs unconditionally per ring iteration. Reported by @KennethBlomqvist in url-kaist/patchwork-plusplus#69. Closes #69. --- cpp/patchworkpp/src/patchworkpp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpp/patchworkpp/src/patchworkpp.cpp b/cpp/patchworkpp/src/patchworkpp.cpp index 73377aa..a859f90 100644 --- a/cpp/patchworkpp/src/patchworkpp.cpp +++ b/cpp/patchworkpp/src/patchworkpp.cpp @@ -300,8 +300,12 @@ void PatchWorkpp::estimateGround(Eigen::MatrixXf cloud_in) { } candidates.clear(); - ringwise_flatness.clear(); } + // ringwise_flatness must be cleared every ring; the previous + // placement inside `if (!candidates.empty())` leaked flatnesses + // from no-candidate rings into the next ring's TGR statistics + // (see issue #69). + ringwise_flatness.clear(); clock_t t_aft_revert = clock(); t_revert += t_aft_revert - t_bef_revert;