Skip to content

Commit 0e0e542

Browse files
committed
icp-log-viewer: add --min-quality filter CLI flag
1 parent 37628b0 commit 0e0e542

2 files changed

Lines changed: 120 additions & 8 deletions

File tree

apps/icp-log-viewer/main.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ static TCLAP::ValueArg<double> argAutoPlayPeriod(
7575
"mode.",
7676
false, 0.1, "period [seconds]", cmd);
7777

78+
static TCLAP::ValueArg<double> argMinQuality(
79+
"q", "min-quality",
80+
"Minimum ICP quality (range [0,1], i.e. 0%%-100%%) to load a log file. "
81+
"Files whose ICP result quality is below this threshold are skipped.",
82+
false, 0.0, "quality [0,1]", cmd);
83+
7884
// =========== Declare global variables ===========
7985
#if MRPT_HAS_NANOGUI
8086

@@ -233,6 +239,48 @@ void main_show_gui()
233239
files[0].wholePath = argSingleFile.getValue();
234240
}
235241

242+
// Apply minimum quality filter if requested:
243+
if (argMinQuality.isSet())
244+
{
245+
const double minQ = argMinQuality.getValue();
246+
if (minQ < 0.0 || minQ > 1.0)
247+
{
248+
THROW_EXCEPTION_FMT("--min-quality must be in [0,1]. Got: %.03f", minQ);
249+
}
250+
std::cout << "Applying minimum quality filter: q >= " << minQ << std::endl;
251+
252+
mrpt::system::CDirectoryExplorer::TFileInfoList filteredFiles;
253+
for (const auto& file : files)
254+
{
255+
mp2p_icp::LogRecord lr;
256+
if (!lr.load_from_file(file.wholePath))
257+
{
258+
std::cerr << " Warning: could not load '" << file.wholePath << "'" << std::endl;
259+
continue;
260+
}
261+
if (lr.icpResult.quality >= minQ)
262+
{
263+
filteredFiles.push_back(file);
264+
}
265+
else
266+
{
267+
std::cout << " Skipping (quality=" << lr.icpResult.quality << " < " << minQ
268+
<< "): " << file.name << std::endl;
269+
}
270+
}
271+
std::cout << "Quality filter: kept " << filteredFiles.size() << " / " << files.size()
272+
<< " files." << std::endl;
273+
274+
if (files.empty())
275+
{
276+
THROW_EXCEPTION_FMT(
277+
"No log files passed --min-quality=%.03f. Lower the threshold or check input logs.",
278+
minQ);
279+
}
280+
281+
files = std::move(filteredFiles);
282+
}
283+
236284
// load files:
237285
for (const auto& file : files)
238286
{

docs/source/app_icp-log-viewer.rst

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Application: ``icp-log-viewer``
55
=====================================
66

7-
Debug ICP pipelines as never before!
7+
``icp-log-viewer`` is an interactive GUI tool to inspect and debug ICP (Iterative Closest Point)
8+
registration sessions stored as ``*.icplog`` files.
89

910
.. raw:: html
1011

@@ -18,30 +19,48 @@ Debug ICP pipelines as never before!
1819
How to launch
1920
------------------
2021

21-
Once mp2p_icp is installed, move to the directory where your `*.icplog` files have been stored and run:
22+
Once mp2p_icp is installed, move to the directory where your ``*.icplog`` files have been stored and run:
2223

2324
.. code-block:: bash
2425
2526
icp-log-viewer
2627
28+
You can also point it directly at a single file or a specific directory:
29+
30+
.. code-block:: bash
31+
32+
# Load all *.icplog files in a directory
33+
icp-log-viewer -d /path/to/logs/
34+
35+
# Load a single file
36+
icp-log-viewer -f /path/to/log.icplog
37+
38+
# Only load files where the ICP quality is >= 0.5 (50%)
39+
icp-log-viewer -d /path/to/logs/ --min-quality 0.5
40+
2741
2842
.. dropdown:: Complete command line argument help
2943

3044
.. code-block:: bash
3145
3246
USAGE:
3347
34-
icp-log-viewer [--autoplay-period <period [seconds]>] [-l <foobar.so>]
35-
[-f <log.icplog>] [-d <.>] [-e <icplog>] [--]
36-
[--version] [-h]
48+
icp-log-viewer [--autoplay-period <period [seconds]>] [-q <quality [0,1]>]
49+
[-l <foobar.so>] [-f <log.icplog>] [-d <.>] [-e <icplog>]
50+
[--] [--version] [-h]
3751
3852
39-
Where:
53+
Where:
4054
4155
--autoplay-period <period [seconds]>
4256
The period (in seconds) between timestamps to load and show in
4357
autoplay mode.
4458
59+
-q <quality [0,1]>, --min-quality <quality [0,1]>
60+
Minimum ICP quality (range [0,1], i.e. 0%-100%) to load a log file.
61+
Files whose ICP result quality is below this threshold are skipped.
62+
This is useful to focus inspection on well-converged ICP results.
63+
4564
-l <foobar.so>, --load-plugins <foobar.so>
4665
One or more (comma separated) *.so files to load as plugins
4766
@@ -52,7 +71,7 @@ Once mp2p_icp is installed, move to the directory where your `*.icplog` files ha
5271
Directory in which to search for *.icplog files.
5372
5473
-e <icplog>, --file-extension <icplog>
55-
Filename extension to look for. Default is `icplog`
74+
Filename extension to look for. Default is ``icplog``.
5675
5776
--, --ignore_rest
5877
Ignores the rest of the labeled arguments following this flag.
@@ -67,4 +86,49 @@ Once mp2p_icp is installed, move to the directory where your `*.icplog` files ha
6786
GUI and feature explanation
6887
-------------------------------
6988

70-
Write me!
89+
The viewer window is divided into a left control panel and a main 3D viewport.
90+
91+
**Log selector**
92+
93+
A slider at the top of the panel lets you step through all loaded ``*.icplog`` entries
94+
(filtered by ``--min-quality`` if requested at launch). Use the **Back** / **Forward** buttons
95+
for single-step navigation, or enable **Autoplay** to advance automatically at the rate set by
96+
``--autoplay-period``.
97+
98+
**3D viewport**
99+
100+
The main 3D view shows the *global* map and the *local* point cloud registered against it.
101+
The initial-guess pose and the final ICP pose can be toggled independently.
102+
103+
**ICP statistics panel**
104+
105+
Numerical outputs shown for each selected log entry:
106+
107+
- **Quality** — the ICP quality score in [0, 1] produced by the configured
108+
``QualityEvaluator`` (e.g. ``QualityEvaluator_PairedRatio``).
109+
- **Log pose** — the final estimated SE(3) pose of the local map.
110+
- **Initial guess** — the pose used to seed the ICP iteration.
111+
- **Init→Final** — the correction applied by ICP on top of the initial guess.
112+
- **Covariance / condition number** — uncertainty of the result.
113+
- **Pairings** — number of point correspondences in the last ICP iteration.
114+
115+
**Pairings visualisation**
116+
117+
Enable **Show pairings** to draw the point correspondences found at the last ICP
118+
iteration. Individual pairing types (point-to-point, point-to-plane, point-to-line,
119+
covariance-to-covariance) can be toggled independently.
120+
121+
**Filtering by quality at load time**
122+
123+
When a directory contains many log files (e.g. from a full SLAM session) it is often
124+
useful to inspect only the low-quality registrations that may have caused drift. Use
125+
``--min-quality`` to restrict the loaded set:
126+
127+
.. code-block:: bash
128+
129+
# Inspect only high-quality (≥ 80 %) registrations
130+
icp-log-viewer -d logs/ --min-quality 0.8
131+
132+
# Inspect only low-quality (< 20 %) registrations — invert by running with 0
133+
# and then sorting/filtering externally, or set a low threshold and browse manually
134+
icp-log-viewer -d logs/ --min-quality 0.0

0 commit comments

Comments
 (0)