From 6fb1db24483257b2c8f1ad8034c16120cf194e6e Mon Sep 17 00:00:00 2001 From: MichalPelka Date: Sun, 15 Nov 2026 02:00:20 +0100 Subject: [PATCH] Make skipping the first LAZ file optional load_data always dropped the points of the first LAZ file, in step 1 and in mandeye_raw_data_viewer. Add LidarOdometryParams::skip_first_file (default true, so results are unchanged) to keep them. Exposed in the step 1 TOML parameters (filter_points), the Python bindings, the step 1 settings window and the raw viewer's open menu. Co-Authored-By: Claude Opus 5.5 --- apps/lidar_odometry_step_1/lidar_odometry.cpp | 15 +++++++++------ apps/lidar_odometry_step_1/lidar_odometry_gui.cpp | 4 ++++ apps/lidar_odometry_step_1/lidar_odometry_utils.h | 1 + apps/lidar_odometry_step_1/toml_io.h | 4 +++- .../mandeye_raw_data_viewer.cpp | 5 +++++ pybind/lidar_odometry_binding.cpp | 1 + 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/apps/lidar_odometry_step_1/lidar_odometry.cpp b/apps/lidar_odometry_step_1/lidar_odometry.cpp index aab62bae8..2cfd90f58 100644 --- a/apps/lidar_odometry_step_1/lidar_odometry.cpp +++ b/apps/lidar_odometry_step_1/lidar_odometry.cpp @@ -66,9 +66,10 @@ static void write_calibration_validation(const fs::path& wdp, const std::vector< static constexpr double kLidarGapWarningS = 0.05; // Warns about gaps inside each file and between consecutive files (t_first/t_last are 0 for a file without -// points). The first file is skipped, as its points are never used. +// points). Files before first_file are skipped, as their points are never used. static void report_lidar_gaps( const std::vector& files, + size_t first_file, const std::vector>& gaps_in_file, const std::vector& t_first, const std::vector& t_last) @@ -84,7 +85,7 @@ static void report_lidar_gaps( double previous_last = 0.0; std::string previous_name; - for (size_t i = 1; i < gaps_in_file.size(); i++) + for (size_t i = first_file; i < gaps_in_file.size(); i++) { if (t_first[i] == 0.0 && t_last[i] == 0.0) continue; @@ -371,6 +372,8 @@ bool load_data( } pointsPerFile.resize(minSize); + // the first file's points are dropped unless params.skip_first_file is off + const size_t firstUsedFile = params.skip_first_file ? 1 : 0; // --- Working directories @@ -410,7 +413,7 @@ bool load_data( L.done.assign(minSize, 0); std::vector> gaps_in_file(minSize); tbb::parallel_for( - size_t(1), // upstream clears the first file's cloud after loading: it is never used + std::min(firstUsedFile, minSize), // a skipped file's cloud is never used minSize, [&](size_t i) { @@ -426,7 +429,7 @@ bool load_data( } gaps_in_file[i] = find_lidar_gaps(data, kLidarGapWarningS); }); - report_lidar_gaps(L.files, gaps_in_file, L.t_first, L.t_last); + report_lidar_gaps(L.files, firstUsedFile, gaps_in_file, L.t_first, L.t_last); if (params.save_calibration_validation && minSize > 0) // as the eager load: the first file, then dropped write_calibration_validation(wdp, L.load(0), params); size_t totalPoints = 0; @@ -472,9 +475,9 @@ bool load_data( // Store results pointsPerFile[i] = std::move(data); }); - report_lidar_gaps(laz_files, gaps_in_file, t_first, t_last); + report_lidar_gaps(laz_files, firstUsedFile, gaps_in_file, t_first, t_last); - if (pointsPerFile.size() > 0) + if (params.skip_first_file && pointsPerFile.size() > 0) pointsPerFile.front().clear(); // --- Summary diff --git a/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp b/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp index 9d5014e44..ef86ca8aa 100644 --- a/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp +++ b/apps/lidar_odometry_step_1/lidar_odometry_gui.cpp @@ -879,6 +879,10 @@ void settings_gui() return; } + ImGui::Checkbox("Skip first file", ¶ms.skip_first_file); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("drop the points of the first LAZ file during load (its IMU data is kept)"); + ImGui::PushItemWidth(ImGuiNumberWidth); ImGui::InputDouble("Filter threshold XY inner [m]", ¶ms.filter_threshold_xy_inner, 0.0, 0.0, "%.3f"); if (ImGui::IsItemHovered()) diff --git a/apps/lidar_odometry_step_1/lidar_odometry_utils.h b/apps/lidar_odometry_step_1/lidar_odometry_utils.h index a707d9266..2ed2c157f 100644 --- a/apps/lidar_odometry_step_1/lidar_odometry_utils.h +++ b/apps/lidar_odometry_step_1/lidar_odometry_utils.h @@ -80,6 +80,7 @@ struct LidarOdometryParams std::function publish_processing_head; // completed worker, never the predicted tail // filter points + bool skip_first_file = true; // drop the first LAZ file's points during load (IMU data is kept) double filter_threshold_xy_inner = 0.3; // filtering points during load double filter_threshold_xy_outer = 70.0; // filtering points during load double decimation = 0.01; // filtering points during load diff --git a/apps/lidar_odometry_step_1/toml_io.h b/apps/lidar_odometry_step_1/toml_io.h index 1002562a1..bc4d10454 100644 --- a/apps/lidar_odometry_step_1/toml_io.h +++ b/apps/lidar_odometry_step_1/toml_io.h @@ -31,6 +31,7 @@ class TomlIO { "real_time_threshold_seconds", &LidarOdometryParams::real_time_threshold_seconds }, { "lazy_load_raw_clouds", &LidarOdometryParams::lazy_load_raw_clouds }, { "points_global_spill_directory", &LidarOdometryParams::points_global_spill_directory }, + { "skip_first_file", &LidarOdometryParams::skip_first_file }, { "filter_threshold_xy_inner", &LidarOdometryParams::filter_threshold_xy_inner }, { "filter_threshold_xy_outer", &LidarOdometryParams::filter_threshold_xy_outer }, { "decimation", &LidarOdometryParams::decimation }, @@ -128,7 +129,8 @@ class TomlIO { "version_info", { "software_version", "config_version", "build_date" } }, { "performance", { "useMultithread", "real_time_threshold_seconds", "lazy_load_raw_clouds", "points_global_spill_directory" } }, { "filter_points", - { "filter_threshold_xy_inner", + { "skip_first_file", + "filter_threshold_xy_inner", "filter_threshold_xy_outer", "decimation", "threshould_output_filter", diff --git a/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp b/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp index 8513f795f..13115a6fc 100644 --- a/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp +++ b/apps/mandeye_raw_data_viewer/mandeye_raw_data_viewer.cpp @@ -91,6 +91,7 @@ std::map photo_files_ts; double filter_threshold_xy_inner = 0.0; // no filtering for raw viewing double filter_threshold_xy_outer = 300.0; // no filtering for raw viewing +bool skip_first_file = true; // as step 1: the first LAZ file's points are dropped bool fusionConventionNwu = true; bool fusionConventionEnu = false; bool fusionConventionNed = false; @@ -1015,6 +1016,7 @@ void loadFiles(std::vector input_file_names) params.lazy_load_raw_clouds = false; // the viewer shows every cloud params.filter_threshold_xy_inner = filter_threshold_xy_inner; params.filter_threshold_xy_outer = filter_threshold_xy_outer; + params.skip_first_file = skip_first_file; std::vector> pointsPerFile; Imu imu_data; @@ -1798,6 +1800,9 @@ void display() openFiles(); if (ImGui::IsItemHovered()) ImGui::SetTooltip("Select files for analyze"); + ImGui::MenuItem("Skip first file", nullptr, &skip_first_file); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Drop the points of the first LAZ file on the next load, as step 1 does"); ImGui::EndPopup(); } diff --git a/pybind/lidar_odometry_binding.cpp b/pybind/lidar_odometry_binding.cpp index 0a398ee4c..c79d609b0 100644 --- a/pybind/lidar_odometry_binding.cpp +++ b/pybind/lidar_odometry_binding.cpp @@ -54,6 +54,7 @@ PYBIND11_MODULE(lidar_odometry_py, m) // Bind LidarOdometryParams py::class_(m, "LidarOdometryParams") .def(py::init<>()) + .def_readwrite("skip_first_file", &LidarOdometryParams::skip_first_file) .def_readwrite("filter_threshold_xy_inner", &LidarOdometryParams::filter_threshold_xy_inner) .def_readwrite("filter_threshold_xy_outer", &LidarOdometryParams::filter_threshold_xy_outer) .def_readwrite("m_g", &LidarOdometryParams::m_g)