From 55f7815f0e1f568ee5176ea8a44d2dd46153f58c Mon Sep 17 00:00:00 2001 From: mwlasiuk Date: Thu, 26 Nov 2026 19:40:23 +0100 Subject: [PATCH 1/4] Remove legacy applications --- .../CMakeLists.txt | 86 - apps/lidar_odometry_step_1_legacy/icon.ico | Bin 20645 -> 0 bytes .../lidar_odometry_gui.cpp | 2835 ----------- apps/lidar_odometry_step_1_legacy/resource.h | 17 - apps/lidar_odometry_step_1_legacy/resource.rc | 54 - .../CMakeLists.txt | 79 - apps/mandeye_raw_data_viewer_legacy/icon.ico | Bin 25645 -> 0 bytes .../mandeye_raw_data_viewer.cpp | 2080 -------- .../mandeye_raw_data_viewer_legacy/resource.h | 17 - .../resource.rc | 50 - .../CMakeLists.txt | 73 - .../icon.ico | Bin 23088 -> 0 bytes .../multi_session_factor_graph.cpp | 928 ---- .../multi_session_factor_graph.h | 21 - .../multi_session_registration.cpp | 4392 ----------------- .../resource.h | 17 - .../resource.rc | 49 - .../CMakeLists.txt | 80 - .../icon.ico | Bin 22282 -> 0 bytes .../multi_view_tls_registration.cpp | 799 --- .../multi_view_tls_registration.h | 177 - .../multi_view_tls_registration_gui.cpp | 4253 ---------------- .../perform_experiment.cpp | 2428 --------- .../resource.h | 17 - .../resource.rc | 49 - 25 files changed, 18501 deletions(-) delete mode 100644 apps/lidar_odometry_step_1_legacy/CMakeLists.txt delete mode 100644 apps/lidar_odometry_step_1_legacy/icon.ico delete mode 100644 apps/lidar_odometry_step_1_legacy/lidar_odometry_gui.cpp delete mode 100644 apps/lidar_odometry_step_1_legacy/resource.h delete mode 100644 apps/lidar_odometry_step_1_legacy/resource.rc delete mode 100644 apps/mandeye_raw_data_viewer_legacy/CMakeLists.txt delete mode 100644 apps/mandeye_raw_data_viewer_legacy/icon.ico delete mode 100644 apps/mandeye_raw_data_viewer_legacy/mandeye_raw_data_viewer.cpp delete mode 100644 apps/mandeye_raw_data_viewer_legacy/resource.h delete mode 100644 apps/mandeye_raw_data_viewer_legacy/resource.rc delete mode 100644 apps/multi_session_registration_legacy/CMakeLists.txt delete mode 100644 apps/multi_session_registration_legacy/icon.ico delete mode 100644 apps/multi_session_registration_legacy/multi_session_factor_graph.cpp delete mode 100644 apps/multi_session_registration_legacy/multi_session_factor_graph.h delete mode 100644 apps/multi_session_registration_legacy/multi_session_registration.cpp delete mode 100644 apps/multi_session_registration_legacy/resource.h delete mode 100644 apps/multi_session_registration_legacy/resource.rc delete mode 100644 apps/multi_view_tls_registration_legacy/CMakeLists.txt delete mode 100644 apps/multi_view_tls_registration_legacy/icon.ico delete mode 100644 apps/multi_view_tls_registration_legacy/multi_view_tls_registration.cpp delete mode 100644 apps/multi_view_tls_registration_legacy/multi_view_tls_registration.h delete mode 100644 apps/multi_view_tls_registration_legacy/multi_view_tls_registration_gui.cpp delete mode 100644 apps/multi_view_tls_registration_legacy/perform_experiment.cpp delete mode 100644 apps/multi_view_tls_registration_legacy/resource.h delete mode 100644 apps/multi_view_tls_registration_legacy/resource.rc diff --git a/apps/lidar_odometry_step_1_legacy/CMakeLists.txt b/apps/lidar_odometry_step_1_legacy/CMakeLists.txt deleted file mode 100644 index 373979a8e..000000000 --- a/apps/lidar_odometry_step_1_legacy/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ -cmake_minimum_required(VERSION 4.0.0) - -# Legacy GLUT + legacy immediate-mode OpenGL build of step1, kept side by -# side with apps/lidar_odometry_step_1 (raylib-based since it was ported off -# GLUT), the same way step2/step3 keep their *_legacy builds. Only the GUI -# translation unit is copied: the odometry sources it builds on carry no -# GL/GLUT code, so they are compiled from apps/lidar_odometry_step_1 as-is. -project(lidar_odometry_step_1_legacy) - -set(STEP1_DIR ${REPOSITORY_DIRECTORY}/apps/lidar_odometry_step_1) - -set(SOURCES - lidar_odometry_gui.cpp - ${STEP1_DIR}/lidar_odometry_utils.cpp - ${STEP1_DIR}/lidar_odometry_utils_optimizers.cpp - ${STEP1_DIR}/lidar_odometry.cpp - ${STEP1_DIR}/points_global_spill.cpp - ${STEP1_DIR}/raw_cloud_loader.cpp - ${STEP1_DIR}/toml_io.cpp - "../../core/src/utils.cpp" -) - -# Windows: add resource file -if(WIN32) - list(APPEND SOURCES "resource.rc") -endif() - -add_executable(lidar_odometry_step_1_legacy ${SOURCES}) - -target_compile_definitions(lidar_odometry_step_1_legacy PRIVATE WITH_GUI=1) -# target_apply_hdmapping_profiler() is defined by apps/lidar_odometry_step_1. -target_apply_hdmapping_profiler(lidar_odometry_step_1_legacy) - -target_include_directories( - lidar_odometry_step_1_legacy - PRIVATE ${STEP1_DIR} - ${REPOSITORY_DIRECTORY}/core/include - ${REPOSITORY_DIRECTORY}/core_hd_mapping/include - ${THIRDPARTY_DIRECTORY} - ${THIRDPARTY_DIRECTORY}/glm - ${EIGEN3_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/tomlplusplus/include - ${THIRDPARTY_DIRECTORY}/imgui - ${THIRDPARTY_DIRECTORY}/imgui/backends - ${THIRDPARTY_DIRECTORY}/ImGuizmo - ${THIRDPARTY_DIRECTORY}/glew-cmake/include - ${FREEGLUT_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/json/include - ${THIRDPARTY_DIRECTORY}/portable-file-dialogs-master - ${LASZIP_INCLUDE_DIR}/LASzip/include - ${THIRDPARTY_DIRECTORY}/observation_equations/codes - ${THIRDPARTY_DIRECTORY}/vqf/vqf/cpp - ${THIRDPARTY_DIRECTORY}/Fusion/Fusion) - -target_link_libraries( - lidar_odometry_step_1_legacy - PRIVATE - step1_run_report - vqf - Fusion - unordered_dense::unordered_dense - spdlog::spdlog - UTL::include - OpenGL::GLU - ${FREEGLUT_LIBRARY} - ${OPENGL_gl_LIBRARY} - ${PLATFORM_LASZIP_LIB} - ${PLATFORM_MISCELLANEOUS_LIBS} - ${CORE_LIBRARIES} - ${GUI_LIBRARIES}) - -if(WIN32) - add_custom_command( - TARGET lidar_odometry_step_1_legacy - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy $ - $ - COMMAND_EXPAND_LISTS) -endif() - -if (MSVC) - target_compile_options(lidar_odometry_step_1_legacy PRIVATE /bigobj) -endif() - -hdmapping_install_app(lidar_odometry_step_1_legacy) diff --git a/apps/lidar_odometry_step_1_legacy/icon.ico b/apps/lidar_odometry_step_1_legacy/icon.ico deleted file mode 100644 index 14e651907f3c13531c15763be35ff3465b595b43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20645 zcmXV11ymbdunz9-P^>NP4#kU=;_mJ(?(R-;cemh9vEY=V#ogWA4gx8v zON)!Dx-Xq(yJg`@JcZ?+<<#=g^zKnvD2j{VemcnJ!x}9>%*i?ISoa8RS5Xk0u>VMZ zkPiA}j)d%K2ul7y#gyr`_`$-}qOIN6Z}gFSfANp;(7^9Spl_eC=|I^3_ou@mP5BuDlF$Gn!nIsnTsT!ViD^y` zjn4_=pFt&7%IfNp=H}FyJa*>iYn?kgJBsS+F__em1$nf{N=izfsi@*pQU<#NV5H^b zsJ?vBjtmr^`Ufk5_-A-{@A({Ju~=_bX#mMNIr#tv)AOmG#23&8hlM33CG}6{i}5|5 zG!XIMaVje(DB()1aYYnGD=vM(R-AY7ecUC$XVmPTDwY`@9kphk5&ps{_lb%sWc~f^ zUf1ii36=DVDsq7M)Ecbe_1@TM#_dNG0^e_1T8nIao3^WMY*tgBOB8bDYxFyJNRz(F zH-c2v)Gv>I)?D?Xu*79&`%K=4YH}K%sJFpsA~k5%S|O`TNDxrVt0*2==XD@{dU)>4=;1_~>p!1jg)Hc}5<$v;9m*QkasAa3EPw)1K&p~4)ak88k*99 zpD?|FtyEPcINP5h>Mhesx-A)FfeCTDmU-N-`JME8#kU57m^0jM-6!?!^?9V7A-=H~giAoc z0o>rO$2}6rc6krfies&CJaF8RR8~dU$(2Pv@|R zS+Dz+86t&H!b<%SwsSb{eM8J0E()AShfKYJ4V{Xa7P((;tCZ9yMAwI#ML;qR+Mst|P98EKh=ChT{cAwUM|me_$tv?FJpan{xol0>9S_tEJdwd+3U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vJ>UZS#>roxa3_+_+T(adMV`g_|A#U z^c_tK)@LMsDKm>Be0sW2rj|QtCUAf~sr;Jg0cGF!;pVqJWDok*VBIveXJs0=>;G;QQfqa^9L$>pdHgG9SF<%~zFqi~Z zbAvI8&upg=v<-L+RYez8=KI?lreG#;(&?6XsSqE%lK!Y`c`p&(r07oyiLKvTNp97* z%RBYYz~4kRg=~MWw~`&?i1{!L-YxOCW(ii|23OYNd(_A+xcL z)#NfVrb0*r0x20T1Mx@?P@B`hu_PJ+vmufs6GLDYd1^F{|BnwFDwc@v6@l-})UC_H z%d$|&e~j7w+p8_FQfQ9BNL4|HIZ`~0%kijTRYrjr3uIi$Kl0%{j+Fd>w~H627stgZ zUQ%&HIHI@F;nrK9a`dI_8hBz_#|Bx;A1$AnrU+h0#DPE*s)_HrwwgOX&wF99>BpT{ zB#V46=zvl*f{C3TH`?0TUJura>wLxj>8*7fp4B7DLt37mp7`3kpyp7)o~74j3=9mI z)zk_}V^u!T)r09kfhn(M7&=YLx-5(yI|uJU;PJiytA};vT{C>cdPRkN6Ky|89Fasc zwY0Rvk3909`&xo|<66aqFpkLuBPwtk3D|?7LOt#5?EFop$Oq}->grh!JemmVSizUU zm!-{3O{Y);5O3shqI*FC#%_Suz>A>oNZ`=nlUJg19 zemEeaqLK=lQJ)X4?5wQg&#qlUSN1?4pGh>3^O^0FnK`V!F@#mwnn))9Ty@fbBTcMy z$wCh!9Du)XR_xi8rz3$v1h1y|(Bm+5c6Lq=c|%|loaycB>&u=CEZ|1yn=`Yqxt(8Z o{^x|DPk{fKIseC7{Eul&sWtUlf1y2rD@GuU^)KlWb#8_K16F{UA^-pY diff --git a/apps/lidar_odometry_step_1_legacy/lidar_odometry_gui.cpp b/apps/lidar_odometry_step_1_legacy/lidar_odometry_gui.cpp deleted file mode 100644 index 40e1531f0..000000000 --- a/apps/lidar_odometry_step_1_legacy/lidar_odometry_gui.cpp +++ /dev/null @@ -1,2835 +0,0 @@ -#include -#include -#include -#include - -#include - -#include -#include - -#include "lidar_odometry.h" -#include "lidar_odometry_utils.h" - -#include -#include -#include -#include -#include -#include - -#include "toml_io.h" -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#include "resource.h" -#include -#endif - -/////////////////////////////////////////////////////////////////////////////////// - -// This is LiDAR odometry (step 1) -// This program calculates trajectory based on IMU and LiDAR data provided by MANDEYE mobile mapping system -// https://github.com/JanuszBedkowski/mandeye_controller The output is a session proving trajekctory and point clouds that can be further -// processed by "multi_view_tls_registration" program. - -std::string winTitle = std::string("Step 1 (Lidar odometry) ") + HDMAPPING_CONFIGURE_PROJECT_VERSION; - -std::vector infoLines = { - "This program is first step in MANDEYE process.", - "", - "It results trajectory and point clouds as single session for 'multi_view_tls_registration_step_2' program.", - "", - "Next step will be to load session.json file with 'multi_view_tls_registration_step_2' program." -}; - -// App specific shortcuts (Type and Shortcut are just for easy reference) -static const std::vector appShortcuts = { { "Normal keys", "A", "" }, - { "", "Ctrl+A", "" }, - { "", "B", "" }, - { "", "Ctrl+B", "" }, - { "", "C", "" }, - { "", "Ctrl+C", "" }, - { "", "D", "" }, - { "", "Ctrl+D", "" }, - { "", "E", "" }, - { "", "Ctrl+E", "" }, - { "", "F", "" }, - { "", "Ctrl+F", "" }, - { "", "G", "" }, - { "", "Ctrl+G", "" }, - { "", "H", "" }, - { "", "Ctrl+H", "" }, - { "", "I", "" }, - { "", "Ctrl+I", "" }, - { "", "J", "" }, - { "", "Ctrl+K", "" }, - { "", "K", "" }, - { "", "Ctrl+K", "" }, - { "", "L", "" }, - { "", "Ctrl+L", "" }, - { "", "M", "" }, - { "", "Ctrl+M", "" }, - { "", "N", "" }, - { "", "Ctrl+N", "" }, - { "", "O", "" }, - { "", "Ctrl+O", "Open data" }, - { "", "P", "" }, - { "", "Ctrl+P", "" }, - { "", "Q", "" }, - { "", "Ctrl+Q", "" }, - { "", "R", "" }, - { "", "Ctrl+R", "" }, - { "", "Shift+R", "" }, - { "", "S", "" }, - { "", "Ctrl+S", "" }, - { "", "Ctrl+Shift+S", "" }, - { "", "T", "" }, - { "", "Ctrl+T", "" }, - { "", "U", "" }, - { "", "Ctrl+U", "" }, - { "", "V", "" }, - { "", "Ctrl+V", "" }, - { "", "W", "" }, - { "", "Ctrl+W", "" }, - { "", "X", "" }, - { "", "Ctrl+X", "" }, - { "", "Y", "" }, - { "", "Ctrl+Y", "" }, - { "", "Z", "" }, - { "", "Ctrl+Z", "" }, - { "", "Shift+Z", "" }, - { "", "1-9", "" }, - { "Special keys", "Up arrow", "" }, - { "", "Shift + up arrow", "" }, - { "", "Ctrl + up arrow", "" }, - { "", "Down arrow", "" }, - { "", "Shift + down arrow", "" }, - { "", "Ctrl + down arrow", "" }, - { "", "Left arrow", "" }, - { "", "Shift + left arrow", "" }, - { "", "Ctrl + left arrow", "" }, - { "", "Right arrow", "" }, - { "", "Shift + right arrow", "" }, - { "", "Ctrl + right arrow", "" }, - { "", "Pg down", "" }, - { "", "Pg up", "" }, - { "", "- key", "" }, - { "", "+ key", "" }, - { "Mouse related", "Left click + drag", "" }, - { "", "Right click + drag", "n" }, - { "", "Scroll", "" }, - { "", "Shift + scroll", "" }, - { "", "Shift + drag", "" }, - { "", "Ctrl + left click", "" }, - { "", "Ctrl + right click", "" }, - { "", "Ctrl + middle click", "" } }; - -namespace fs = std::filesystem; - -bool is_settings_gui = false; -bool full_debug_messages = false; -NDT ndt; -bool show_reference_buckets_indoor = false; -bool show_reference_buckets_outdoor = false; -bool show_reference_points = false; -int dec_reference_points = 100; -bool show_initial_points = true; -bool show_trajectory = true; -bool show_trajectory_as_axes = false; -bool show_prediction_vectors = false; -bool intermediate_trajectory_prediction_axes = false; -bool show_covs_indoor = false; -bool show_covs_outdoor = false; -int dec_covs = 10; -bool simple_gui = true; -bool step_1_done = false; -bool step_2_done = false; -bool step_3_done = false; -bool calculations_failed = false; -bool show_without_filtered_buckets = false; -bool show_normal_vectors_indoor = false; -bool show_normal_vectors_outdoor = false; - -int lastPar = 1; - -std::vector worker_data; - -std::string working_directory = ""; -bool initial_transformation_gizmo = false; - -float m_gizmo[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; - -float x_displacement = 0.01; - -int index_begin = -1; -int index_end = -1; -bool gizmo_stretch_interval = false; -Eigen::Affine3d stretch_gizmo_m = Eigen::Affine3d::Identity(); - -LidarOdometryParams params; -std::vector csv_files; -std::vector sn_files; -std::string imuSnToUse; -Session session; - -std::vector> pointsPerFile; -Imu imu_data; -Trajectory trajectory; -std::atomic loRunning{ false }; -std::atomic loProgress{ 0.0 }; -std::atomic loPause{ false }; -std::chrono::time_point loStartTime; -std::atomic loElapsedSeconds{ 0.0 }; -std::atomic loEstimatedTimeRemaining{ 0.0 }; - -fs::path outwd; - -#if _WIN32 -#define DEFAULT_PATH "C:\\" -#else -#define DEFAULT_PATH "~" -#endif - -/////////////////////////////////////////////////////////////////////////////////// - -void set_lidar_odometry_default_params(LidarOdometryParams& params) -{ - params.decimation = 0.01; - params.in_out_params_indoor.resolution_X = 0.1; - params.in_out_params_indoor.resolution_Y = 0.1; - params.in_out_params_indoor.resolution_Z = 0.1; - - params.in_out_params_outdoor.resolution_X = 0.3; - params.in_out_params_outdoor.resolution_Y = 0.3; - params.in_out_params_outdoor.resolution_Z = 0.3; - - params.filter_threshold_xy_inner = 0.3; - params.filter_threshold_xy_outer = 70.0; - params.threshould_output_filter = 0.3; - - params.use_robust_and_accurate_lidar_odometry = false; - params.distance_bucket = 0.2; - params.polar_angle_deg = 10.0; - params.azimutal_angle_deg = 10.0; - params.robust_and_accurate_lidar_odometry_iterations = 20; - - params.max_distance_lidar = 70.0; - params.nr_iter = 1000; - params.sliding_window_trajectory_length_threshold = 200; - params.real_time_threshold_seconds = 10; -} - -// Helper function to format time in human-readable format -std::string formatTime(double seconds) -{ - if (seconds < 0) - return "Calculating..."; - - int hours = static_cast(seconds / 3600); - int minutes = static_cast((seconds - hours * 3600) / 60); - int secs = static_cast(seconds - hours * 3600 - minutes * 60); - - std::ostringstream oss; - - if (hours > 0) - { - oss << std::setw(2) << std::setfill('0') << hours << "h "; - } - if (minutes > 0 || hours > 0) - { - oss << std::setw(2) << std::setfill('0') << minutes << "m "; - } - - oss << std::setw(2) << std::setfill('0') << secs << "s"; - - return oss.str(); -} - -// Helper function to format estimated completion time -std::string formatCompletionTime(double remainingSeconds) -{ - if (remainingSeconds < 0) - return "Calculating..."; - - auto now = std::chrono::system_clock::now(); - auto estimatedCompletion = now + std::chrono::seconds(static_cast(remainingSeconds)); - auto completion_time_t = std::chrono::system_clock::to_time_t(estimatedCompletion); - - // Format as HH:MM:SS - Cross-platform time formatting - struct tm completion_tm; -#ifdef _WIN32 - localtime_s(&completion_tm, &completion_time_t); -#else - localtime_r(&completion_time_t, &completion_tm); -#endif - - char timeStr[32]; - strftime(timeStr, sizeof(timeStr), "%H:%M", &completion_tm); - - return std::string(timeStr); -} - -#if 0 -std::vector> get_batches_of_points(std::string laz_file, int point_count_threshold, conststd::vector& prev_points) -{ - std::vector> res_points; - std::vector points = load_point_cloud(laz_file, false, 0, 10000, {}); - - std::vector tmp_points = prev_points; - int counter = tmp_points.size(); - for (size_t i = 0; i < points.size(); i++) - { - counter++; - tmp_points.push_back(points[i]); - if (counter > point_count_threshold) - { - res_points.push_back(tmp_points); - tmp_points.clear(); - counter = 0; - } - } - - if (tmp_points.size() > 0) - { - res_points.push_back(tmp_points); - } - return res_points; -} -#endif - -void find_best_stretch( - std::vector points, std::vector timestamps, std::vector poses, std::string fn1, std::string fn2) -{ - for (size_t i = 0; i < points.size(); i++) - { - auto lower = std::lower_bound(timestamps.begin(), timestamps.end(), points[i].timestamp); - points[i].index_pose = std::distance(timestamps.begin(), lower); - } - - std::set indexes; - - for (size_t i = 0; i < points.size(); i++) - { - indexes.insert(points[i].index_pose); - } - // build trajectory - std::vector trajectory; - std::vector ts; - - for (auto& s : indexes) - { - trajectory.push_back(poses[s]); - ts.push_back(timestamps[s]); - } - - std::cout << "trajectory.size() " << trajectory.size() << std::endl; - // Sleep(2000); - - std::vector points_reindexed = points; - for (size_t i = 0; i < points_reindexed.size(); i++) - { - points_reindexed[i].index_pose = get_index_in_set(indexes, points[i].index_pose); - } - /// - std::vector best_trajectory = trajectory; - uint64_t min_buckets = ULLONG_MAX; - - for (double x = 0.0; x < 0.2; x += 0.0005) - { - std::vector trajectory_stretched; - - Eigen::Affine3d m_x_offset = Eigen::Affine3d::Identity(); - m_x_offset(0, 3) = x; - - Eigen::Affine3d m = trajectory[0]; - trajectory_stretched.push_back(m); - for (size_t i = 1; i < trajectory.size(); i++) - { - Eigen::Affine3d m_update = trajectory[i - 1].inverse() * trajectory[i] * (m_x_offset); - m = m * m_update; - trajectory_stretched.push_back(m); - } - - NDT::GridParameters rgd_params; - rgd_params.resolution_X = 0.3; - rgd_params.resolution_Y = 0.3; - rgd_params.resolution_Z = 0.3; - NDTBucketMapType my_buckets; - - std::vector points_global = points_reindexed; - - std::vector points_global2; - - for (auto& p : points_global) - { - if (p.point.z() > 0) - { - p.point = trajectory_stretched[p.index_pose] * p.point; - points_global2.push_back(p); - // if (p.point.norm() > 6 && p.point.norm() < 15) - //{ - // points_global.push_back(p); - // } - } - } - std::scoped_lock lock(params.mutex_buckets_indoor, params.mutex_buckets_outdoor); - - update_rgd(rgd_params, my_buckets, points_global2, trajectory_stretched[0].translation()); - - std::cout << "number of buckets [" << x << "]: " << my_buckets.size() << std::endl; - if (my_buckets.size() < min_buckets) - { - min_buckets = my_buckets.size(); - best_trajectory = trajectory_stretched; - } - } - - std::map trajectory_for_interpolation; - for (size_t i = 0; i < best_trajectory.size(); i++) - { - trajectory_for_interpolation[ts[i]] = best_trajectory[i].matrix(); - } - - std::vector pointcloud_global; - std::vector intensity; - std::vector timestamps_; - for (const auto& p : points_reindexed) - { - Eigen::Matrix4d pose = getInterpolatedPose(trajectory_for_interpolation, p.timestamp); - Eigen::Affine3d b; - b.matrix() = pose; - Eigen::Vector3d vec = b * p.point; - pointcloud_global.push_back(vec); - intensity.push_back(p.intensity); - timestamps_.push_back(p.timestamp); - } - - std::cout << "saving file: " << fn1 << std::endl; - exportLaz(fn1, pointcloud_global, intensity, timestamps_); - - pointcloud_global.clear(); - for (const auto& p : points_reindexed) - { - Eigen::Vector3d vec = trajectory[p.index_pose] * p.point; - pointcloud_global.push_back(vec); - } - exportLaz(fn2, pointcloud_global, intensity, timestamps_); -} - -#if 0 -void alternative_approach() -{ - int point_count_threshold = 10000; - - std::cout << "aternative_approach" << std::endl; - - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load las files", {}, true); - std::sort(std::begin(input_file_names), std::end(input_file_names)); - - std::vector csv_files; - std::vector laz_files; - std::for_each(std::begin(input_file_names), std::end(input_file_names), [&](const std::string& fileName) - { - if (fileName.ends_with(".laz") || fileName.ends_with(".las")) - { - laz_files.push_back(fileName); - } - if (fileName.ends_with(".csv")) - { - csv_files.push_back(fileName); - } }); - - std::cout << "imu files: " << std::endl; - for (const auto& fn : csv_files) - { - std::cout << fn << std::endl; - } - - std::cout << "loading imu" << std::endl; - Imu imu_data; - - std::for_each(std::begin(csv_files), std::end(csv_files), [&imu_data](const std::string& fn) - { - auto imu = load_imu(fn.c_str(), 0); - std::cout << fn << std::endl; - imu_data.insert(std::end(imu_data), std::begin(imu), std::end(imu)); }); - - std::map trajectory; - int counter = 1; - const float RAD_TO_DEG = 180.0f / static_cast(M_PI); - - if (params.use_vqf) - { - double avg_dt = 1.0 / 200.0; - if (imu_data.size() >= 2) - { - double t0 = std::get<0>(imu_data.front()).first; - double t1 = std::get<0>(imu_data.back()).first; - if (t1 > t0) - avg_dt = (t1 - t0) / static_cast(imu_data.size() - 1); - } - - VQFParams vqf_params = buildVQFParams(params); - VQF vqf(vqf_params, avg_dt); - - for (const auto& [timestamp_pair, gyr, acc] : imu_data) - { - const double g = 9.80665; - vqf_real_t gyr_vqf[3] = { static_cast(gyr.x()), static_cast(gyr.y()), static_cast(gyr.z()) }; - vqf_real_t acc_vqf[3] = { static_cast(acc.x()) * g, static_cast(acc.y()) * g, static_cast(acc.z()) * g }; - - vqf.update(gyr_vqf, acc_vqf); - - vqf_real_t quat[4]; - if (params.vqf_useMagnetometer) - vqf.getQuat9D(quat); - else - vqf.getQuat6D(quat); - Eigen::Quaterniond d(quat[0], quat[1], quat[2], quat[3]); - Eigen::Affine3d t{ Eigen::Matrix4d::Identity() }; - t.rotate(d); - trajectory[timestamp_pair.first] = t.matrix(); - counter++; - if (counter % 100 == 0) - { - Eigen::Vector3d euler = d.toRotationMatrix().eulerAngles(0, 1, 2) * (180.0 / M_PI); - std::cout << "Roll " << euler.x() << ", Pitch " << euler.y() << ", Yaw " << euler.z() << " [" << counter << " of " << imu_data.size() << "]" << std::endl; - } - } - } - else - { - FusionAhrs ahrs; - FusionAhrsInitialise(&ahrs); - if (params.fusionConventionNwu) ahrs.settings.convention = FusionConventionNwu; - else if (params.fusionConventionEnu) ahrs.settings.convention = FusionConventionEnu; - else if (params.fusionConventionNed) ahrs.settings.convention = FusionConventionNed; - ahrs.settings.gain = params.fusion_gain; - - bool first = true; - double last_ts = 0.0; - - for (const auto& [timestamp_pair, gyr, acc] : imu_data) - { - const FusionVector gyroscope = { static_cast(gyr.x() * RAD_TO_DEG), - static_cast(gyr.y() * RAD_TO_DEG), - static_cast(gyr.z() * RAD_TO_DEG) }; - const FusionVector accelerometer = { acc.x(), acc.y(), acc.z() }; - - if (first) - { - FusionAhrsUpdateNoMagnetometer(&ahrs, gyroscope, accelerometer, 1.0f / 200.0f); - first = false; - } - else - { - float ts_diff = static_cast(timestamp_pair.first - last_ts); - if (ts_diff < 0.01f) - FusionAhrsUpdateNoMagnetometer(&ahrs, gyroscope, accelerometer, ts_diff); - else - FusionAhrsUpdateNoMagnetometer(&ahrs, gyroscope, accelerometer, 1.0f / 200.0f); - } - last_ts = timestamp_pair.first; - - FusionQuaternion quat = FusionAhrsGetQuaternion(&ahrs); - Eigen::Quaterniond d{ quat.element.w, quat.element.x, quat.element.y, quat.element.z }; - Eigen::Affine3d t{ Eigen::Matrix4d::Identity() }; - t.rotate(d); - trajectory[timestamp_pair.first] = t.matrix(); - counter++; - if (counter % 100 == 0) - { - const FusionEuler euler = FusionQuaternionToEuler(quat); - std::cout << "Roll " << euler.angle.roll << ", Pitch " << euler.angle.pitch << ", Yaw " << euler.angle.yaw - << " [" << counter << " of " << imu_data.size() << "]" << std::endl; - } - } - } - - /////////////////////////////////////////////////////////////////////////////// - std::cout << "point cloud file names" << std::endl; - for (const auto& fn : laz_files) - { - std::cout << fn << std::endl; - } - - std::vector prev_points; - std::vector> all_points; - std::vector> tmp_points = get_batches_of_points(laz_files[0], point_count_threshold, prev_points); - - for (size_t i = 0; i < tmp_points.size() - 1; i++) - { - all_points.push_back(tmp_points[i]); - } - - for (size_t i = 1; i < laz_files.size(); i++) - { - prev_points = tmp_points[tmp_points.size() - 1]; - tmp_points = get_batches_of_points(laz_files[i], point_count_threshold, prev_points); - for (size_t j = 0; j < tmp_points.size() - 1; j++) - { - all_points.push_back(tmp_points[j]); - } - } - - ////////// - std::vector timestamps; - std::vector poses; - for (const auto& t : trajectory) - { - timestamps.push_back(t.first); - Eigen::Affine3d m; - m.matrix() = t.second; - poses.push_back(m); - } - - for (size_t i = 0; i < all_points.size(); i++) - { - std::cout << all_points[i].size() << std::endl; - std::string fn1 = "C:/data/tmp/" + std::to_string(i) + "_best.laz"; - std::string fn2 = "C:/data/tmp/" + std::to_string(i) + "_original.laz"; - - find_best_stretch(all_points[i], timestamps, poses, fn1, fn2); - } -} -#endif - -Eigen::Vector3d GLWidgetGetOGLPos(int x, int y, const ObservationPicking& observation_picking) -{ - const auto laser_beam = GetLaserBeam(x, y); - - RegistrationPlaneFeature::Plane pl; - - pl.a = 0; - pl.b = 0; - pl.c = 1; - pl.d = -observation_picking.picking_plane_height; - - Eigen::Vector3d pos = rayIntersection(laser_beam, pl); - - std::cout << "intersection: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl; - - return pos; -} - -void step1(const std::atomic& loPause) -{ - std::string input_folder_name; - std::vector input_file_names; - input_folder_name = mandeye::fd::SelectFolder("Select Mandeye data folder"); - - std::cout << "Selected folder: '" << input_folder_name << std::endl; - - if (fs::exists(input_folder_name)) - { - std::string newTitle = winTitle + " - ..\\" + std::filesystem::path(input_folder_name).filename().string(); - glutSetWindowTitle(newTitle.c_str()); - - for (const auto& entry : fs::directory_iterator(input_folder_name)) - if (entry.is_regular_file()) - input_file_names.push_back(entry.path().string()); - - if (load_data(input_file_names, params, pointsPerFile, imu_data, full_debug_messages)) - { - working_directory = fs::path(input_file_names[0]).parent_path().string(); - calculate_trajectory(trajectory, imu_data, params, full_debug_messages); - if (compute_step_1(pointsPerFile, params, trajectory, worker_data, loPause)) - { - release_raw_clouds(pointsPerFile, params); // nothing after step 1 reads them - step_1_done = true; - } - else - std::cerr << "Lidar odometry step 1 failed (see the messages above)" << std::endl; - } - else - { - std::string message_info = "Problem with loading data from folder '" + input_folder_name + - "' (Pease check if folder exists). Program will close once You click OK!!!"; - std::cout << message_info << std::endl; - [[maybe_unused]] pfd::message message("Information", message_info.c_str(), pfd::choice::ok, pfd::icon::info); - message.result(); - - exit(1); - } - } -} - -void step2(const std::atomic& loPause) -{ - double ts_failure = 0.0; - std::atomic parked{ false }; - if (compute_step_2(worker_data, params, ts_failure, loProgress, loPause, full_debug_messages, parked)) - step_2_done = true; - else - { - for (size_t fileNo = 0; fileNo < csv_files.size(); fileNo++) - { - const std::string& imufn = csv_files.at(fileNo); - const std::string snFn = (fileNo >= sn_files.size()) ? ("") : (sn_files.at(fileNo)); - const auto idToSn = MLvxCalib::GetIdToSnMapping(snFn); - // GetId of Imu to use - int imuNumberToUse = MLvxCalib::GetImuIdToUse(idToSn, imuSnToUse); - auto imu = load_imu(imufn.c_str(), imuNumberToUse); - - if (imu.size() > 0) - { - if (std::get<0>(imu[imu.size() - 1]).first > ts_failure) - break; - } - std::cout << "file: '" << imufn << "' [OK]" << std::endl; - } - calculations_failed = true; - } -} - -void save_results(bool info, double elapsed_seconds) -{ - outwd = get_next_result_path(working_directory); - save_result(worker_data, params, outwd, elapsed_seconds); - if (info) - { - std::string message_info = "Results saved to folder: '" + outwd.string() + "'"; - std::cout << message_info << std::endl; - [[maybe_unused]] pfd::message message("Information", message_info.c_str(), pfd::choice::ok, pfd::icon::info); - message.result(); - } -} - -void settings_gui() -{ - if (ImGui::Begin("Settings", &is_settings_gui)) - { - ImGui::Checkbox("simple_gui", &simple_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show even more parameters"); - - ImGui::NewLine(); - - if (!loRunning) - { - // TaitBryanPose motion_model_correction; - ImGui::Text("motion_model_correction [deg]:"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("om, rotation via X", ¶ms.motion_model_correction.om); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - ImGui::InputDouble("fi, rotation via Y", ¶ms.motion_model_correction.fi); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - ImGui::InputDouble("ka, rotation via Z", ¶ms.motion_model_correction.ka); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - ImGui::PopItemWidth(); - - if (ImGui::Button("Set example")) - { - params.motion_model_correction.om = 0.0; - params.motion_model_correction.fi = 0.05; - params.motion_model_correction.ka = 0.0; - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("motion_model_corrections for LiDAR X-axis (forward direction)"); - - ImGui::NewLine(); - - ImGui::Text("lidar_odometry_motion_model sigmas [m] / [deg]:"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("position/rotational uncertainties"); - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("x_1", ¶ms.lidar_odometry_motion_model_x_1_sigma_m, 0.0, 0.0, "%.4f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("om_1", ¶ms.lidar_odometry_motion_model_om_1_sigma_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - - ImGui::InputDouble("y_1", ¶ms.lidar_odometry_motion_model_y_1_sigma_m, 0.0, 0.0, "%.4f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("fi_1", ¶ms.lidar_odometry_motion_model_fi_1_sigma_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - - ImGui::InputDouble("z_1", ¶ms.lidar_odometry_motion_model_z_1_sigma_m, 0.0, 0.0, "%.4f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::SameLine(); - ImGui::InputDouble("ka_1", ¶ms.lidar_odometry_motion_model_ka_1_sigma_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - - ImGui::PopItemWidth(); - - ImGui::Text("lidar_odometry_motion_model_fix_origin sigmas [m] / [deg]:"); - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("x_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_x_1_sigma_m); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("om_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_om_1_sigma_deg); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - - ImGui::InputDouble("y_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_y_1_sigma_m); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("fi_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_fi_1_sigma_deg); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - - ImGui::InputDouble("z_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_z_1_sigma_m); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::SameLine(); - ImGui::InputDouble("ka_1##o", ¶ms.lidar_odometry_motion_model_fix_origin_ka_1_sigma_deg); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - - ImGui::PopItemWidth(); - } - - ImGui::NewLine(); - - if (!simple_gui) - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Threshold nr poses", ¶ms.threshold_nr_poses); - if (params.threshold_nr_poses < 1) - { - params.threshold_nr_poses = 1; - } - - ImGui::NewLine(); - } - - // ImGui::Checkbox("show_all_points", &show_all_points); - - if (calculations_failed) - { - ImGui::Text("CALCULATIONS FAILED... please read information in console"); - ImGui::End(); - return; - } - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("Filter threshold XY inner [m]", ¶ms.filter_threshold_xy_inner, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("all local points inside lidar xy_circle radius will be removed during load"); - ImGui::Text("Minimum value is given by Lidar's specs (Close Proximity Blind Zone)"); - ImGui::Text("Value can be higher to filter out close range permanent obstacles"); - ImGui::Text("e.g.: 0.1[m] for Livox Mid-360"); - ImGui::EndTooltip(); - } - ImGui::InputDouble("Filter threshold XY outer [m]", ¶ms.filter_threshold_xy_outer, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("all local points outside lidar xy_circle radius will be removed during load"); - ImGui::Text("Maximum value is given by Lidar's specs (Detection Range)"); - ImGui::Text("Value can be lower to adapt for different reflectivity or real world contrains"); - ImGui::Text("e.g.: 70[m] @ 80%% reflectivity for Livox Mid-360"); - ImGui::EndTooltip(); - } - ImGui::InputDouble("Threshold output filter [m]", ¶ms.threshould_output_filter, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("all local points inside lidar xy_circle radius will be removed during save"); - ImGui::PopItemWidth(); - - if (!simple_gui) - { - ImGui::NewLine(); - ImGui::Text("NDT bucket size (inner/outer)"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("##x", ¶ms.in_out_params_indoor.resolution_X, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - if (params.in_out_params_indoor.resolution_X < 0.01) - { - params.in_out_params_indoor.resolution_X = 0.01; - } - ImGui::SameLine(); - ImGui::InputDouble("X##ndt", ¶ms.in_out_params_outdoor.resolution_X, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - if (params.in_out_params_outdoor.resolution_X < 0.01) - { - params.in_out_params_outdoor.resolution_X = 0.01; - } - - ImGui::InputDouble("##y", ¶ms.in_out_params_indoor.resolution_Y, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - if (params.in_out_params_indoor.resolution_Y < 0.01) - { - params.in_out_params_indoor.resolution_Y = 0.01; - } - ImGui::SameLine(); - ImGui::InputDouble("Y##ndt", ¶ms.in_out_params_outdoor.resolution_Y, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - if (params.in_out_params_outdoor.resolution_Y < 0.01) - { - params.in_out_params_outdoor.resolution_Y = 0.01; - } - - ImGui::InputDouble("##z", ¶ms.in_out_params_indoor.resolution_Z, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - if (params.in_out_params_indoor.resolution_Z < 0.01) - { - params.in_out_params_indoor.resolution_Z = 0.01; - } - ImGui::SameLine(); - ImGui::InputDouble("Z##ndt", ¶ms.in_out_params_outdoor.resolution_Z, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - if (params.in_out_params_outdoor.resolution_Z < 0.01) - { - params.in_out_params_outdoor.resolution_Z = 0.01; - } - - ImGui::NewLine(); - - ImGui::InputDouble("Downsampling", ¶ms.decimation, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Larger value of downsampling better performance, but worse accuracy"); - - ImGui::InputDouble("Max distance of processed points [m]", ¶ms.max_distance_lidar, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Local LiDAR coordinates"); - - ImGui::InputInt("Number of iterations", ¶ms.nr_iter); - ImGui::InputDouble( - "Sliding window trajectory length threshold [m]", ¶ms.sliding_window_trajectory_length_threshold, 0.0, 0.0, "%.2f"); - ImGui::InputInt("Threshold initial points", ¶ms.threshold_initial_points); - - ImGui::NewLine(); - - // AHRS type selection - ImGui::Checkbox("Use VQF (instead of Fusion/Madgwick)", ¶ms.use_vqf); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Unchecked = Fusion (Madgwick complementary filter, default)\nChecked = VQF (Versatile Quaternion-based Filter)"); - - if (!params.use_vqf) - { - // Fusion-specific parameters - static int fusionConvention; // 0=NWU, 1=ENU, 2=NED - if (fusionConvention < 0 || fusionConvention > 2) - fusionConvention = 0; - - ImGui::Text("Fusion convention: "); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Coordinate system conventions for sensor fusion defining how the axes are oriented relative to world frame"); - - ImGui::SameLine(); - ImGui::RadioButton("NWU", &fusionConvention, 0); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("North West Up"); - ImGui::SameLine(); - ImGui::RadioButton("ENU", &fusionConvention, 1); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("East North Up"); - ImGui::SameLine(); - ImGui::RadioButton("NED", &fusionConvention, 2); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("North East Down"); - - params.fusionConventionNwu = (fusionConvention == 0); - params.fusionConventionEnu = (fusionConvention == 1); - params.fusionConventionNed = (fusionConvention == 2); - - ImGui::InputDouble("Fusion gain", ¶ms.fusion_gain, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Complementary filter gain (0-1). Higher = more accelerometer trust."); - } - - ImGui::NewLine(); - - ImGui::Checkbox("Use motion from previous step", ¶ms.use_motion_from_previous_step); - ImGui::Checkbox("Lidar-only odometry (no IMU)", ¶ms.lidar_only_odometry); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Predict each window's rotation and translation from the previous one (constant velocity) instead of from " - "the IMU. For recordings without a usable IMU, e.g. a synthetic stationary one."); - ImGui::Checkbox("Use IMU preintegration", ¶ms.use_imu_preintegration); - if (params.use_imu_preintegration) - { - const char* methods[] = { "Euler, no gravity comp., SM velocity", "Trapezoidal, no gravity comp., SM velocity", - "Euler, gravity comp., SM velocity", "Trapezoidal, gravity comp., SM velocity", - "Kalman, gravity comp., SM velocity", "Euler, gravity comp., AHRS velocity", - "Trapezoidal, gravity comp., AHRS velocity", "Kalman, gravity comp., AHRS velocity" }; - ImGui::Combo("IMU preintegration method", ¶ms.imu_preintegration_method, methods, IM_ARRAYSIZE(methods)); - } - if (params.use_vqf) - { - ImGui::InputDouble("VQF tauAcc [s]", ¶ms.vqf_tauAcc, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("VQF accelerometer time constant (tauAcc) in seconds."); - ImGui::Text("Controls how strongly accelerometer corrects the gyroscope-based orientation."); - ImGui::Text("Higher = more gyro trust (stable but may drift). Lower = more acc trust (noisy but no drift)."); - ImGui::EndTooltip(); - } - - if (ImGui::TreeNode("VQF Gyro Bias Estimation")) - { - ImGui::Checkbox("Motion bias estimation", ¶ms.vqf_motionBiasEstEnabled); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Enables gyroscope bias estimation during motion phases,\nbased on the inclination correction only (without " - "magnetometer)."); - - if (params.vqf_motionBiasEstEnabled) - { - ImGui::InputDouble("Bias sigma motion [deg/s]", ¶ms.vqf_biasSigmaMotion, 0.0, 0.0, "%.4f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Std dev of converged bias estimation uncertainty during motion.\nDetermines trust on motion bias " - "estimation " - "updates.\nSmall value leads to fast convergence. Default: 0.1"); - ImGui::InputDouble("Bias vertical forgetting", ¶ms.vqf_biasVerticalForgettingFactor, 0.0, 0.0, "%.6f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Forgetting factor for unobservable bias in vertical direction during motion.\nGyro bias is not observable " - "vertically without magnetometer.\nRelative weight of artificial zero measurement ensuring\nbias estimate " - "decays to zero. Default: 0.0001"); - } - - ImGui::InputDouble("Bias sigma init [deg/s]", ¶ms.vqf_biasSigmaInit, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Std dev of the initial bias estimation uncertainty. Default: 0.5 deg/s"); - ImGui::InputDouble("Bias forgetting time [s]", ¶ms.vqf_biasForgettingTime, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time in which bias estimation uncertainty increases from 0 to 0.1 deg/s.\nDetermines the system noise assumed " - "by " - "the Kalman filter. Default: 100.0"); - ImGui::InputDouble("Bias clip [deg/s]", ¶ms.vqf_biasClip, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Maximum expected gyroscope bias.\nUsed to clip bias estimate and measurement error in update step.\nAlso used " - "by " - "rest detection to not regard large constant angular rate as rest.\nDefault: 2.0"); - - ImGui::Checkbox("Rest bias estimation", ¶ms.vqf_restBiasEstEnabled); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Enables rest detection and gyroscope bias estimation during rest phases.\nDuring rest, gyro bias is estimated " - "from low-pass filtered gyro readings."); - - if (params.vqf_restBiasEstEnabled) - { - ImGui::InputDouble("Bias sigma rest [deg/s]", ¶ms.vqf_biasSigmaRest, 0.0, 0.0, "%.4f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Std dev of converged bias estimation uncertainty during rest.\nDetermines trust on rest bias estimation " - "updates.\nSmall value leads to fast convergence. Default: 0.03"); - ImGui::InputDouble("Rest min time [s]", ¶ms.vqf_restMinT, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time threshold for rest detection.\nRest is detected when measurements have been close to\nthe low-pass " - "filtered reference for the given time. Default: 1.5"); - ImGui::InputDouble("Rest filter tau [s]", ¶ms.vqf_restFilterTau, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time constant for the second-order Butterworth low-pass filter\nused to obtain the reference for rest " - "detection. Default: 0.5"); - ImGui::InputDouble("Rest threshold gyro [deg/s]", ¶ms.vqf_restThGyr, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Angular velocity threshold for rest detection.\nDeviation norm between measurement and reference must be " - "below threshold.\nEach component must also be below biasClip. Default: 2.0"); - ImGui::InputDouble("Rest threshold acc [m/s2]", ¶ms.vqf_restThAcc, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Acceleration threshold for rest detection.\nDeviation norm between measurement and reference must be " - "below threshold.\nDefault: 0.5"); - } - - ImGui::TreePop(); - } - - ImGui::Checkbox("Use magnetometer", ¶ms.vqf_useMagnetometer); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Enable 9D mode (gyro+acc+mag) for absolute heading correction.\nDefault: off (6D mode, gyro+acc only, heading " - "from " - "gyro integration)."); - - if (params.vqf_useMagnetometer && ImGui::TreeNode("VQF Magnetometer")) - { - ImGui::InputDouble("tauMag [s]", ¶ms.vqf_tauMag, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time constant for magnetometer update.\nSmall values imply trust on magnetometer, large values trust on " - "gyroscope.\nCorresponds to cutoff frequency of first-order LP filter\nfor heading correction. Default: 9.0"); - ImGui::Checkbox("Mag disturbance rejection", ¶ms.vqf_magDistRejectionEnabled); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Enables magnetic disturbance detection and rejection.\nFor short disturbances, mag correction is fully " - "disabled.\nFor long disturbances (>magMaxRejectionTime), correction uses\nincreased time constant " - "(magRejectionFactor)."); - ImGui::InputDouble("Mag current tau [s]", ¶ms.vqf_magCurrentTau, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time constant for current norm/dip value in disturbance detection.\nFast LP filter for robustness with noisy " - "or " - "async mag measurements.\nSet to -1 to disable. Default: 0.05"); - ImGui::InputDouble("Mag ref tau [s]", ¶ms.vqf_magRefTau, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Time constant for adjustment of the magnetic field reference.\nAllows reference to converge to observed " - "undisturbed field. Default: 20.0"); - ImGui::InputDouble("Mag norm threshold", ¶ms.vqf_magNormTh, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Relative threshold for magnetic field strength for disturbance detection.\nRelative to the reference norm. " - "Default: 0.1 (10%%)"); - ImGui::InputDouble("Mag dip threshold [deg]", ¶ms.vqf_magDipTh, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Threshold for the magnetic field dip angle for disturbance detection. Default: 10.0"); - ImGui::InputDouble("Mag new time [s]", ¶ms.vqf_magNewTime, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Duration after which to accept a different homogeneous magnetic field.\nNew reference accepted when within " - "magNormTh and magDipTh for this time.\nOnly phases with sufficient movement (magNewMinGyr) count. Default: " - "20.0"); - ImGui::InputDouble("Mag new first time [s]", ¶ms.vqf_magNewFirstTime, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Duration after which to accept a homogeneous magnetic field for the first time.\nUsed instead of magNewTime " - "when " - "no current estimate exists,\nto allow faster initial reference acquisition. Default: 5.0"); - ImGui::InputDouble("Mag new min gyro [deg/s]", ¶ms.vqf_magNewMinGyr, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Minimum angular velocity needed to count time for new mag field acceptance.\nPeriods with angular velocity " - "norm " - "below this threshold\ndo not count towards magNewTime. Default: 20.0"); - ImGui::InputDouble("Mag min undisturbed [s]", ¶ms.vqf_magMinUndisturbedTime, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Minimum duration within thresholds after which to regard\nthe field as undisturbed again. Default: 0.5"); - ImGui::InputDouble("Mag max rejection [s]", ¶ms.vqf_magMaxRejectionTime, 0.0, 0.0, "%.1f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Maximum duration of full magnetic disturbance rejection.\nUp to this duration, heading correction is fully " - "disabled\nand tracked by gyroscope only. After this, correction uses\nincreased time constant " - "(magRejectionFactor). Default: 60.0"); - ImGui::InputDouble("Mag rejection factor", ¶ms.vqf_magRejectionFactor, 0.0, 0.0, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Factor by which to slow heading correction during long disturbed phases.\nAfter magMaxRejectionTime of full " - "rejection, correction uses\nthis factor to increase the time constant. Default: 2.0"); - ImGui::TreePop(); - } - } // end if (params.use_vqf) - - ImGui::PopItemWidth(); - } - ImGui::NewLine(); - if (!step_1_done) - { - if (ImGui::Button("Load data")) - { - loStartTime = std::chrono::system_clock::now(); - - step1(loPause); - std::cout << "Load data done please click 'Compute all' to continue calculations" << std::endl; - - std::chrono::duration elapsed = std::chrono::system_clock::now() - loStartTime; - double elapsedSeconds = elapsed.count(); - - std::cout << "Elapsed time: " << formatTime(elapsedSeconds).c_str() << std::endl; - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "Select folder containing IMU *.csv and LiDAR *.laz files produced by MANDEYE (e.g.: 'continousScanning_*')"); - } - if (step_1_done && !step_2_done) - { - if (ImGui::Button("Compute all")) - step2(loPause); - - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Press this button for automatic LiDAR odometry calculation -> it will produce trajectory"); - } - - if (step_1_done && step_2_done) - { - if (ImGui::Button("Point cloud consistency and trajectory smoothness")) - run_consistency(worker_data, params); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("This process makes trajectory smooth, point cloud will be more consistent"); - ImGui::Text("Press optionally before pressing 'Save result'"); - ImGui::EndTooltip(); - } - - ImGui::SameLine(); - ImGui::Checkbox("Use multiple Gaussians for each bucket", ¶ms.use_mutliple_gaussian); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Multiple Gaussians suppose to work better in floor plan indoor scenarios (multiple neighbouring rooms)"); - - if (ImGui::Button("Save result")) - save_results(true, 0.0); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Press this button for saving resulting trajectory and point clouds"); - ImGui::Text("as single session for 'multi_view_tls_registration_step_2' program"); - ImGui::EndTooltip(); - } - } - if (step_1_done && step_2_done) - { - if (ImGui::Button("Save all point clouds to single las/laz file")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Save las/laz file", mandeye::fd::LAS_LAZ_filter, ".laz"); - - if (output_file_name.size() > 0) - { - session.fill_session_from_worker_data(worker_data, false, true, true, params.threshould_output_filter); - // save_all_to_las(session, output_file_name, false); - save_all_to_las(session, output_file_name, true, true); - } - } - } - if (!simple_gui) - { - ImGui::NewLine(); - ImGui::Checkbox("Use robust and accurate lidar odometry", ¶ms.use_robust_and_accurate_lidar_odometry); - - if (params.use_robust_and_accurate_lidar_odometry) - { - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("Distance bucket [m]", ¶ms.distance_bucket, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("Polar angle [deg]", ¶ms.polar_angle_deg, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("Azimutal angle [deg]", ¶ms.azimutal_angle_deg, 0.0, 0.0, "%.3f"); - ImGui::InputInt("Number of iterations", ¶ms.robust_and_accurate_lidar_odometry_iterations); - // ImGui::InputDouble("Max distance lidar", ¶ms.max_distance_lidar); - ImGui::PopItemWidth(); - } - - ImGui::NewLine(); - - ImGui::Text("Rigid ICP using spherical coordinates"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("Distance bucket [m]##ricp", ¶ms.distance_bucket_rigid_sf, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("Polar angle [deg]##ricp", ¶ms.polar_angle_deg_rigid_sf, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("azimutal angle [deg]##ricp", ¶ms.azimutal_angle_deg_rigid_sf, 0.0, 0.0, "%.3f"); - ImGui::InputInt("Number of iterations##ricp", ¶ms.robust_and_accurate_lidar_odometry_rigid_sf_iterations); - ImGui::InputDouble("Max distance [m]##ricp", ¶ms.max_distance_lidar_rigid_sf, 0.0, 0.0, "%.2f"); - ImGui::PopItemWidth(); - - ImGui::NewLine(); - - ImGui::Text("Rigid spherical feature sigmas [m] / [deg]:"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("x##rgdsfs", ¶ms.rgd_sf_sigma_x_m, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("om##rgdsfs", ¶ms.rgd_sf_sigma_om_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - - ImGui::InputDouble("y##rgdsfs", ¶ms.rgd_sf_sigma_y_m, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("fi##rgdsfs", ¶ms.rgd_sf_sigma_fi_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - - ImGui::InputDouble("z##rgdsfs", ¶ms.rgd_sf_sigma_z_m, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::SameLine(); - ImGui::InputDouble("ka##rgdsfs", ¶ms.rgd_sf_sigma_ka_deg, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - - ImGui::PopItemWidth(); - - ImGui::NewLine(); - - if (ImGui::Button("Save trajectory to ASCII (x y z)")) - { - std::string output_file_name = ""; - output_file_name = mandeye::fd::SaveFileDialog("Save trajectory", {}, ""); - std::cout << "File to save: '" << output_file_name << "'" << std::endl; - - if (output_file_name.size() > 0) - { - save_trajectory_to_ascii(worker_data, output_file_name); - } - } - - ImGui::NewLine(); - ImGui::Text("Reference point clouds for initial alignment:"); - - static std::vector input_file_names; - - if (ImGui::Button("Load laz/las files")) - { - input_file_names = mandeye::fd::OpenFileDialog("Load laz/las files", mandeye::fd::LAS_LAZ_filter, true); - if (input_file_names.size() > 0) - { - show_reference_points = true; - load_reference_point_clouds(input_file_names, params); - } - } - - if (ImGui::Button("Set parameters for drone with Ouster (https://ntu-aris.github.io/ntu_viral_dataset/)")) - { - params.decimation = 1.0; - params.in_out_params_indoor.resolution_X = 1.0; - params.in_out_params_indoor.resolution_Y = 1.0; - params.in_out_params_indoor.resolution_Z = 1.0; - - params.in_out_params_outdoor.resolution_X = 2.0; - params.in_out_params_outdoor.resolution_Y = 2.0; - params.in_out_params_outdoor.resolution_Z = 2.0; - } - - if (!input_file_names.empty()) - { - ImGui::Checkbox("Show points", &show_reference_points); - ImGui::SameLine(); - // ImGui::Checkbox("Show buckets ", &show_reference_buckets); - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Downsamplingn###ref", &dec_reference_points); - - if (ImGui::Button("Filter reference buckets")) - { - filter_reference_buckets(params); - } - } - - if (params.initial_points.size() > 0) - { - ImGui::NewLine(); - ImGui::Text("Manipulate initial transformation:"); - ImGui::Checkbox("Show gizmo", &initial_transformation_gizmo); - // gizmo_stretch_interval - if (initial_transformation_gizmo) - { - m_gizmo[0] = (float)params.m_g(0, 0); - m_gizmo[1] = (float)params.m_g(1, 0); - m_gizmo[2] = (float)params.m_g(2, 0); - m_gizmo[3] = (float)params.m_g(3, 0); - m_gizmo[4] = (float)params.m_g(0, 1); - m_gizmo[5] = (float)params.m_g(1, 1); - m_gizmo[6] = (float)params.m_g(2, 1); - m_gizmo[7] = (float)params.m_g(3, 1); - m_gizmo[8] = (float)params.m_g(0, 2); - m_gizmo[9] = (float)params.m_g(1, 2); - m_gizmo[10] = (float)params.m_g(2, 2); - m_gizmo[11] = (float)params.m_g(3, 2); - m_gizmo[12] = (float)params.m_g(0, 3); - m_gizmo[13] = (float)params.m_g(1, 3); - m_gizmo[14] = (float)params.m_g(2, 3); - m_gizmo[15] = (float)params.m_g(3, 3); - } - else - { - if (ImGui::Button("Align to reference")) - { - for (int i = 0; i < 30; i++) - { - align_to_reference(params.in_out_params_indoor, params.initial_points, params.m_g, params.buckets_indoor); - } - } - } - } - - if (worker_data.size() > 0) - { - ImGui::NewLine(); - - ImGui::Text("Scans selection:"); - - ImGui::Text("index from: "); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::SliderInt("##fs", &index_begin, 0, index_end); - ImGui::SameLine(); - ImGui::InputInt("##fi", &index_begin, 1, 5); - if (index_begin < 0) - index_begin = 0; - if (index_begin >= index_end) - index_begin = std::min(index_end, static_cast(worker_data.size() - 1)); - - ImGui::SameLine(); - ImGui::Text(" to: "); - ImGui::SameLine(); - - int prev = index_end; - ImGui::SliderInt("##ts", &index_end, index_begin, static_cast(worker_data.size() - 1)); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("max %zu", worker_data.size() - 1); - ImGui::SameLine(); - ImGui::InputInt("##ti", &index_end, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("max %zu", worker_data.size() - 1); - if (index_end < index_begin) - index_end = index_begin; - if (index_end >= worker_data.size() - 1) - index_end = worker_data.size() - 1; - if (prev != index_end) - { - stretch_gizmo_m = worker_data[index_end].intermediate_trajectory[0]; - } - - ImGui::PopItemWidth(); - - ImGui::Text("Selection: "); - if (ImGui::Button("Select all")) - { - for (size_t k = 0; k < worker_data.size(); k++) - { - worker_data[k].show = true; - } - } - ImGui::SameLine(); - if (ImGui::Button("Unselect")) - { - for (size_t k = 0; k < worker_data.size(); k++) - { - worker_data[k].show = false; - } - } - - ImGui::Text("Select scans from range:"); - ImGui::SameLine(); - if (ImGui::Button("")) - { - for (size_t k = 0; k < worker_data.size(); k++) - worker_data[k].show = (k >= index_begin && k <= index_end); - } - - if (ImGui::Button("")) - { - if (index_begin > 1 && index_end > 1) - { - index_begin--; - index_end--; - - for (size_t k = 0; k < worker_data.size(); k++) - worker_data[k].show = (k >= index_begin && k <= index_end); - } - } - ImGui::SameLine(); - if (ImGui::Button("")) - { - if (index_begin + 1 < worker_data.size() && index_end + 1 < worker_data.size()) - { - index_begin++; - index_end++; - - for (size_t k = 0; k < worker_data.size(); k++) - worker_data[k].show = (k >= index_begin && k <= index_end); - } - } - - if (ImGui::Button("from - 10, to - 10>")) - { - if (index_begin > 10 && index_end > 10) - { - index_begin -= 10; - index_end -= 10; - - for (size_t k = 0; k < worker_data.size(); k++) - worker_data[k].show = (k >= index_begin && k <= index_end); - } - } - ImGui::SameLine(); - if (ImGui::Button("")) - { - if (index_begin + 10 < worker_data.size() && index_end + 10 < worker_data.size()) - { - index_begin += 10; - index_end += 10; - - for (size_t k = 0; k < worker_data.size(); k++) - worker_data[k].show = (k >= index_begin && k <= index_end); - } - } - - if (ImGui::Button("Export selected scans")) - { - auto output_file_name = mandeye::fd::SaveFileDialog("Save las/laz file", mandeye::fd::LAS_LAZ_filter, ".laz"); - Eigen::Affine3d pose; - if (output_file_name.size() > 0) - { - session.fill_session_from_worker_data(worker_data, true, false, false, params.threshould_output_filter); - save_all_to_las(session, output_file_name, false, true); - } - // TODO: give value to pose even if output_file_name is wrong - - std::cout << "----------------------------------------" << std::endl; - std::cout << "please add following lines to RESSO file:" << std::endl; - std::cout << fs::path(output_file_name).filename() << "(!!!please remove brackets!!!)" << std::endl; - std::cout << pose.matrix() << std::endl; - - std::cout << "example RESSO file" << std::endl; - std::cout << ".................................................." << std::endl; - std::cout << "3" << std::endl - << "scan_0.laz" << std::endl - << "0.999775 0.000552479 -0.0212158 -0.0251188" << std::endl - << "0.000834612 0.997864 0.0653156 -0.0381429" << std::endl - << "0.0212066 - 0.0653186 0.997639 -0.000757752" - << "0 0 0 1" << std::endl - << "scan_1.laz" << std::endl - << "0.999783 0.00178963 -0.0207603 -0.0309683" << std::endl - << "-0.000467341 0.99798 0.0635239 -0.0517512" << std::endl - << "0.0208321 -0.0635004 0.997764 0.00331449" << std::endl - << "0 0 0 1" << std::endl - << "scan_2.laz" << std::endl - << "0.999783 0.00163449 -0.0207736 -0.0309985" << std::endl - << "-0.000312224 0.997982 0.0634957 -0.0506113" << std::endl - << "0.0208355 -0.0634754 0.997766 0.0028499" << std::endl - << "0 0 0 1" << std::endl; - std::cout << "................................................." << std::endl; - } - - ImGui::SameLine(); - - if (ImGui::Button("Save RESSO file")) - { - auto output_file_name = mandeye::fd::SaveFileDialog("Save RESSO file", {}, ""); - std::cout << "RESSO file to save: '" << output_file_name << "'" << std::endl; - - if (output_file_name.size() > 0) - { - session.point_clouds_container.save_poses(fs::path(output_file_name).string(), false); - } - } - - if (index_end > index_begin) - { - ImGui::Separator(); - ImGui::Checkbox("Gizmo_stretch_interval", &gizmo_stretch_interval); - } - - // gizmo_stretch_interval - if (gizmo_stretch_interval) - { - if (index_end < worker_data.size()) - { - if (worker_data[index_end].intermediate_trajectory.size() > 0) - { - m_gizmo[0] = (float)stretch_gizmo_m(0, 0); - m_gizmo[1] = (float)stretch_gizmo_m(1, 0); - m_gizmo[2] = (float)stretch_gizmo_m(2, 0); - m_gizmo[3] = (float)stretch_gizmo_m(3, 0); - m_gizmo[4] = (float)stretch_gizmo_m(0, 1); - m_gizmo[5] = (float)stretch_gizmo_m(1, 1); - m_gizmo[6] = (float)stretch_gizmo_m(2, 1); - m_gizmo[7] = (float)stretch_gizmo_m(3, 1); - m_gizmo[8] = (float)stretch_gizmo_m(0, 2); - m_gizmo[9] = (float)stretch_gizmo_m(1, 2); - m_gizmo[10] = (float)stretch_gizmo_m(2, 2); - m_gizmo[11] = (float)stretch_gizmo_m(3, 2); - m_gizmo[12] = (float)stretch_gizmo_m(0, 3); - m_gizmo[13] = (float)stretch_gizmo_m(1, 3); - m_gizmo[14] = (float)stretch_gizmo_m(2, 3); - m_gizmo[15] = (float)stretch_gizmo_m(3, 3); - } - } - - if (ImGui::Button("Accept Gizmo (only translation)")) - { - if (index_end < worker_data.size()) - { - if (worker_data[index_end].intermediate_trajectory.size() > 0) - { - Eigen::Affine3d current_gizmo = Eigen::Affine3d::Identity(); - current_gizmo(0, 0) = m_gizmo[0]; - current_gizmo(1, 0) = m_gizmo[1]; - current_gizmo(2, 0) = m_gizmo[2]; - current_gizmo(3, 0) = m_gizmo[3]; - current_gizmo(0, 1) = m_gizmo[4]; - current_gizmo(1, 1) = m_gizmo[5]; - current_gizmo(2, 1) = m_gizmo[6]; - current_gizmo(3, 1) = m_gizmo[7]; - current_gizmo(0, 2) = m_gizmo[8]; - current_gizmo(1, 2) = m_gizmo[9]; - current_gizmo(2, 2) = m_gizmo[10]; - current_gizmo(3, 2) = m_gizmo[11]; - current_gizmo(0, 3) = m_gizmo[12]; - current_gizmo(1, 3) = m_gizmo[13]; - current_gizmo(2, 3) = m_gizmo[14]; - current_gizmo(3, 3) = m_gizmo[15]; - - auto first_pose = worker_data[index_begin].intermediate_trajectory[0]; - - Eigen::Vector3d translation = current_gizmo.translation() - first_pose.translation(); - - float number_all_nodes_inside_interval = 0; - for (int i = index_begin; i < index_end; i++) - { - number_all_nodes_inside_interval += (float)worker_data[i].intermediate_trajectory.size(); - } - - std::vector> all_poses; - for (size_t i = 0; i < worker_data.size(); i++) - { - std::vector poses; - for (size_t j = 0; j < worker_data[i].intermediate_trajectory.size(); j++) - { - poses.push_back(worker_data[i].intermediate_trajectory[j]); - } - all_poses.push_back(poses); - } - - float counter = 0; - - Eigen::Affine3d last_m = Eigen::Affine3d::Identity(); - - for (int i = index_begin; i < index_end; i++) - { - for (size_t j = 0; j < worker_data[i].intermediate_trajectory.size(); j++) - { - TaitBryanPose pose = pose_tait_bryan_from_affine_matrix(worker_data[i].intermediate_trajectory[j]); - - pose.px = - first_pose.translation().x() + translation.x() * (counter / number_all_nodes_inside_interval); - pose.py = - first_pose.translation().y() + translation.y() * (counter / number_all_nodes_inside_interval); - pose.pz = - first_pose.translation().z() + translation.z() * (counter / number_all_nodes_inside_interval); - - counter += 1.0f; - - worker_data[i].intermediate_trajectory[j] = affine_matrix_from_pose_tait_bryan(pose); - - last_m = worker_data[i].intermediate_trajectory[j]; - } - } - - for (size_t i = index_end; i < worker_data.size(); i++) - { - for (size_t j = 0; j < worker_data[i].intermediate_trajectory.size(); j++) - { - Eigen::Affine3d m_update = Eigen::Affine3d::Identity(); - - if (j == 0) - { - m_update = all_poses[i - 1][all_poses[i - 1].size() - 1].inverse() * all_poses[i][0]; - } - else - { - m_update = all_poses[i][j - 1].inverse() * all_poses[i][j]; - } - last_m = last_m * m_update; - worker_data[i].intermediate_trajectory[j] = last_m; - } - } - } - } - } - ImGui::Separator(); - } - - ImGui::NewLine(); - ImGui::Text("Show/hide individual scans:"); - - int n_items = (int)worker_data.size(); - int digits = (n_items > 0) ? (int)std::log10(n_items - 1) + 1 : 1; - - for (int i = 0; i < n_items; i++) - { - // std::string text = "[" + std::to_string(i) + "]"; - // ImGui::Checkbox(text.c_str(), &worker_data[i].show); - std::stringstream ss; - ss << "[" << std::setw(digits) << std::setfill('0') << i << "]"; - - ImGui::Checkbox(ss.str().c_str(), &worker_data[i].show); - - // Arrange checkboxes in rows of 5 - if ((i + 1) % 5 != 0) - ImGui::SameLine(); - } - } - } - } - - ImGui::End(); -} - -void progress_window() -{ - ImGui::Begin("Progress", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - - ImGui::Text(("Working directory:\n'" + working_directory + "'").c_str()); - - // Calculate elapsed time and ETA - auto currentTime = std::chrono::system_clock::now(); - std::chrono::duration elapsed = currentTime - loStartTime; - double elapsedSeconds = elapsed.count(); - loElapsedSeconds.store(elapsedSeconds); - - float progress = loProgress.load(); - double estimatedTimeRemaining = 0.0; - - if (progress > 0.01f && progress < 100.0f) - { // Only estimate when we have meaningful progress - double totalEstimatedTime = elapsedSeconds / progress; - estimatedTimeRemaining = totalEstimatedTime - elapsedSeconds; - loEstimatedTimeRemaining.store(estimatedTimeRemaining); - } - - // Format progress text with time information - char progressText[256]; - char timeInfo[512]; - - if (progress > 0.01f) - { - std::string completionTime = formatCompletionTime(estimatedTimeRemaining); - snprintf(progressText, sizeof(progressText), "Processing: %.1f%%", progress * 100.0f); - snprintf( - timeInfo, - sizeof(timeInfo), - "Elapsed: %s | Remaining: %s | Estimated finish: ~%s", - formatTime(elapsedSeconds).c_str(), - formatTime(estimatedTimeRemaining).c_str(), - completionTime.c_str()); - } - else - { - snprintf(progressText, sizeof(progressText), "Processing: %.1f%%", progress * 100.0f); - snprintf(timeInfo, sizeof(timeInfo), "Elapsed: %s | Calculating completion time...", formatTime(elapsedSeconds).c_str()); - } - - ImGui::ProgressBar(progress, ImVec2(-1.0f, 0.0f), progressText); - ImGui::Text("%s", timeInfo); - -#ifdef _WIN32 - // Update Windows taskbar progress - if (progress > 0.01f && progress < 1.0f) - { - SetTaskbarProgress(progress); - } - else if (progress >= 1.0f) - { - ClearTaskbarProgress(); - } -#endif - - ImGui::NewLine(); - - if (!loPause) - { - if (ImGui::Button("Pause")) - loPause.store(true); - - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Pausing calculation will not save intermediate state!"); - ImGui::Text("You can't resume if you close the program!"); - ImGui::EndTooltip(); - } - } - else - { - if (ImGui::Button("Resume")) - loPause.store(false); - } - ImGui::SameLine(); - ImGui::Text("Also check console for progress.."); - - ImGui::Checkbox("Show reference buckets indoor", &show_reference_buckets_indoor); - ImGui::Checkbox("Show reference buckets outdoor", &show_reference_buckets_outdoor); - ImGui::Checkbox("Show initial points", &show_initial_points); - ImGui::Checkbox("Show trajectory", &show_trajectory); - ImGui::Checkbox("Show trajectory as axes", &show_trajectory_as_axes); - ImGui::Checkbox("Show prediction vectors", &show_prediction_vectors); - ImGui::Checkbox("Show intermediate trajectory prediction axes", &intermediate_trajectory_prediction_axes); - ImGui::Checkbox("Show without filtered buckets", &show_without_filtered_buckets); - ImGui::Checkbox("Show normal vectors indoor", &show_normal_vectors_indoor); - ImGui::Checkbox("Show normal vectors outdoor", &show_normal_vectors_outdoor); - // ImGui::Checkbox("Show covs indoor", &show_covs_indoor); - // ImGui::Checkbox("Show covs outdoor", &show_covs_outdoor); - - ImGui::End(); -} - -void openData() -{ - is_settings_gui = false; - info_gui = false; - - loRunning.store(true); - loProgress.store(0.0f); - loElapsedSeconds.store(0.0); - loEstimatedTimeRemaining.store(0.0); - loStartTime = std::chrono::system_clock::now(); - - step1(loPause); - - if (step_1_done) - { - std::thread loThread( - []() - { - std::chrono::time_point start, end; - start = std::chrono::system_clock::now(); - - step2(loPause); - if (!step_2_done) - { - loRunning = false; - std::cerr << "Lidar odometry step 2 failed: no results saved" << std::endl; - return; - } - - end = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds = end - start; - - save_results(false, elapsed_seconds.count()); - - loRunning = false; - - std::ostringstream oss; - oss << "Data saved to folder:\n'" << outwd.string() << "'\n" - << "Calculated trajectory length: " << std::fixed << std::setprecision(1) - << params.total_length_of_calculated_trajectory << "[m]\n" - << "Elapsed time: " << formatTime(elapsed_seconds.count()).c_str(); - - [[maybe_unused]] pfd::message message("Information", oss.str(), pfd::choice::ok, pfd::icon::info); - message.result(); - }); - - loThread.detach(); - } - else // no data loaded - loRunning = false; -} - -bool step1( - const std::string& folder, - LidarOdometryParams& params, - std::vector>& pointsPerFile, - Imu& imu_data, - std::string& working_directory, - Trajectory& trajectory, - std::vector& worker_data, - const std::atomic& loPause) -{ - std::vector input_file_names; - - for (const auto& entry : fs::directory_iterator(folder)) - { - if (!entry.is_directory()) - { - std::cout << entry.path() << std::endl; - input_file_names.push_back(entry.path().string()); - } - } - - if (load_data(input_file_names, params, pointsPerFile, imu_data, full_debug_messages)) - { - working_directory = fs::path(input_file_names[0]).parent_path().string(); - calculate_trajectory(trajectory, imu_data, params, full_debug_messages); - if (!compute_step_1(pointsPerFile, params, trajectory, worker_data, loPause)) - return false; - release_raw_clouds(pointsPerFile, params); // nothing after step 1 reads them - std::cout << "step_1_done" << std::endl; - return true; - } - return false; -} - -bool step2(std::vector& worker_data, LidarOdometryParams& params, const std::atomic& loPause) -{ - double ts_failure = 0.0; - std::atomic loProgress; - std::atomic parked{ false }; - return compute_step_2(worker_data, params, ts_failure, loProgress, loPause, full_debug_messages, parked); -} - -void save_results( - bool info, - double elapsed_seconds, - std::string& working_directory, - std::vector& worker_data, - LidarOdometryParams& params, - fs::path outwd) -{ - save_result(worker_data, params, outwd, elapsed_seconds); -} - -void display() -{ - ImGuiIO& io = ImGui::GetIO(); - glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - glClearColor(bg_color.x * bg_color.w, bg_color.y * bg_color.w, bg_color.z * bg_color.w, bg_color.w); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - float ratio = float(io.DisplaySize.x) / float(io.DisplaySize.y); - - updateCameraTransition(); - - reshape((GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - viewLocal = Eigen::Affine3f::Identity(); - - viewLocal.translate(rotation_center); - - viewLocal.translate(Eigen::Vector3f(translate_x, translate_y, translate_z)); - if (!lock_z) - viewLocal.rotate(Eigen::AngleAxisf(rotate_x * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - else - viewLocal.rotate(Eigen::AngleAxisf(-90.0 * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - viewLocal.rotate(Eigen::AngleAxisf(rotate_y * DEG_TO_RAD, Eigen::Vector3f::UnitZ())); - - viewLocal.translate(-rotation_center); - - glMatrixMode(GL_MODELVIEW); - glLoadMatrixf(viewLocal.matrix().data()); - - showAxes(); - - if (show_initial_points) - { - glColor3d(0.0, 1.0, 0.0); - glPointSize(point_size); - glBegin(GL_POINTS); - for (const auto& p : params.initial_points) - { - auto pp = params.m_g * p.point; - glVertex3d(pp.x(), pp.y(), pp.z()); - } - glEnd(); - } - -#if 0 // ToDo - for (size_t i = 0; i < worker_data.size(); i++) - { - if (worker_data[i].show) - { - glPointSize(1); - glColor3d(0.0, 0.0, 1.0); - glBegin(GL_POINTS); - for (const auto &p : worker_data[i].intermediate_points) - { - Eigen::Vector3d pt = worker_data[i].intermediate_trajectory[p.index_pose] * p.point; - glVertex3d(pt.x(), pt.y(), pt.z()); - } - glEnd(); - glPointSize(1); - - glLineWidth(1); - glBegin(GL_LINES); - const auto &it = worker_data[i].intermediate_trajectory[0]; - glColor3f(1, 0, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + it(0, 0), it(1, 3) + it(1, 0), it(2, 3) + it(2, 0)); - - glColor3f(0, 1, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + it(0, 1), it(1, 3) + it(1, 1), it(2, 3) + it(2, 1)); - - glEnd(); - } - } -#endif - - if (show_reference_points) - { - glColor3f(1, 0, 0); - glBegin(GL_POINTS); - for (size_t i = 0; i < params.reference_points.size(); i += dec_reference_points) - glVertex3f(params.reference_points[i].point.x(), params.reference_points[i].point.y(), params.reference_points[i].point.z()); - glEnd(); - } - - if (show_trajectory_as_axes) - { - // glBegin(GL_LINE_STRIP); - glBegin(GL_LINES); - for (const auto& wd : worker_data) - { - for (const auto& it : wd.intermediate_trajectory) - { - glColor3f(1, 0, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + it(0, 0) * 0.1, it(1, 3) + it(1, 0) * 0.1, it(2, 3) + it(2, 0) * 0.1); - - glColor3f(0, 1, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + it(0, 1) * 0.1, it(1, 3) + it(1, 1) * 0.1, it(2, 3) + it(2, 1) * 0.1); - - glColor3f(0, 0, 1); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + it(0, 2) * 0.1, it(1, 3) + it(1, 2) * 0.1, it(2, 3) + it(2, 2) * 0.1); - } - } - glEnd(); - } - - if (show_prediction_vectors) - { - glDisable(GL_DEPTH_TEST); - glLineWidth(3.0f); - glBegin(GL_LINES); - for (const auto& wd : worker_data) - { - if (wd.intermediate_trajectory.empty() || wd.imu_prediction_vector.norm() < 1e-6) - continue; - - Eigen::Vector3d start = wd.intermediate_trajectory.front().translation(); - Eigen::Vector3d end = start + wd.imu_prediction_vector; - - glColor3f(1.0f, 0.0f, 1.0f); // magenta - glVertex3d(start.x(), start.y(), start.z()); - glVertex3d(end.x(), end.y(), end.z()); - } - glEnd(); - glLineWidth(1.0f); - glEnable(GL_DEPTH_TEST); - } - - if (intermediate_trajectory_prediction_axes) - { - glLineWidth(1.0f); - glBegin(GL_LINES); - for (const auto& wd : worker_data) - { - if (wd.intermediate_trajectory.empty() || wd.intermediate_trajectory_prediction.empty()) - continue; - - for (size_t i = 0; i < std::min(wd.intermediate_trajectory.size(), wd.intermediate_trajectory_prediction.size()); i++) - { - const auto& it = wd.intermediate_trajectory[i]; - const auto& pred_axis = wd.intermediate_trajectory_prediction[i]; - - glColor3f(1, 0, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + pred_axis(0, 0) * 0.05, it(1, 3) + pred_axis(1, 0) * 0.05, it(2, 3) + pred_axis(2, 0) * 0.05); - - glColor3f(0, 1, 0); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + pred_axis(0, 1) * 0.05, it(1, 3) + pred_axis(1, 1) * 0.05, it(2, 3) + pred_axis(2, 1) * 0.05); - - glColor3f(0, 0, 1); - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + pred_axis(0, 2) * 0.05, it(1, 3) + pred_axis(1, 2) * 0.05, it(2, 3) + pred_axis(2, 2) * 0.05); - } - } - glEnd(); - glLineWidth(1.0f); - } - - if (show_trajectory) - { - glPointSize(3); - glColor3f(0, 1, 1); - glBegin(GL_POINTS); - for (const auto& wd : worker_data) - { - for (const auto& it : wd.intermediate_trajectory) - glVertex3f(it(0, 3), it(1, 3), it(2, 3)); - } - glEnd(); - glPointSize(1); - - glColor3f(1, 0, 0); - glBegin(GL_LINES); - if (worker_data.size() > 0) - { - const auto& wd = worker_data[worker_data.size() - 1]; - if (wd.intermediate_trajectory.size() > 0) - { - const auto& it = wd.intermediate_trajectory[wd.intermediate_trajectory.size() - 1]; - - glVertex3f(it(0, 3) - 1, it(1, 3), it(2, 3)); - glVertex3f(it(0, 3) + 1, it(1, 3), it(2, 3)); - - glVertex3f(it(0, 3), it(1, 3) - 1, it(2, 3)); - glVertex3f(it(0, 3), it(1, 3) + 1, it(2, 3)); - - glVertex3f(it(0, 3), it(1, 3), it(2, 3) - 1); - glVertex3f(it(0, 3), it(1, 3), it(2, 3) + 1); - } - } - glEnd(); - } - - if (show_reference_buckets_indoor) - { - std::scoped_lock lock(params.mutex_buckets_indoor); - glColor3f(1, 0, 0); - glBegin(GL_POINTS); - for (const auto& b : params.buckets_indoor) - { - if (b.second.number_of_points == -1) - { - glColor3f(0, 1, 1); - } - else - { - glColor3f(1, 0, 0); - } - if (!show_without_filtered_buckets) - { - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - } - else - { - if (b.second.number_of_hits < 20) - { - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - } - } - } - glEnd(); - } - - if (show_reference_buckets_outdoor) - { - std::scoped_lock lock2(params.mutex_buckets_outdoor); - glColor3f(0, 0, 1); - glBegin(GL_POINTS); - for (const auto& b : params.buckets_outdoor) - { - if (b.second.number_of_points == -1) - { - glColor3f(1, 0, 1); - } - else - { - glColor3f(0, 0, 1); - } - // glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - if (!show_without_filtered_buckets) - { - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - } - else - { - if (b.second.number_of_hits < 20) - { - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - } - } - } - glEnd(); - } - - if (show_normal_vectors_indoor) - { - std::scoped_lock lock2(params.mutex_buckets_indoor); - glColor3f(0, 0, 1); - glBegin(GL_LINES); - for (const auto& b : params.buckets_indoor) - { - glColor3f(fabs(b.second.normal_vector.x()), fabs(b.second.normal_vector.y()), fabs(b.second.normal_vector.z())); - - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - glVertex3f( - b.second.mean.x() + b.second.normal_vector.x(), - b.second.mean.y() + b.second.normal_vector.y(), - b.second.mean.z() + b.second.normal_vector.z()); - } - glEnd(); - } - - if (show_normal_vectors_outdoor) - { - std::scoped_lock lock2(params.mutex_buckets_outdoor); - glColor3f(0, 0, 1); - glBegin(GL_LINES); - for (const auto& b : params.buckets_outdoor) - { - glColor3f(fabs(b.second.normal_vector.x()), fabs(b.second.normal_vector.y()), fabs(b.second.normal_vector.z())); - - glVertex3f(b.second.mean.x(), b.second.mean.y(), b.second.mean.z()); - glVertex3f( - b.second.mean.x() + b.second.normal_vector.x(), - b.second.mean.y() + b.second.normal_vector.y(), - b.second.mean.z() + b.second.normal_vector.z()); - } - glEnd(); - } - - if (show_covs_indoor) - { - std::scoped_lock lock(params.mutex_buckets_indoor); - for (const auto& b : params.buckets_indoor) - draw_ellipse(b.second.cov, b.second.mean, Eigen::Vector3f(1.0f, 0.0f, 0.0f), 3); - } - - if (show_covs_outdoor) - { - std::scoped_lock lock2(params.mutex_buckets_outdoor); - for (const auto& b : params.buckets_outdoor) - draw_ellipse(b.second.cov, b.second.mean, Eigen::Vector3f(0.0f, 0.0f, 1.0f), 3); - } - - // - if (worker_data.size() > 0) - { - if (index_begin < worker_data.size()) - { - glColor3f(1, 1, 0); - glBegin(GL_LINES); - if (worker_data[index_begin].intermediate_trajectory.size() > 0) - { - auto p = worker_data[index_begin].intermediate_trajectory[0].translation(); - glVertex3f(p.x() - 1, p.y(), p.z()); - glVertex3f(p.x() + 1, p.y(), p.z()); - - glVertex3f(p.x(), p.y() - 1, p.z()); - glVertex3f(p.x(), p.y() + 1, p.z()); - - glVertex3f(p.x(), p.y(), p.z() - 1); - glVertex3f(p.x(), p.y(), p.z() + 1); - } - glEnd(); - } - - if (index_end < worker_data.size()) - { - glColor3f(0, 1, 1); - glBegin(GL_LINES); - if (worker_data[index_end].intermediate_trajectory.size() > 0) - { - auto p = worker_data[index_end].intermediate_trajectory[0].translation(); - glVertex3f(p.x() - 1, p.y(), p.z()); - glVertex3f(p.x() + 1, p.y(), p.z()); - - glVertex3f(p.x(), p.y() - 1, p.z()); - glVertex3f(p.x(), p.y() + 1, p.z()); - - glVertex3f(p.x(), p.y(), p.z() - 1); - glVertex3f(p.x(), p.y(), p.z() + 1); - } - glEnd(); - } - } - - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGLUT_NewFrame(); - ImGui::NewFrame(); - - ShowMainDockSpace(); - - view_kbd_shortcuts(); - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_O, false)) - { - openData(); - - // workaround - io.AddKeyEvent(ImGuiKey_O, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (!loRunning) - { - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("Presets")) - { - if (ImGui::MenuItem("1 Velocity < 8km/h, tiny spaces (default)", nullptr, (lastPar == 1))) - { - lastPar = 1; - - set_lidar_odometry_default_params(params); - - std::cout << "clicked: Set parameters for velocity up to 8km/h, tiny spaces" << std::endl; - } - if (ImGui::MenuItem("2 Velocity < 8km/h, larger spaces, precise forestry (generic)", nullptr, (lastPar == 2))) - { - lastPar = 2; - - params.decimation = 0.01; - params.in_out_params_indoor.resolution_X = 0.1; - params.in_out_params_indoor.resolution_Y = 0.1; - params.in_out_params_indoor.resolution_Z = 0.1; - - params.in_out_params_outdoor.resolution_X = 0.3; - params.in_out_params_outdoor.resolution_Y = 0.3; - params.in_out_params_outdoor.resolution_Z = 0.3; - - params.filter_threshold_xy_inner = 1.0; - params.filter_threshold_xy_outer = 70.0; - params.threshould_output_filter = 1.5; - - params.use_robust_and_accurate_lidar_odometry = false; - params.distance_bucket = 0.2; - params.polar_angle_deg = 10.0; - params.azimutal_angle_deg = 10.0; - params.robust_and_accurate_lidar_odometry_iterations = 20; - - params.max_distance_lidar = 70.0; - params.nr_iter = 500; - params.sliding_window_trajectory_length_threshold = 10000; - params.real_time_threshold_seconds = 10; - - std::cout << "clicked: Set parameters for velocity < 8km/h, larger spaces, precise forestry (generic)" << std::endl; - } - if (ImGui::MenuItem("3 Velocity < 30 km/h, largest open spaces, fast motion", nullptr, (lastPar == 3))) - { - lastPar = 3; - - params.decimation = 0.03; - params.in_out_params_indoor.resolution_X = 0.3; - params.in_out_params_indoor.resolution_Y = 0.3; - params.in_out_params_indoor.resolution_Z = 0.3; - - params.in_out_params_outdoor.resolution_X = 0.5; - params.in_out_params_outdoor.resolution_Y = 0.5; - params.in_out_params_outdoor.resolution_Z = 0.5; - - params.filter_threshold_xy_inner = 1.0; - params.filter_threshold_xy_outer = 70.0; - params.threshould_output_filter = 3.0; - - params.use_robust_and_accurate_lidar_odometry = false; - params.distance_bucket = 0.2; - params.polar_angle_deg = 10.0; - params.azimutal_angle_deg = 10.0; - params.robust_and_accurate_lidar_odometry_iterations = 20; - - params.max_distance_lidar = 70.0; - params.nr_iter = 500; - params.sliding_window_trajectory_length_threshold = 200; - params.real_time_threshold_seconds = 10; - - std::cout << "clicked: Set parameters for velocity < 30 km/h, largest open spaces, fast motion" << std::endl; - } - ImGui::Separator(); - if (ImGui::MenuItem( - "4: Best accuracy, precision, and robustness (uncheck to calculate faster)", - nullptr, - params.ablation_study_use_anisotropic_weighting)) - { - params.ablation_study_use_anisotropic_weighting = !params.ablation_study_use_anisotropic_weighting; - } - ImGui::MenuItem("5: No IMU, lidar-only odometry (combine with 1-3)", nullptr, ¶ms.lidar_only_odometry); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "For recordings without IMU data, written with a synthetic stationary IMU (e.g. ouster_pcap_to_laz " - "--stationary-imu): each window's rotation and translation are predicted from the previous window instead of " - "from the IMU."); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Set parameters for MANDEYE data processing"); - - if (ImGui::BeginMenu("Parameters")) - { - ImGui::MenuItem( - "Remove IMU bias from first stationary scan", nullptr, ¶ms.use_removie_imu_bias_from_first_stationary_scan); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("IMU bias will be removed given there's a stationary period at the start of the recording"); - - ImGui::MenuItem("Multithread", nullptr, ¶ms.useMultithread); - ImGui::SetNextItemWidth(ImGuiNumberWidth / 2); - ImGui::InputDouble("Time threshold [s]", ¶ms.real_time_threshold_seconds, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Optimization timeout"); - ImGui::Text("smaller value gives faster calculations, less precise results"); - ImGui::Text("e.g.: 0.1 [s] will make processing time aprox equal to scan time"); - ImGui::Text("0.3 [s] will make processing time aprox equal to 3x scan time"); - ImGui::EndTooltip(); - } - - if (ImGui::MenuItem("Set real time performance")) - params.real_time_threshold_seconds = 0.1; - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("For IMU 200Hz, 20 nodes in optimization window"); - - ImGui::Separator(); - - ImGui::Text("Debug:"); - - ImGui::MenuItem("Full processing messages", nullptr, &full_debug_messages); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show more messages during processing in console window"); - ImGui::MenuItem("Save calibration validation file", nullptr, ¶ms.save_calibration_validation); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Save calibrated points from first laz file in 'calibrationValidation.asc' file"); - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Number of calibration validation points", ¶ms.calibration_validation_points); - - ImGui::Separator(); - if (ImGui::BeginMenu("Ablation study")) - { - ImGui::MenuItem("Use planarity", nullptr, ¶ms.ablation_study_use_planarity); - ImGui::MenuItem("Use norm", nullptr, ¶ms.ablation_study_use_norm); - ImGui::MenuItem("Use hierarchical RGD (outer RGD turned on)", nullptr, ¶ms.ablation_study_use_hierarchical_rgd); - ImGui::MenuItem("Use view point and normal vectors", nullptr, ¶ms.ablation_study_use_view_point_and_normal_vectors); - ImGui::MenuItem("Use threshold '1e-6' outer RGD", nullptr, ¶ms.ablation_study_use_threshold_outer_rgd); - ImGui::MenuItem("Use anisotropic weighting", nullptr, ¶ms.ablation_study_use_anisotropic_weighting); - ImGui::EndMenu(); - } - - ImGui::Separator(); - - ImGui::MenuItem("Saving results with index pose", nullptr, ¶ms.save_index_pose); - - ImGui::Separator(); - - if (ImGui::MenuItem("Load parameters")) - { - auto input_file_names = mandeye::fd::OpenFileDialog("Load parameters file", mandeye::fd::Toml_filter, ".toml"); - - if (input_file_names.size() > 0) - { - try - { - // Use the original TomlIO class for loading parameters in GUI - TomlIO toml_io; - toml_io.LoadParametersFromTomlFile(input_file_names[0], params); - std::cout << "Parameters loaded from: " << input_file_names[0] << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error loading TOML file: " << e.what() << std::endl; - } - } - } - - if (ImGui::MenuItem("Save parameters")) - { - auto output_file_name = mandeye::fd::SaveFileDialog("Save parameters file", mandeye::fd::Toml_filter, ".toml"); - std::cout << "Parameters file to save: '" << output_file_name << "'" << std::endl; - - if (!output_file_name.empty()) - { - // Use the original TomlIO class for saving parameters in GUI - TomlIO toml_io; - bool success = toml_io.SaveParametersToTomlFile(output_file_name, params); - if (success) - std::cout << "Parameters file generated: " << output_file_name << std::endl; - else - std::cerr << "Failed to save parameters." << std::endl; - } - } - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Processing parameter list"); - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - if (ImGui::Button("Load & process scanning")) - openData(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select folder from where to load data and start processing (Ctrl+O)"); - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - if (ImGui::BeginMenu("View")) - { - ImGui::BeginDisabled(!(session.point_clouds_container.point_clouds.size() > 0)); - { - auto tmp = point_size; - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points size", &point_size); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("keyboard 1-9 keys"); - if (point_size < 1) - point_size = 1; - else if (point_size > 10) - point_size = 10; - - if (tmp != point_size) - for (auto& point_cloud : session.point_clouds_container.point_clouds) - point_cloud.point_size = point_size; - - ImGui::Separator(); - } - ImGui::EndDisabled(); - - ImGui::MenuItem("Show initial points", nullptr, &show_initial_points); - ImGui::MenuItem("Show trajectory", nullptr, &show_trajectory); - ImGui::MenuItem("Show trajectory as axes", nullptr, &show_trajectory_as_axes); - ImGui::MenuItem("Show prediction vectors", nullptr, &show_prediction_vectors); - ImGui::MenuItem("Show intermediate trajectory prediction axes", nullptr, &intermediate_trajectory_prediction_axes); - - ImGui::MenuItem("Show compass/ruler", "key C", &compass_ruler); - - ImGui::MenuItem("Lock Z", "Shift + Z", &lock_z, !is_ortho); - - // ImGui::MenuItem("show_covs", nullptr, &show_covs); - - ImGui::Separator(); - - ImGui::Text("Colors:"); - - ImGui::ColorEdit3("Background", (float*)¶ms.clear_color, ImGuiColorEditFlags_NoInputs); - - bg_color = params.clear_color; - - ImGui::Separator(); - - ImGui::MenuItem("Settings", nullptr, &is_settings_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show power user settings window with more parameters"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Scene view relevant parameters"); - - camMenu(); - - ImGui::SameLine( - ImGui::GetWindowWidth() - ImGui::CalcTextSize("Info").x - ImGui::GetStyle().ItemSpacing.x * 2 - - ImGui::GetStyle().FramePadding.x * 2); - - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_Header)); - if (ImGui::SmallButton("Info")) - info_gui = !info_gui; - - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(3); - - ImGui::EndMainMenuBar(); - } - } - - if (initial_transformation_gizmo) - { - ImGuiIO& io = ImGui::GetIO(); - // ImGuizmo ----------------------------------------------- - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - &modelview[0], - &projection[0], - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - params.m_g(0, 0) = m_gizmo[0]; - params.m_g(1, 0) = m_gizmo[1]; - params.m_g(2, 0) = m_gizmo[2]; - params.m_g(3, 0) = m_gizmo[3]; - params.m_g(0, 1) = m_gizmo[4]; - params.m_g(1, 1) = m_gizmo[5]; - params.m_g(2, 1) = m_gizmo[6]; - params.m_g(3, 1) = m_gizmo[7]; - params.m_g(0, 2) = m_gizmo[8]; - params.m_g(1, 2) = m_gizmo[9]; - params.m_g(2, 2) = m_gizmo[10]; - params.m_g(3, 2) = m_gizmo[11]; - params.m_g(0, 3) = m_gizmo[12]; - params.m_g(1, 3) = m_gizmo[13]; - params.m_g(2, 3) = m_gizmo[14]; - params.m_g(3, 3) = m_gizmo[15]; - } - - if (gizmo_stretch_interval) - { - ImGuiIO& io = ImGui::GetIO(); - // ImGuizmo ----------------------------------------------- - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - &modelview[0], - &projection[0], - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - stretch_gizmo_m(0, 0) = m_gizmo[0]; - stretch_gizmo_m(1, 0) = m_gizmo[1]; - stretch_gizmo_m(2, 0) = m_gizmo[2]; - stretch_gizmo_m(3, 0) = m_gizmo[3]; - stretch_gizmo_m(0, 1) = m_gizmo[4]; - stretch_gizmo_m(1, 1) = m_gizmo[5]; - stretch_gizmo_m(2, 1) = m_gizmo[6]; - stretch_gizmo_m(3, 1) = m_gizmo[7]; - stretch_gizmo_m(0, 2) = m_gizmo[8]; - stretch_gizmo_m(1, 2) = m_gizmo[9]; - stretch_gizmo_m(2, 2) = m_gizmo[10]; - stretch_gizmo_m(3, 2) = m_gizmo[11]; - stretch_gizmo_m(0, 3) = m_gizmo[12]; - stretch_gizmo_m(1, 3) = m_gizmo[13]; - stretch_gizmo_m(2, 3) = m_gizmo[14]; - stretch_gizmo_m(3, 3) = m_gizmo[15]; - } - - if (is_settings_gui) - { - lastPar = 0; - - settings_gui(); - } - - if (loRunning) - progress_window(); - - cor_window(); - - if (info_gui) - { - infoLines[infoLines.size() - 2] = "It saves session file in " + working_directory + "\\lio_result_*"; - info_window(infoLines, appShortcuts); - } - - if (compass_ruler) - drawMiniCompassWithRuler(); - - ImGui::Render(); - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -void on_exit() -{ - remove_cache(params); -} - -void mouse(int glut_button, int state, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - - int button = -1; - if (glut_button == GLUT_LEFT_BUTTON) - button = 0; - if (glut_button == GLUT_RIGHT_BUTTON) - button = 1; - if (glut_button == GLUT_MIDDLE_BUTTON) - button = 2; - if (button != -1 && state == GLUT_DOWN) - io.MouseDown[button] = true; - if (button != -1 && state == GLUT_UP) - io.MouseDown[button] = false; - - static int glutMajorVersion = glutGet(GLUT_VERSION) / 10000; - if (state == GLUT_DOWN && (glut_button == 3 || glut_button == 4) && glutMajorVersion < 3) - wheel(glut_button, glut_button == 3 ? 1 : -1, x, y); - - if (!io.WantCaptureMouse) - { - if ((glut_button == GLUT_MIDDLE_BUTTON || glut_button == GLUT_RIGHT_BUTTON) && state == GLUT_DOWN && io.KeyCtrl) - setNewRotationCenter(x, y); - - if (state == GLUT_DOWN) - mouse_buttons |= 1 << glut_button; - else if (state == GLUT_UP) - mouse_buttons = 0; - - mouse_old_x = x; - mouse_old_y = y; - } -} - -int main(int argc, char* argv[]) -{ - spdlog::cfg::load_env_levels(); - spdlog::flush_on(spdlog::level::warn); - set_lidar_odometry_default_params(params); - - try - { - if (checkClHelp(argc, argv)) - { - std::cout << winTitle << "\n\n" - << "USAGE:\n" - << std::filesystem::path(argv[0]).stem().string() << " /?\n" - << std::filesystem::path(argv[0]).stem().string() << " \n" - << std::filesystem::path(argv[0]).stem().string() << " --dump-default-params \n\n" - << "where\n" - << " Path where scan files are located (*.csv, *.laz, *.sn)\n" - << " Path to TOML parameter file (*.toml)\n" - << " Path where processed session should be stored\n" - << " (with alone, default parameters are used and the\n" - << " session is stored in the next free /lio_result_N,\n" - << " as the GUI does)\n" - << " --dump-default-params \n" - << " Write the default parameters to and exit\n" - << " -h, /h, --help, /? Show this help and exit\n\n"; - - return 0; - } - - for (int i = 1; i < argc; ++i) - { - if (std::string(argv[i]) == "--dump-default-params") - { - if (i + 1 >= argc) - { - std::cerr << "--dump-default-params requires an output file (*.toml)" << std::endl; - return 1; - } - const fs::path out_file(argv[i + 1]); - // Value-initialised, as the static `params` is: the NDT grid members carry no - // initialisers, and a default-initialised local would dump stack garbage. - LidarOdometryParams default_params{}; - set_lidar_odometry_default_params(default_params); - TomlIO toml_io; - toml_io.SaveParametersToTomlFile(out_file.string(), default_params); - std::error_code ec; - if (!fs::exists(out_file, ec) || fs::file_size(out_file, ec) == 0 || ec) - { - std::cerr << "Could not write default parameters to: " << out_file.string() << std::endl; - return 1; - } - std::cout << "Default parameters saved to: " << out_file.string() << std::endl; - return 0; - } - } - - if (argc == 2) // running from command line - { - auto path = fs::path(argv[1]); - if (is_directory(path)) - { - std::string working_directory; - std::vector worker_data; - - std::chrono::time_point start, end; - start = std::chrono::system_clock::now(); - - std::atomic loPause{ false }; - if (!step1(path.string(), params, pointsPerFile, imu_data, working_directory, trajectory, worker_data, loPause) || - !step2(worker_data, params, loPause)) - { - std::cerr << "Lidar odometry failed: no results saved" << std::endl; - return 1; - } - - end = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds = end - start; - std::time_t end_time = std::chrono::system_clock::to_time_t(end); - std::cout << "calculations finished computation at " << std::ctime(&end_time) - << "Elapsed time: " << formatTime(elapsed_seconds.count()).c_str() << "s\n"; - - // Only the input folder was given: store the session where the GUI would, - // in the next free lio_result_N under the working directory. - if (working_directory.empty()) - { - std::cerr << "No Mandeye data could be loaded from: '" << path.string() << "'" << std::endl; - return 1; - } - const fs::path result_dir = get_next_result_path(working_directory); - save_results(false, elapsed_seconds.count(), working_directory, worker_data, params, result_dir); - std::cout << "Results saved to folder: '" << result_dir.string() << "'" << std::endl; - remove_cache(params); - } - } - else if (argc == 4) // runnning from command line with custom params - { - // Load parameters from file using original TomlIO class - TomlIO toml_io; - toml_io.LoadParametersFromTomlFile(argv[2], params); - std::cout << "Parameters loaded OK from: " << argv[2] << std::endl; - - std::string working_directory; - std::vector worker_data; - - std::chrono::time_point start, end; - start = std::chrono::system_clock::now(); - - std::atomic loPause{ false }; - if (!step1(argv[1], params, pointsPerFile, imu_data, working_directory, trajectory, worker_data, loPause) || - !step2(worker_data, params, loPause)) - { - std::cerr << "Lidar odometry failed: no results saved" << std::endl; - return 1; - } - - end = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds = end - start; - std::time_t end_time = std::chrono::system_clock::to_time_t(end); - std::cout << "calculations finished computation at " << std::ctime(&end_time) - << "Elapsed time: " << formatTime(elapsed_seconds.count()).c_str() << "s\n"; - - save_results(false, elapsed_seconds.count(), working_directory, worker_data, params, argv[3]); - remove_cache(params); - } - else // full GUI mode - { - std::cout << argv[0] << " input_folder parameters(*.toml) output_folder" << std::endl; - - initGL(&argc, argv, winTitle, display, mouse); - glutCloseFunc(on_exit); - -#ifdef _WIN32 - InitTaskbarProgress(); -#endif - - glutMainLoop(); - - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGLUT_Shutdown(); - ImGui::DestroyContext(); - } - } catch (const std::bad_alloc& e) - { - std::cerr << "System is out of memory : " << e.what() << std::endl; - mandeye::fd::OutOfMemMessage(); - } catch (const std::exception& e) - { - std::cout << e.what(); - } catch (...) - { - std::cerr << "Unknown fatal error occurred." << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/apps/lidar_odometry_step_1_legacy/resource.h b/apps/lidar_odometry_step_1_legacy/resource.h deleted file mode 100644 index 4f3204cae..000000000 --- a/apps/lidar_odometry_step_1_legacy/resource.h +++ /dev/null @@ -1,17 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDI_ICON1 101 // application icon -#define VS_VERSION_INFO 1 // version info - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/apps/lidar_odometry_step_1_legacy/resource.rc b/apps/lidar_odometry_step_1_legacy/resource.rc deleted file mode 100644 index ac2be718a..000000000 --- a/apps/lidar_odometry_step_1_legacy/resource.rc +++ /dev/null @@ -1,54 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "icon.ico" - -// GLFW (used by raylib) only picks up a window/taskbar icon from a -// resource named exactly GLFW_ICON on Windows; without it GLFW falls -// back to the generic IDI_WINLOGO icon at runtime. -GLFW_ICON ICON "icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 0, 0, 100, 1 -PRODUCTVERSION 0, 0, 100, 1 -FILEFLAGSMASK 0x3fL -FILEOS 0x40004 -FILETYPE 0x1 -BEGIN -BLOCK "StringFileInfo" -BEGIN -BLOCK "040904B0" -BEGIN -VALUE "CompanyName", "Mandeye\0" -VALUE "FileDescription", "HDMapping Step 1\0" -VALUE "FileVersion", "0.100.1\0" -VALUE "InternalName", "Odometry\0" -VALUE "LegalCopyright", "(c) 2026 github.com/MapsHD/HDMapping\0" -VALUE "OriginalFilename", "lidar_odometry_step_1.exe\0" -VALUE "ProductVersion", "0.100.1\0" -VALUE "ProgramID", "github.com/MapsHD/HDMapping\0" -VALUE "ProductName", "HDMapping\0" -END -END -BLOCK "VarFileInfo" -BEGIN -VALUE "Translation", 0x409, 0x04B0 -END -END -///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/apps/mandeye_raw_data_viewer_legacy/CMakeLists.txt b/apps/mandeye_raw_data_viewer_legacy/CMakeLists.txt deleted file mode 100644 index 403e4c7c5..000000000 --- a/apps/mandeye_raw_data_viewer_legacy/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -cmake_minimum_required(VERSION 4.0.0) - -# Legacy GLUT + legacy immediate-mode OpenGL build of the raw data viewer, -# kept side by side with apps/mandeye_raw_data_viewer (raylib-based since it -# was ported off GLUT), the same way step2/step3 keep their *_legacy builds. -project(mandeye_raw_data_viewer_legacy) - -# Source files -set(SOURCES - mandeye_raw_data_viewer.cpp - ../lidar_odometry_step_1/toml_io.cpp - ../lidar_odometry_step_1/lidar_odometry.cpp - ../lidar_odometry_step_1/lidar_odometry_utils.cpp - ../lidar_odometry_step_1/lidar_odometry_utils_optimizers.cpp - ../lidar_odometry_step_1/points_global_spill.cpp - ../lidar_odometry_step_1/raw_cloud_loader.cpp - "../../core/src/utils.cpp" -) - -# Windows: add resource file -if(WIN32) - list(APPEND SOURCES resource.rc) -endif() - -add_executable( - mandeye_raw_data_viewer_legacy ${SOURCES} -) - -target_include_directories( - mandeye_raw_data_viewer_legacy - PRIVATE include - ${REPOSITORY_DIRECTORY}/core/include - ${REPOSITORY_DIRECTORY}/core_hd_mapping/include - ${THIRDPARTY_DIRECTORY} - ${THIRDPARTY_DIRECTORY}/glm - ${EIGEN3_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/tomlplusplus/include - ${THIRDPARTY_DIRECTORY}/imgui - ${THIRDPARTY_DIRECTORY}/imgui/backends - ${THIRDPARTY_DIRECTORY}/ImGuizmo - ${THIRDPARTY_DIRECTORY}/glew-cmake/include - ${FREEGLUT_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/json/include - ${THIRDPARTY_DIRECTORY}/portable-file-dialogs-master - ${LASZIP_INCLUDE_DIR}/LASzip/include - ${THIRDPARTY_DIRECTORY}/observation_equations/codes - ${THIRDPARTY_DIRECTORY}/vqf/vqf/cpp - ${THIRDPARTY_DIRECTORY}/Fusion/Fusion) - -target_link_libraries( - mandeye_raw_data_viewer_legacy - PRIVATE step1_run_report vqf Fusion - unordered_dense::unordered_dense - spdlog::spdlog - UTL::include - ${FREEGLUT_LIBRARY} - ${OPENGL_gl_LIBRARY} - OpenGL::GLU - ${PLATFORM_LASZIP_LIB} - ${CORE_LIBRARIES} - ${GUI_LIBRARIES} - ${PLATFORM_MISCELLANEOUS_LIBS} - ${OpenCV_LIBS}) - -if(WIN32) - add_custom_command( - TARGET mandeye_raw_data_viewer_legacy - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy $ - $ - COMMAND_EXPAND_LISTS) -endif() - -if (MSVC) - target_compile_options(mandeye_raw_data_viewer_legacy PRIVATE /bigobj) -endif() - -hdmapping_install_app(mandeye_raw_data_viewer_legacy) diff --git a/apps/mandeye_raw_data_viewer_legacy/icon.ico b/apps/mandeye_raw_data_viewer_legacy/icon.ico deleted file mode 100644 index 710913e34e4b182cb7412859d885face7f382cd6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25645 zcmXV11yoy2n57ho6!+rp?hb|G1Sn8kix+nf4#kT*6qn*2w77e5cXzk2@88{Ua>z+C zlX>$#yZ5^T1M?2}`|t4%h8zap6b1$lcpa{yB!h}fhzz_$m6QFV`roJjJrO?u|MZ+n z%wb?m*5tl?R`*ys&9d+zo`r_}K?)Kd9VBJRcS5Ou z1ydKiL!$YYF^Od4RaZliYOrd%VmfrxZkHpl4^I82tz*q6#- zk}BxRC?zFjYGx*ox3RL6{(9#ffzvdm=7l~hIv&cC-+&I0o)UDY^ibNr+pkVT^ z%r z{o?BCU*|siLV6yXA;9oeOjv}lb`Xq4g-)No`|4OA{KWLaLbEO!znEAK#ChMT4_A}j zZiRmzS&;w4>Yb&n)oxc9>CU*&c|m!(P1rez*QHj3^{Sm!74>}+s{<0Mnw*5{SCR-7 z+=yvnp2evEP%3-Cab;`F(l;L^3=XgEF z$K`cnx&K3uAEf|>+0z6Pbe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N!er14j zKN7PFREf-k?;aII4mv%ejP5Reh4klUNh@Zj>OgV;NO9e^}Irs11?Hk%@bn2p!Vqj5P5FyPLJojrD5H<9}XrCPNDEva9h-597IC6 zT_C#0f^ab`WcBHo9kIzwv^UPXt<@(4_zM3$xwr_;f?oUWyo6DRgoY>$EQ+K$wO9%S ztgQPE%)5|N&3EUz_g@Eyz-s*JaenhXOVkNVSDnY6JVBYFky;rRYxc>X`*@skMBBjh ze>a0giaqba^R~>=Ne(J9LCZ`;)^Wb9s5+00#f~^5$rm2qKU{3dQTJ7*5R6SKmPFa= zU(AR}5LTQVRvr|mh09as+O)_Mc%&zNw_^FfLxVG7FP9|>bk>zEjcf|cJI6BBL>(gu z9f(YQ|Jc*f)BUfsHnuk1|CK#jLHp~dlSeD@e>p6dwas)Ls&Q>VO}?By9@l$Nn*|0U zZYzAMVkbN7Sszf29NvzypI$l!adHN04e0 zazz^=TDV6Qa5~38tEyChuUW(QaP^73gOkVo-G8e6>ebIn8BykpnJFRa9oom0sm1J| z&Ke$+v&aUFs?w7$zDyveoimgx7Tc2 zJ-CdDA4;)9KsFzpjrm^{QV4t(xa=^Hjm-e-OWC4S-Rt&u9 -#include -// clang-format on - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include "../lidar_odometry_step_1/lidar_odometry.h" -#include "../lidar_odometry_step_1/lidar_odometry_utils.h" -#include -#include -#include - -#include - -#include "tbb/tbb.h" -#include - -#include - -#ifdef _WIN32 -#include "resource.h" -#include // <-- Required for ShellExecuteA -#include -#endif - -/////////////////////////////////////////////////////////////////////////////////// - -std::string winTitle = std::string("Raw data viewer ") + HDMAPPING_CONFIGURE_PROJECT_VERSION; - -std::vector infoLines = { "This program is optional step in MANDEYE process", - "", - "It analyzes LiDAR data created by Mission Recorder", - "Next step will be to load data with 'lidar_odometry_step_1' app" }; - -// App specific shortcuts (using empty dummy until needed) -std::vector appShortcuts(80, { "", "", "" }); - -#define SAMPLE_PERIOD (1.0 / 200.0) -namespace fs = std::filesystem; - -ImVec4 pc_color = ImVec4(1.0f, 0.0f, 0.0f, 1.00f); -ImVec4 pc_color2 = ImVec4(0.0f, 0.0f, 1.0f, 1.00f); - -struct AllData -{ - std::vector> timestamps; - std::vector poses; - std::vector points_local; - std::vector lidar_ids; -}; -std::vector all_data; - -struct ImuData -{ - std::vector timestampLidar; - std::vector timestampRel; // timestampLidar shifted so the dataset starts at 0 [s] - double datasetStart = 0.0; // absolute timestamp of the first IMU sample [s] - std::vector angX; - std::vector angY; - std::vector angZ; - std::vector accX; - std::vector accY; - std::vector accZ; - std::vector yaw; - std::vector pitch; - std::vector roll; -}; -ImuData imu_data_plot; - -std::vector laz_files; -std::vector photos_files; -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 fusionConventionNwu = true; -bool fusionConventionEnu = false; -bool fusionConventionNed = false; -int number_of_points_threshold = 20000; -bool is_init = false; -int index_rendered_points_local = -1; -// std::vector> all_points_local; -// std::vector> all_points_local; -// std::vector> all_lidar_ids; -std::vector indexes_to_filename; - -// cached inputs to the chunking pass below, kept around so number_of_points_threshold -// can be changed and re-applied (rebuildAllData) without reloading files from disk -std::vector> g_points_per_file; -std::vector> g_timestamps_cache; -std::vector g_poses_cache; -double vqf_tauAcc = 0.5; -double wx = 1000000.0; -double wy = 1000000.0; -double wz = 1000000.0; -double wom = 1000000.0; -double wfi = 1000000.0; -double wka = 1000000.0; -// bool is_slerp = false; - -double distance_bucket = 0.5; -double polar_angle_deg = 5; -double azimutal_angle_deg = 5; -double max_distance_lidar = 70.0; -int robust_and_accurate_lidar_odometry_iterations = 20; -bool useMultithread = true; - -std::vector> rgd_nn; -std::vector> mean_cov; -bool show_mean_cov = false; -bool show_rgd_nn = false; -bool show_imu_data = false; -bool show_cameras_data = true; -bool is_settings_gui = false; -bool color_by_intensity = false; -float intensity_gamma = 1.0f; - -namespace photos -{ - cv::Mat imgToShow; - std::string imgToShowFn; - GLuint photo_texture_cam0 = 0; - double nearestTs = 0; - int photo_width_cam0 = 0; - int photo_height_cam0 = 0; -} // namespace photos - -/////////////////////////////////////////////////////////////////////////////////// - -static ImVec2 DisplayImageFit(ImTextureID tex, int tex_w, int tex_h, bool allow_upscale = true) -{ - ImVec2 avail = ImGui::GetContentRegionAvail(); - if (tex_w <= 0 || tex_h <= 0 || avail.x <= 0.0f || avail.y <= 0.0f) - return ImVec2(0, 0); - - float sx = avail.x / float(tex_w); - float sy = avail.y / float(tex_h); - float scale = std::min(sx, sy); - if (!allow_upscale) - scale = std::min(scale, 1.0f); - - ImVec2 disp(scale * tex_w, scale * tex_h); - - ImVec2 cur = ImGui::GetCursorPos(); - ImGui::SetCursorPosX(cur.x + (avail.x - disp.x) * 0.5f); // center horizontally - ImGui::Image(tex, disp); - // cursor Y is already advanced by Image; no restore needed - - return disp; -} - -void render_nearest_photo(double ts) -{ - using namespace photos; - // find closest photo - if (photo_files_ts.empty()) - { - return; - } - uint64_t ts_uint64 = static_cast(ts * 1e9); - auto it = photo_files_ts.lower_bound(ts_uint64); - if (it == photo_files_ts.end()) - { - return; - } - const std::string& photo_file = it->second; - if (photo_file == imgToShowFn) - { - return; - } - spdlog::info("render_nearest_photo: {}", photo_file); - cv::Mat img = cv::imread(photo_file); - if (img.empty()) - { - return; - } - cv::Mat img_rgb; - cv::cvtColor(img, img_rgb, cv::COLOR_BGR2RGB); - imgToShow = img_rgb; - imgToShowFn = photo_file; - photos::nearestTs = double(it->first) / 1e9; - // upload to OpenGL texture - photo_width_cam0 = imgToShow.cols; - photo_height_cam0 = imgToShow.rows; - if (photo_texture_cam0 == 0) - { - glGenTextures(1, &photo_texture_cam0); - } - glBindTexture(GL_TEXTURE_2D, photo_texture_cam0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, photo_width_cam0, photo_height_cam0, 0, GL_RGB, GL_UNSIGNED_BYTE, imgToShow.data); - glBindTexture(GL_TEXTURE_2D, 0); -} - -void optimize() -{ -#if 0 - rgd_nn.clear(); - - // NDT::GridParameters rgd_params_sc; - - // rgd_params_sc.resolution_X = distance_bucket; - // rgd_params_sc.resolution_Y = polar_angle_deg; - // rgd_params_sc.resolution_Z = azimutal_angle_deg; - - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - // std::vector points_local_sf; - std::vector points_local; - auto tr = all_data[index_rendered_points_local].poses; - auto trmm = all_data[index_rendered_points_local].poses; - - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - auto lower = std::lower_bound(all_data[index_rendered_points_local].timestamps.begin(), all_data[index_rendered_points_local].timestamps.end(), all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { return lhs.first < rhs; }); - - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - // Eigen::Affine3d m = all_data[index_rendered_points_local].poses[index_pose]; - // Eigen::Vector3d p = m * all_data[index_rendered_points_local].points_local[i].point; - double r_l = all_data[index_rendered_points_local].points_local[i].point.norm(); - if (r_l > 0.5 && all_data[index_rendered_points_local].points_local[i].index_pose != -1 && r_l < max_distance_lidar) - { - // double polar_angle_deg_l = atan2(all_data[index_rendered_points_local].points_local[i].point.y(), all_data[index_rendered_points_local].points_local[i].point.x()) / M_PI * 180.0; - // double azimutal_angle_deg_l = acos(all_data[index_rendered_points_local].points_local[i].point.z() / r_l) / M_PI * 180.0; - all_data[index_rendered_points_local].points_local[i].index_pose = index_pose; - points_local.push_back(all_data[index_rendered_points_local].points_local[i]); - - /////////////////////////////////////////////////////// - // Point3Di p_sl = all_data[index_rendered_points_local].points_local[i]; - // p_sl.point.x() = r_l; - // p_sl.point.y() = polar_angle_deg_l; - // p_sl.point.z() = azimutal_angle_deg_l; - - // points_local_sf.push_back(p_sl); - } - } - } - - //spdlog::info("points_local.size(): {}", points_local.size()); - // points_local - // points_local_sf - - std::vector - point_cloud_global; - std::vector point_cloud_global_sc; - - for (size_t i = 0; i < points_local.size(); i++) - { - Point3Di pg = points_local[i]; - pg.point = tr[points_local[i].index_pose] * pg.point; - point_cloud_global.push_back(pg); - double r_g = pg.point.norm(); - point_cloud_global_sc.emplace_back(r_g, atan2(pg.point.y(), pg.point.x()) / M_PI * 180.0, acos(pg.point.z() / r_g) / M_PI * 180.0); - } - - NDT::GridParameters rgd_params_sc; - - rgd_params_sc.resolution_X = distance_bucket; - rgd_params_sc.resolution_Y = polar_angle_deg; - rgd_params_sc.resolution_Z = azimutal_angle_deg; - Eigen::Vector3d b(rgd_params_sc.resolution_X, rgd_params_sc.resolution_Y, rgd_params_sc.resolution_Z); - - NDTBucketMapType buckets; - update_rgd_spherical_coordinates(rgd_params_sc, buckets, point_cloud_global, point_cloud_global_sc, false); - //update_rgd(rgd_params_sc, buckets, point_cloud_global, {0, 0, 0}); - - std::vector> tripletListA; - std::vector> tripletListP; - std::vector> tripletListB; - - for (size_t i = 0; i < point_cloud_global.size(); i++) - { - - auto index_of_bucket = get_rgd_index_3d(point_cloud_global_sc[i], b); - //auto index_of_bucket = get_rgd_index_3d(point_cloud_global[i].point, b); - auto bucket_it = buckets.find(index_of_bucket); - // no bucket found - if (bucket_it == buckets.end()) - { - continue; - } - auto& this_bucket = bucket_it->second; - - rgd_nn.emplace_back(point_cloud_global[i].point, this_bucket.mean); - - const Eigen::Matrix3d& infm = this_bucket.cov.inverse(); - const double threshold = 100000.0; - - if ((infm.array() > threshold).any()) - { - continue; - } - if ((infm.array() < -threshold).any()) - { - continue; - } - - const Eigen::Affine3d& m_pose = tr[points_local[i].index_pose]; - //spdlog::info("points_local[i].index_pose {}", points_local[i].index_pose); - const Eigen::Vector3d& p_s = points_local[i].point; - const TaitBryanPose pose_s = pose_tait_bryan_from_affine_matrix(m_pose); - double delta_x; - double delta_y; - double delta_z; - - //// - Eigen::Matrix jacobian; - // TaitBryanPose pose_s = pose_tait_bryan_from_affine_matrix((*mposes)[p.index_pose]); - - point_to_point_source_to_target_tait_bryan_wc(delta_x, delta_y, delta_z, - pose_s.px, pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, - p_s.x(), p_s.y(), p_s.z(), this_bucket.mean.x(), this_bucket.mean.y(), this_bucket.mean.z()); - - // spdlog::info("delta_x: {}", delta_x); - // spdlog::info("delta_y: {}", delta_y); - // spdlog::info("delta_z: {}", delta_z); - - if (sqrt(delta_x * delta_x + delta_y * delta_y + delta_z * delta_z) < 0.001) - { - continue; - } - - point_to_point_source_to_target_tait_bryan_wc_jacobian(jacobian, pose_s.px, pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z()); - - int c = points_local[i].index_pose * 6; - - // std::mutex &m = my_mutex[0]; // mutexes[intermediate_points_i.index_pose]; - // std::unique_lock lck(m); - int ir = tripletListB.size(); - - for (int row = 0; row < 3; row++) - { - for (int col = 0; col < 6; col++) - { - if (jacobian(row, col) != 0.0) - { - tripletListA.emplace_back(ir + row, c + col, -jacobian(row, col)); - } - } - } - tripletListB.emplace_back(ir, 0, delta_x); - tripletListB.emplace_back(ir + 1, 0, delta_y); - tripletListB.emplace_back(ir + 2, 0, delta_z); - - tripletListP.emplace_back(ir, ir, infm(0, 0)); - tripletListP.emplace_back(ir, ir + 1, infm(0, 1)); - tripletListP.emplace_back(ir, ir + 2, infm(0, 2)); - tripletListP.emplace_back(ir + 1, ir, infm(1, 0)); - tripletListP.emplace_back(ir + 1, ir + 1, infm(1, 1)); - tripletListP.emplace_back(ir + 1, ir + 2, infm(1, 2)); - tripletListP.emplace_back(ir + 2, ir, infm(2, 0)); - tripletListP.emplace_back(ir + 2, ir + 1, infm(2, 1)); - tripletListP.emplace_back(ir + 2, ir + 2, infm(2, 2)); - - /// - } - - std::vector> odo_edges; - for (size_t i = 1; i < tr.size(); i++) - { - odo_edges.emplace_back(i - 1, i); - } - - std::vector poses; - std::vector poses_desired; - - for (size_t i = 0; i < tr.size(); i++) - { - poses.push_back(pose_tait_bryan_from_affine_matrix(tr[i])); - } - for (size_t i = 0; i < trmm.size(); i++) - { - poses_desired.push_back(pose_tait_bryan_from_affine_matrix(trmm[i])); - } - - for (size_t i = 0; i < odo_edges.size(); i++) - { - Eigen::Matrix relative_pose_measurement_odo; - relative_pose_tait_bryan_wc_case1(relative_pose_measurement_odo, - poses_desired[odo_edges[i].first].px, - poses_desired[odo_edges[i].first].py, - poses_desired[odo_edges[i].first].pz, - poses_desired[odo_edges[i].first].om, - poses_desired[odo_edges[i].first].fi, - poses_desired[odo_edges[i].first].ka, - poses_desired[odo_edges[i].second].px, - poses_desired[odo_edges[i].second].py, - poses_desired[odo_edges[i].second].pz, - poses_desired[odo_edges[i].second].om, - poses_desired[odo_edges[i].second].fi, - poses_desired[odo_edges[i].second].ka); - - Eigen::Matrix delta; - relative_pose_obs_eq_tait_bryan_wc_case1( - delta, - poses[odo_edges[i].first].px, - poses[odo_edges[i].first].py, - poses[odo_edges[i].first].pz, - poses[odo_edges[i].first].om, - poses[odo_edges[i].first].fi, - poses[odo_edges[i].first].ka, - poses[odo_edges[i].second].px, - poses[odo_edges[i].second].py, - poses[odo_edges[i].second].pz, - poses[odo_edges[i].second].om, - poses[odo_edges[i].second].fi, - poses[odo_edges[i].second].ka, - relative_pose_measurement_odo(0, 0), - relative_pose_measurement_odo(1, 0), - relative_pose_measurement_odo(2, 0), - relative_pose_measurement_odo(3, 0), - relative_pose_measurement_odo(4, 0), - relative_pose_measurement_odo(5, 0)); - - Eigen::Matrix jacobian; - relative_pose_obs_eq_tait_bryan_wc_case1_jacobian(jacobian, - poses[odo_edges[i].first].px, - poses[odo_edges[i].first].py, - poses[odo_edges[i].first].pz, - poses[odo_edges[i].first].om, - poses[odo_edges[i].first].fi, - poses[odo_edges[i].first].ka, - poses[odo_edges[i].second].px, - poses[odo_edges[i].second].py, - poses[odo_edges[i].second].pz, - poses[odo_edges[i].second].om, - poses[odo_edges[i].second].fi, - poses[odo_edges[i].second].ka); - - int ir = tripletListB.size(); - - int ic_1 = odo_edges[i].first * 6; - int ic_2 = odo_edges[i].second * 6; - - for (size_t row = 0; row < 6; row++) - { - tripletListA.emplace_back(ir + row, ic_1, -jacobian(row, 0)); - tripletListA.emplace_back(ir + row, ic_1 + 1, -jacobian(row, 1)); - tripletListA.emplace_back(ir + row, ic_1 + 2, -jacobian(row, 2)); - tripletListA.emplace_back(ir + row, ic_1 + 3, -jacobian(row, 3)); - tripletListA.emplace_back(ir + row, ic_1 + 4, -jacobian(row, 4)); - tripletListA.emplace_back(ir + row, ic_1 + 5, -jacobian(row, 5)); - - tripletListA.emplace_back(ir + row, ic_2, -jacobian(row, 6)); - tripletListA.emplace_back(ir + row, ic_2 + 1, -jacobian(row, 7)); - tripletListA.emplace_back(ir + row, ic_2 + 2, -jacobian(row, 8)); - tripletListA.emplace_back(ir + row, ic_2 + 3, -jacobian(row, 9)); - tripletListA.emplace_back(ir + row, ic_2 + 4, -jacobian(row, 10)); - tripletListA.emplace_back(ir + row, ic_2 + 5, -jacobian(row, 11)); - } - - tripletListB.emplace_back(ir, 0, delta(0, 0)); - tripletListB.emplace_back(ir + 1, 0, delta(1, 0)); - tripletListB.emplace_back(ir + 2, 0, delta(2, 0)); - tripletListB.emplace_back(ir + 3, 0, delta(3, 0)); - tripletListB.emplace_back(ir + 4, 0, delta(4, 0)); - tripletListB.emplace_back(ir + 5, 0, delta(5, 0)); - - tripletListP.emplace_back(ir, ir, wx); - tripletListP.emplace_back(ir + 1, ir + 1, wy); - tripletListP.emplace_back(ir + 2, ir + 2, wz); - tripletListP.emplace_back(ir + 3, ir + 3, wom); - tripletListP.emplace_back(ir + 4, ir + 4, wfi); - tripletListP.emplace_back(ir + 5, ir + 5, wka); - } - - int ic = 0; - int ir = tripletListB.size(); - tripletListA.emplace_back(ir, ic * 6 + 0, 1); - tripletListA.emplace_back(ir + 1, ic * 6 + 1, 1); - tripletListA.emplace_back(ir + 2, ic * 6 + 2, 1); - tripletListA.emplace_back(ir + 3, ic * 6 + 3, 1); - tripletListA.emplace_back(ir + 4, ic * 6 + 4, 1); - tripletListA.emplace_back(ir + 5, ic * 6 + 5, 1); - - /*tripletListP.emplace_back(ir, ir, 1000000); - tripletListP.emplace_back(ir + 1, ir + 1, 1000000); - tripletListP.emplace_back(ir + 2, ir + 2, 1000000); - tripletListP.emplace_back(ir + 3, ir + 3, 1000000); - tripletListP.emplace_back(ir + 4, ir + 4, 1000000); - tripletListP.emplace_back(ir + 5, ir + 5, 1000000);*/ - tripletListP.emplace_back(ir, ir, 1); - tripletListP.emplace_back(ir + 1, ir + 1, 1); - tripletListP.emplace_back(ir + 2, ir + 2, 1); - tripletListP.emplace_back(ir + 3, ir + 3, 1); - tripletListP.emplace_back(ir + 4, ir + 4, 1); - tripletListP.emplace_back(ir + 5, ir + 5, 1); - - tripletListB.emplace_back(ir, 0, 0); - tripletListB.emplace_back(ir + 1, 0, 0); - tripletListB.emplace_back(ir + 2, 0, 0); - tripletListB.emplace_back(ir + 3, 0, 0); - tripletListB.emplace_back(ir + 4, 0, 0); - tripletListB.emplace_back(ir + 5, 0, 0); - - Eigen::SparseMatrix matA(tripletListB.size(), tr.size() * 6); - Eigen::SparseMatrix matP(tripletListB.size(), tripletListB.size()); - Eigen::SparseMatrix matB(tripletListB.size(), 1); - - matA.setFromTriplets(tripletListA.begin(), tripletListA.end()); - matP.setFromTriplets(tripletListP.begin(), tripletListP.end()); - matB.setFromTriplets(tripletListB.begin(), tripletListB.end()); - - Eigen::SparseMatrix AtPA(tr.size() * 6, tr.size() * 6); - Eigen::SparseMatrix AtPB(tr.size() * 6, 1); - - { - Eigen::SparseMatrix AtP = matA.transpose() * matP; - AtPA = (AtP)*matA; - AtPB = (AtP)*matB; - } - - tripletListA.clear(); - tripletListP.clear(); - tripletListB.clear(); - - // AtPA += AtPAndt.sparseView(); - // AtPB += AtPBndt.sparseView(); - - // Eigen::SparseMatrix AtPA_I(tr.size() * 6, tr.size() * 6); - // AtPA_I.setIdentity(); - // AtPA += AtPA_I; - - Eigen::SimplicialCholesky> - solver(AtPA); - Eigen::SparseMatrix x = solver.solve(AtPB); - std::vector h_x; - for (int k = 0; k < x.outerSize(); ++k) - { - for (Eigen::SparseMatrix::InnerIterator it(x, k); it; ++it) - { - h_x.push_back(it.value()); - - std::cout << it.value() << " "; - } - } - - if (h_x.size() == 6 * tr.size()) - { - int counter = 0; - - for (size_t i = 0; i < tr.size(); i++) - { - TaitBryanPose pose = pose_tait_bryan_from_affine_matrix(tr[i]); - auto prev_pose = pose; - pose.px += h_x[counter++]; - pose.py += h_x[counter++]; - pose.pz += h_x[counter++]; - pose.om += h_x[counter++]; - pose.fi += h_x[counter++]; - pose.ka += h_x[counter++]; - - // Eigen::Vector3d p1(prev_pose.px, prev_pose.py, prev_pose.pz); - // Eigen::Vector3d p2(pose.px, pose.py, pose.pz); - - // if ((p1 - p2).norm() < 1.0) - //{ - tr[i] = affine_matrix_from_pose_tait_bryan(pose); - //} - } - all_data[index_rendered_points_local].poses = tr; - } - } -#endif - - NDT::GridParameters rgd_params_sc; - - rgd_params_sc.resolution_X = distance_bucket; - rgd_params_sc.resolution_Y = polar_angle_deg; - rgd_params_sc.resolution_Z = azimutal_angle_deg; - - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - std::vector tr = all_data[index_rendered_points_local].poses; // = worker_data[i].intermediate_trajectory; - std::vector trmm = - all_data[index_rendered_points_local].poses; // = worker_data[i].intermediate_trajectory_motion_model; - - std::vector points_local_sf; - std::vector points_local; - - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - auto lower = std::lower_bound( - all_data[index_rendered_points_local].timestamps.begin(), - all_data[index_rendered_points_local].timestamps.end(), - all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - all_data[index_rendered_points_local].points_local[i].index_pose = index_pose; - // Eigen::Affine3d m = all_data[index_rendered_points_local].poses[index_pose]; - // Eigen::Vector3d p = m * all_data[index_rendered_points_local].points_local[i].point; - double r_l = all_data[index_rendered_points_local].points_local[i].point.norm(); - if (r_l > 0.5 && all_data[index_rendered_points_local].points_local[i].index_pose != -1 && r_l < max_distance_lidar) - { - double polar_angle_deg_l = atan2( - all_data[index_rendered_points_local].points_local[i].point.y(), - all_data[index_rendered_points_local].points_local[i].point.x()) / - M_PI * 180.0; - double azimutal_angle_deg_l = - acos(all_data[index_rendered_points_local].points_local[i].point.z() / r_l) / M_PI * 180.0; - - points_local.push_back(all_data[index_rendered_points_local].points_local[i]); - - /////////////////////////////////////////////////////// - Point3Di p_sl = all_data[index_rendered_points_local].points_local[i]; - p_sl.point.x() = r_l; - p_sl.point.y() = polar_angle_deg_l; - p_sl.point.z() = azimutal_angle_deg_l; - - points_local_sf.push_back(p_sl); - } - } - } - - spdlog::info("optimize_sf2"); - for (int iter = 0; iter < robust_and_accurate_lidar_odometry_iterations; iter++) - { - optimize_sf2(points_local, points_local_sf, tr, trmm, rgd_params_sc, useMultithread, wx, wy, wz, wom, wfi, wka); - trmm = tr; - } - - all_data[index_rendered_points_local].poses = tr; - } - - return; -} - -std::vector> get_nn() -{ - std::vector> nn; - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - // for (size_t i = 0; i < all_data[index_rendered_points_local].poses.size(); i++){ - // all_data[index_rendered_points_local].poses[i](0, 3) += 1.0; - // } - - auto worker_data = all_data[index_rendered_points_local]; - - // index data - for (size_t i = 0; i < worker_data.points_local.size(); i++) - { - auto lower = std::lower_bound( - worker_data.timestamps.begin(), - worker_data.timestamps.end(), - worker_data.points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(worker_data.timestamps.begin(), lower) - 1; - - if (index_pose >= 0 && index_pose < worker_data.poses.size()) - { - worker_data.points_local[i].index_pose = index_pose; - } - else - { - worker_data.points_local[i].index_pose = -1; - } - } - - NDT::GridParameters rgd_params; - // rgd_params.resolution_X = 0.3; // distance bucket - // rgd_params.resolution_Y = 0.3; // polar angle deg - // rgd_params.resolution_Z = 0.3; // azimutal angle deg - - rgd_params.resolution_X = distance_bucket; // distance bucket - rgd_params.resolution_Y = polar_angle_deg; // polar angle deg - rgd_params.resolution_Z = azimutal_angle_deg; // azimutal angle deg - - std::vector point_cloud_global; - std::vector points_local; - - std::vector point_cloud_global_sc; - std::vector points_local_sc; - - for (size_t i = 0; i < worker_data.points_local.size(); i++) - { - double r_l = worker_data.points_local[i].point.norm(); - if (r_l > 0.5 && worker_data.points_local[i].index_pose != -1 && r_l < max_distance_lidar) - { - double polar_angle_deg_l = - atan2(worker_data.points_local[i].point.y(), worker_data.points_local[i].point.x()) / M_PI * 180.0; - double azimutal_angle_deg_l = acos(worker_data.points_local[i].point.z() / r_l) / M_PI * 180.0; - - Eigen::Vector3d pp = worker_data.points_local[i].point; - // pps.x() = r; - // pps.y() = polar_angle_deg; - // pps.z() = azimutal_angle_deg; - // point_cloud_spherical_coordinates.push_back(pps); - - Eigen::Affine3d pose = worker_data.poses[worker_data.points_local[i].index_pose]; - - pp = pose * pp; - - Point3Di pg = worker_data.points_local[i]; - pg.point = pp; - - point_cloud_global.push_back(pg); - points_local.push_back(worker_data.points_local[i]); - - /////////////////////////////////////////////////////// - Point3Di p_sl = worker_data.points_local[i]; - p_sl.point.x() = r_l; - p_sl.point.y() = polar_angle_deg_l; - p_sl.point.z() = azimutal_angle_deg_l; - - points_local_sc.push_back(p_sl); - // - double r_g = pg.point.norm(); - double polar_angle_deg_g = atan2(pg.point.y(), pg.point.x()) / M_PI * 180.0; - double azimutal_angle_deg_g = acos(pg.point.z() / r_l) / M_PI * 180.0; - - Eigen::Vector3d p_sg = worker_data.points_local[i].point; - p_sg.x() = r_g; - p_sg.y() = polar_angle_deg_g; - p_sg.z() = azimutal_angle_deg_g; - - point_cloud_global_sc.push_back(p_sg); - } - } - - NDTBucketMapType buckets; - update_rgd_spherical_coordinates(rgd_params, buckets, point_cloud_global, point_cloud_global_sc); - - ///////////// - // std::vector> nn; - Eigen::Vector3d b(rgd_params.resolution_X, rgd_params.resolution_Y, rgd_params.resolution_Z); - - for (size_t i = 0; i < point_cloud_global_sc.size(); i++) - { - auto index_of_bucket = get_rgd_index_3d(point_cloud_global_sc[i], b); - - auto bucket_it = buckets.find(index_of_bucket); - - if (bucket_it != buckets.end()) - { - auto& this_bucket = bucket_it->second; - this_bucket.number_of_points++; - // const auto &curr_mean = points_global[i].point; - const auto& mean = this_bucket.mean; - - nn.emplace_back(point_cloud_global[i].point, mean); - - ////////////// - } - } - } - return nn; -} - -std::vector> get_mean_cov() -{ - std::vector> mc; - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - // for (size_t i = 0; i < all_data[index_rendered_points_local].poses.size(); i++){ - // all_data[index_rendered_points_local].poses[i](0, 3) += 1.0; - // } - - auto worker_data = all_data[index_rendered_points_local]; - - // index data - for (size_t i = 0; i < worker_data.points_local.size(); i++) - { - auto lower = std::lower_bound( - worker_data.timestamps.begin(), - worker_data.timestamps.end(), - worker_data.points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(worker_data.timestamps.begin(), lower) - 1; - - if (index_pose >= 0 && index_pose < worker_data.poses.size()) - worker_data.points_local[i].index_pose = index_pose; - else - worker_data.points_local[i].index_pose = -1; - } - - NDT::GridParameters rgd_params; - // rgd_params.resolution_X = 0.3; // distance bucket - // rgd_params.resolution_Y = 0.3; // polar angle deg - // rgd_params.resolution_Z = 0.3; // azimutal angle deg - - rgd_params.resolution_X = distance_bucket; // distance bucket - rgd_params.resolution_Y = polar_angle_deg; // polar angle deg - rgd_params.resolution_Z = azimutal_angle_deg; // azimutal angle deg - - std::vector point_cloud_global; - std::vector points_local; - - std::vector point_cloud_global_sc; - std::vector points_local_sc; - - for (size_t i = 0; i < worker_data.points_local.size(); i++) - { - double r_l = worker_data.points_local[i].point.norm(); - if (r_l > 0.5 && worker_data.points_local[i].index_pose != -1 && r_l < max_distance_lidar) - { - double polar_angle_deg_l = - atan2(worker_data.points_local[i].point.y(), worker_data.points_local[i].point.x()) / M_PI * 180.0; - double azimutal_angle_deg_l = acos(worker_data.points_local[i].point.z() / r_l) / M_PI * 180.0; - - Eigen::Vector3d pp = worker_data.points_local[i].point; - // pps.x() = r; - // pps.y() = polar_angle_deg; - // pps.z() = azimutal_angle_deg; - // point_cloud_spherical_coordinates.push_back(pps); - - Eigen::Affine3d pose = worker_data.poses[worker_data.points_local[i].index_pose]; - - pp = pose * pp; - - Point3Di pg = worker_data.points_local[i]; - pg.point = pp; - - point_cloud_global.push_back(pg); - points_local.push_back(worker_data.points_local[i]); - - /////////////////////////////////////////////////////// - Point3Di p_sl = worker_data.points_local[i]; - p_sl.point.x() = r_l; - p_sl.point.y() = polar_angle_deg_l; - p_sl.point.z() = azimutal_angle_deg_l; - - points_local_sc.push_back(p_sl); - // - double r_g = pg.point.norm(); - double polar_angle_deg_g = atan2(pg.point.y(), pg.point.x()) / M_PI * 180.0; - double azimutal_angle_deg_g = acos(pg.point.z() / r_l) / M_PI * 180.0; - - Eigen::Vector3d p_sg = worker_data.points_local[i].point; - p_sg.x() = r_g; - p_sg.y() = polar_angle_deg_g; - p_sg.z() = azimutal_angle_deg_g; - - point_cloud_global_sc.push_back(p_sg); - } - } - - NDTBucketMapType buckets; - update_rgd_spherical_coordinates(rgd_params, buckets, point_cloud_global, point_cloud_global_sc); - - ///////////// - Eigen::Vector3d b(rgd_params.resolution_X, rgd_params.resolution_Y, rgd_params.resolution_Z); - - for (const auto& b : buckets) - { - auto& this_bucket = b.second; - - mc.emplace_back(this_bucket.mean, this_bucket.cov); - } - } - - return mc; -} - -// Re-chunks the already-loaded points (g_points_per_file / g_timestamps_cache / g_poses_cache) -// into all_data using the current number_of_points_threshold. Smaller thresholds mean each -// Index step in the toolbar covers less time, giving finer time navigation. -void rebuildAllData(bool preserve_position) -{ - double preserved_time = 0.0; - bool have_preserved_time = false; - if (preserve_position && index_rendered_points_local >= 0 && index_rendered_points_local < static_cast(all_data.size()) && - !all_data[index_rendered_points_local].timestamps.empty()) - { - preserved_time = all_data[index_rendered_points_local].timestamps.front().first; - have_preserved_time = true; - } - - all_data.clear(); - all_data.shrink_to_fit(); - indexes_to_filename.clear(); - indexes_to_filename.shrink_to_fit(); - - if (number_of_points_threshold < 1) - number_of_points_threshold = 1; - - const auto& pointsPerFile = g_points_per_file; - const auto& timestamps = g_timestamps_cache; - const auto& poses = g_poses_cache; - - int number_of_points = 0; - for (const auto& pp : pointsPerFile) - number_of_points += static_cast(pp.size()); - - spdlog::info("Number of points: {}", number_of_points); - spdlog::info("Start indexing points"); - - std::vector points_local; - std::vector lidar_ids; - - for (size_t i = 0; i < pointsPerFile.size(); i++) - { - std::cout << "Indexed file " << i + 1 << "/" << pointsPerFile.size() << "\r"; - - for (const auto& pp : pointsPerFile[i]) - { - auto lower = std::lower_bound( - timestamps.begin(), - timestamps.end(), - pp.timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = static_cast(std::distance(timestamps.begin(), lower)) - 1; - - if (index_pose >= 0 && index_pose < static_cast(poses.size())) - { - points_local.push_back(pp); - lidar_ids.push_back(pp.lidarid); - } - - if (points_local.size() > static_cast(number_of_points_threshold)) - { - indexes_to_filename.push_back(static_cast(i)); - - AllData data; - data.points_local = points_local; - data.lidar_ids = lidar_ids; - - for (size_t k = 0; k < timestamps.size(); k++) - { - if (timestamps[k].first >= points_local[0].timestamp && - timestamps[k].first <= points_local[points_local.size() - 1].timestamp) - { - data.timestamps.push_back(timestamps[k]); - data.poses.push_back(poses[k]); - } - } - - // correct points timestamps - if (data.timestamps.size() > 2) - { - double ts_begin = data.timestamps[0].first; - double ts_step = - (data.timestamps[data.timestamps.size() - 1].first - data.timestamps[0].first) / data.points_local.size(); - - for (size_t pp_i = 0; pp_i < data.points_local.size(); pp_i++) - data.points_local[pp_i].timestamp = ts_begin + pp_i * ts_step; - } - - all_data.push_back(data); - - points_local.clear(); - lidar_ids.clear(); - } - } - } - - spdlog::info("Indexing points finished\n"); - - if (all_data.size() > 0) - { - is_init = true; - index_rendered_points_local = 0; - - if (have_preserved_time) - { - for (size_t i = 0; i < all_data.size(); i++) - { - if (!all_data[i].timestamps.empty() && preserved_time >= all_data[i].timestamps.front().first && - preserved_time <= all_data[i].timestamps.back().first) - { - index_rendered_points_local = static_cast(i); - break; - } - } - } - } - else - { - is_init = false; - index_rendered_points_local = -1; - } -} - -void loadFiles(std::vector input_file_names) -{ - LidarOdometryParams params; // dummy for load_data function - params.save_calibration_validation = false; - 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; - - std::vector> pointsPerFile; - Imu imu_data; - - // no files selected, quit loading - if (input_file_names.empty()) - return; - - if (load_data(input_file_names, params, pointsPerFile, imu_data, false)) - { - // clear possible previous data - - all_data.clear(); - all_data.shrink_to_fit(); - - imu_data_plot.timestampLidar.clear(); - imu_data_plot.timestampRel.clear(); - imu_data_plot.datasetStart = 0.0; - imu_data_plot.angX.clear(); - imu_data_plot.angY.clear(); - imu_data_plot.angZ.clear(); - imu_data_plot.accX.clear(); - imu_data_plot.accY.clear(); - imu_data_plot.accZ.clear(); - imu_data_plot.yaw.clear(); - imu_data_plot.pitch.clear(); - imu_data_plot.roll.clear(); - - imu_data_plot.timestampLidar.shrink_to_fit(); - imu_data_plot.timestampRel.shrink_to_fit(); - imu_data_plot.angX.shrink_to_fit(); - imu_data_plot.angY.shrink_to_fit(); - imu_data_plot.angZ.shrink_to_fit(); - imu_data_plot.accX.shrink_to_fit(); - imu_data_plot.accY.shrink_to_fit(); - imu_data_plot.accZ.shrink_to_fit(); - imu_data_plot.yaw.shrink_to_fit(); - imu_data_plot.pitch.shrink_to_fit(); - imu_data_plot.roll.shrink_to_fit(); - - photo_files_ts.clear(); - - laz_files.clear(); - - // specific processing for RAW data viewer - - std::sort(input_file_names.begin(), input_file_names.end()); - for (const auto& fileName : input_file_names) - { - std::string ext = fs::path(fileName).extension().string(); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - - if (ext == ".laz" || ext == ".las") - laz_files.push_back(fileName); - else if (ext == ".jpg" || ext == ".jpeg") - { - photos_files.push_back(fileName); - // decode filename e.g.: ` cam0_1761264773592270949.jpg` - const std::string filename = fs::path(fileName).stem().string(); - std::string cam_id = filename.substr(0, filename.find("_")); - std::string timestamp = filename.substr(filename.find("_") + 1, filename.size()); - - spdlog::info("cam_id: {}", cam_id); - spdlog::info("timestamp: {}", timestamp); - spdlog::info("filename: {}", filename); - - if (cam_id == "cam0" && !timestamp.empty()) - { - try - { - uint64_t ts = std::stoull(timestamp); - photo_files_ts[ts] = fileName; - } catch (const std::exception& e) - { - spdlog::error("Error parsing timestamp from filename: {} - {}", filename, e.what()); - } - } - } - } - - // rest of RAW data viewer processing - - // VQF initialization - double avg_dt = SAMPLE_PERIOD; - if (imu_data.size() >= 2) - { - const double t0 = std::get<0>(imu_data.front()).first; - const double t1 = std::get<0>(imu_data.back()).first; - const double duration = t1 - t0; - - if (t1 > t0) - avg_dt = duration / static_cast(imu_data.size() - 1); - - if (duration > 24 * 60 * 60) - { - spdlog::error("Session is absurdly long : start time : {}, end time {}", t0, t1); - spdlog::error("Setting rate to {}", SAMPLE_PERIOD); - avg_dt = SAMPLE_PERIOD; - } - } - - VQFParams vqf_params; - vqf_params.tauAcc = vqf_tauAcc > 0.0 ? vqf_tauAcc : 3.0; - // produce warning - if (std::fabs(avg_dt - SAMPLE_PERIOD) > 0.01) - { - spdlog::warn("The dt found is strange : {}", avg_dt); - } - spdlog::info("avg_dt: {}", avg_dt); - VQF vqf(vqf_params, avg_dt); - - std::map> trajectory; - - int counter = 1; - - for (const auto& [timestamp_pair, gyr, acc] : imu_data) - { - const double g = 9.81; - vqf_real_t gyr_vqf[3] = { static_cast(gyr.x()), static_cast(gyr.y()), static_cast(gyr.z()) }; - vqf_real_t acc_vqf[3] = { static_cast(acc.x()) * g, - static_cast(acc.y()) * g, - static_cast(acc.z()) * g }; - - vqf.update(gyr_vqf, acc_vqf); - - vqf_real_t quat[4]; - vqf.getQuat6D(quat); - Eigen::Quaterniond d(quat[0], quat[1], quat[2], quat[3]); - Eigen::Affine3d t{ Eigen::Matrix4d::Identity() }; - t.rotate(d); - - trajectory[timestamp_pair.first] = std::pair(t.matrix(), timestamp_pair.second); - - Eigen::Vector3d euler = d.toRotationMatrix().eulerAngles(0, 1, 2) * (180.0 / M_PI); - counter++; - if (counter % 100 == 0) - { - spdlog::info("[{} of {}]: Roll {}, Pitch {}, Yaw {}", counter, imu_data.size(), euler.x(), euler.y(), euler.z()); - } - - // log it for implot - imu_data_plot.timestampLidar.push_back(timestamp_pair.first); - imu_data_plot.angX.push_back(gyr.x()); - imu_data_plot.angY.push_back(gyr.y()); - imu_data_plot.angZ.push_back(gyr.z()); - imu_data_plot.accX.push_back(acc.x()); - imu_data_plot.accY.push_back(acc.y()); - imu_data_plot.accZ.push_back(acc.z()); - imu_data_plot.yaw.push_back(euler.z()); - imu_data_plot.pitch.push_back(euler.y()); - imu_data_plot.roll.push_back(euler.x()); - } - - // timeline x-axis is shown relative to the first IMU sample so it starts at 0 [s]; - // datasetStart keeps the absolute value for reference / annotations - if (!imu_data_plot.timestampLidar.empty()) - { - imu_data_plot.datasetStart = imu_data_plot.timestampLidar.front(); - imu_data_plot.timestampRel.reserve(imu_data_plot.timestampLidar.size()); - for (double ts : imu_data_plot.timestampLidar) - imu_data_plot.timestampRel.push_back(ts - imu_data_plot.datasetStart); - } - - std::vector> timestamps; - std::vector poses; - for (const auto& t : trajectory) - { - timestamps.emplace_back(t.first, t.second.second); - Eigen::Affine3d m; - m.matrix() = t.second.first; - poses.push_back(m); - } - - g_points_per_file = std::move(pointsPerFile); - g_timestamps_cache = std::move(timestamps); - g_poses_cache = std::move(poses); - - rebuildAllData(false); - } -} - -void openFolder() -{ - std::string input_folder_name; - std::vector input_file_names; - input_folder_name = mandeye::fd::SelectFolder("Select Mandeye data folder"); - - spdlog::info("Selected folder: '{}'", input_folder_name); - - const std::vector subDirs{ "", "CAMERA_0" }; - for (const auto& subdir : subDirs) - { - const auto location = std::filesystem::path(input_folder_name) / subdir; - if (fs::exists(location)) - { - for (const auto& entry : fs::directory_iterator(location)) - if (entry.is_regular_file()) - input_file_names.push_back(entry.path().string()); - } - } - - loadFiles(input_file_names); -} - -void openFiles() -{ - std::vector input_file_names = mandeye::fd::OpenFileDialog("Load all files", mandeye::fd::All_Filter, true); - - loadFiles(input_file_names); -} - -void imu_data_gui() -{ - ImGui::Begin("IMU data", &show_imu_data); - { - if (imu_data_plot.timestampRel.size() > 0) - { - // All timelines below use time relative to the start of the dataset (t = 0 s). - // t0 is that start expressed as an absolute LiDAR timestamp in seconds. - const double t0 = imu_data_plot.datasetStart; - - ImGui::TextDisabled("Time axis is relative to dataset start."); - ImGui::Text("Dataset start (t = 0 s) = %.6f s absolute LiDAR time", t0); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Add this offset to any x-axis value to get the absolute LiDAR timestamp [s]"); - ImGui::Text("Dataset duration: %.3f s", imu_data_plot.timestampRel.back()); - ImGui::Separator(); - - static double x_min = 0.0; - static double x_max = 20.0; - - // currently rendered point block, expressed on the relative time axis - double annotation = 0; - bool has_annotation = false; - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - if (all_data[index_rendered_points_local].timestamps.size() > 0) - { - annotation = all_data[index_rendered_points_local].timestamps.front().first - t0; - has_annotation = true; - } - } - - const double* ts = imu_data_plot.timestampRel.data(); - const int ts_n = (int)imu_data_plot.timestampRel.size(); - - if (ImPlot::BeginPlot("IMU - acceleration 'm/s^2", ImVec2(-1, 0))) - { - ImPlot::SetupAxisLimits(ImAxis_X1, x_min, x_max, ImGuiCond_Once); - ImPlot::SetupAxisLinks(ImAxis_X1, &x_min, &x_max); - ImPlot::SetupAxis(ImAxis_X1, "time since dataset start [s]"); - ImPlot::PlotLine("accX", ts, imu_data_plot.accX.data(), ts_n); - ImPlot::PlotLine("accY", ts, imu_data_plot.accY.data(), ts_n); - ImPlot::PlotLine("accZ", ts, imu_data_plot.accZ.data(), ts_n); - if (has_annotation) - ImPlot::TagX(annotation, ImVec4(1, 0, 0, 1)); - ImPlot::EndPlot(); - } - - if (ImPlot::BeginPlot("Imu - gyro", ImVec2(-1, 0))) - { - ImPlot::SetupAxisLimits(ImAxis_X1, x_min, x_max, ImGuiCond_Once); - ImPlot::SetupAxisLinks(ImAxis_X1, &x_min, &x_max); - ImPlot::SetupAxis(ImAxis_X1, "time since dataset start [s]"); - ImPlot::PlotLine("angX", ts, imu_data_plot.angX.data(), ts_n); - ImPlot::PlotLine("angY", ts, imu_data_plot.angY.data(), ts_n); - ImPlot::PlotLine("angZ", ts, imu_data_plot.angZ.data(), ts_n); - if (has_annotation) - ImPlot::TagX(annotation, ImVec4(1, 0, 0, 1)); - ImPlot::EndPlot(); - } - - if (ImPlot::BeginPlot("IMU - AHRS angles [deg]", ImVec2(-1, 0))) - { - ImPlot::SetupAxisLimits(ImAxis_X1, x_min, x_max, ImGuiCond_Once); - ImPlot::SetupAxisLinks(ImAxis_X1, &x_min, &x_max); - ImPlot::SetupAxis(ImAxis_X1, "time since dataset start [s]"); - ImPlot::PlotLine("yaw", ts, imu_data_plot.yaw.data(), ts_n); - ImPlot::PlotLine("pitch", ts, imu_data_plot.pitch.data(), ts_n); - ImPlot::PlotLine("roll", ts, imu_data_plot.roll.data(), ts_n); - if (has_annotation) - ImPlot::TagX(annotation, ImVec4(1, 0, 0, 1)); - ImPlot::EndPlot(); - } - - if (!photo_files_ts.empty() && ImPlot::BeginPlot("Photos")) - { - ImPlot::SetupAxisLimits(ImAxis_X1, x_min, x_max, ImGuiCond_Once); - ImPlot::SetupAxisLinks(ImAxis_X1, &x_min, &x_max); - ImPlot::SetupAxis(ImAxis_X1, "time since dataset start [s]"); - // plot photos timestamps, also relative to the dataset start - std::vector photo_timestamps; - std::vector dummy; - for (const auto& [ts_ns, fn] : photo_files_ts) - { - photo_timestamps.push_back(static_cast(ts_ns) / 1e9 - t0); - dummy.push_back(0.0); - } - ImPlot::PlotScatter("photos", photo_timestamps.data(), dummy.data(), (int)photo_timestamps.size()); - if (has_annotation) - ImPlot::TagX(annotation, ImVec4(1, 0, 0, 1)); - ImPlot::EndPlot(); - } - } - - if (ImGui::Button("Save 'ts gyr_x gyr_y gyr_z acc_x acc_y acc_z yaw_rad pitch_rad roll_rad' to csv")) - { - std::string output_file_name = ""; - output_file_name = mandeye::fd::SaveFileDialog("Save IMU data", {}, ""); - spdlog::info("file to save: '{}'", output_file_name); - - ofstream file; - file.open(output_file_name); - file << std::setprecision(20); - for (size_t i = 0; i < imu_data_plot.timestampLidar.size(); i++) - { - file << imu_data_plot.timestampLidar[i] << " " << imu_data_plot.angX[i] << " " << imu_data_plot.angY[i] << " " - << imu_data_plot.angZ[i] << " " << imu_data_plot.accX[i] << " " << imu_data_plot.accY[i] << " " - << imu_data_plot.accZ[i] << " " << imu_data_plot.yaw[i] << " " << imu_data_plot.pitch[i] << " " - << imu_data_plot.roll[i] << std::endl; - } - - file.close(); - } - } - - ImGui::End(); -} - -void settings_gui() -{ - if (ImGui::Begin("Settings", &is_settings_gui)) - { - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputInt("number_of_points_threshold", &number_of_points_threshold); - if (number_of_points_threshold < 1) - number_of_points_threshold = 1; - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Max number of points per rendered chunk (one 'Index' step)."); - ImGui::Text("Lower = shorter time span per chunk = finer time navigation with the Index slider."); - ImGui::EndTooltip(); - } - ImGui::BeginDisabled(!is_init); - ImGui::SameLine(); - if (ImGui::Button("Rebin")) - rebuildAllData(true); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Re-chunk the already loaded data with the new threshold, keeping the current time position"); - ImGui::EndDisabled(); - if (is_init) - ImGui::Text("Chunks: %d", static_cast(all_data.size())); - - ImGui::InputDouble("VQF tauAcc [s]", &vqf_tauAcc); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("VQF accelerometer time constant (tauAcc) in seconds."); - ImGui::Text("Controls how strongly accelerometer corrects the gyroscope-based orientation."); - ImGui::Text("Higher = more gyro trust (stable but may drift). Lower = more acc trust (noisy but no drift)."); - ImGui::EndTooltip(); - } - - // ImGui::Checkbox("is_slerp", &is_slerp); - - ImGui::PopItemWidth(); - - ImGui::BeginDisabled(!is_init); - if (ImGui::Button("Save point cloud")) - { - std::string output_file_name = ""; - output_file_name = mandeye::fd::SaveFileDialog("Save las or laz file", mandeye::fd::LAS_LAZ_filter); - - if (output_file_name.size() > 0) - { - spdlog::info("las or laz file to save: '{}'", output_file_name); - - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - - /*if (index_rendered_points_local >= 0 && index_rendered_points_local < all_points_local.size()) - { - for (size_t i = 0; i < all_points_local[index_rendered_points_local].size(); i++) - { - pointcloud.emplace_back(all_points_local[index_rendered_points_local][i].point.x(), - all_points_local[index_rendered_points_local][i].point.y(), all_points_local[index_rendered_points_local][i].point.z()); - intensity.push_back(all_points_local[index_rendered_points_local][i].intensity); - timestamps.push_back(all_points_local[index_rendered_points_local][i].timestamp); - } - }*/ - - if (!exportLaz(output_file_name, pointcloud, intensity, timestamps, 0, 0, 0)) - spdlog::error("problem with saving file: '{}'", output_file_name); - } - } - ImGui::EndDisabled(); - - ImGui::Separator(); - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("Distance bucket [m]", &distance_bucket); - ImGui::InputDouble("Polar angle [deg]", &polar_angle_deg); - ImGui::InputDouble("Azimutal angle [deg]", &azimutal_angle_deg); - ImGui::InputDouble("Max distance LiDAR", &max_distance_lidar); - ImGui::InputInt("robust_and_accurate_lidar_odometry_iterations", &robust_and_accurate_lidar_odometry_iterations); - ImGui::Checkbox("Use multithread", &useMultithread); - ImGui::Text("Pose component weights for optimization:"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Value guideline:"); - ImGui::Text("1e6: almost rigid motion, prior dominates (default)"); - ImGui::Text("1e4: small corrections allowed"); - ImGui::Text("1e2: free alignment"); - ImGui::Text(" 0: motion model ignored"); - ImGui::EndTooltip(); - } - ImGui::InputDouble("wx", &wx); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Translation penaltie for %s", xText); - ImGui::InputDouble("wy", &wy); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Translation penaltie for %s", yText); - ImGui::InputDouble("wz", &wz); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Translation penaltie for %s", zText); - ImGui::InputDouble("wom", &wom); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - ImGui::InputDouble("wfi", &wfi); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - ImGui::InputDouble("wka", &wka); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - ImGui::PopItemWidth(); - - ImGui::NewLine(); - - if (ImGui::Button("Optimize")) - optimize(); - - ImGui::Separator(); - - if (ImGui::Button("Print to console debug text")) - { - double max_diff = 0; - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - auto lower = std::lower_bound( - all_data[index_rendered_points_local].timestamps.begin(), - all_data[index_rendered_points_local].timestamps.end(), - all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - - spdlog::info( - "poses {}/{}: point TS [s] - pose TS [s] = ... [s]", - index_pose, - all_data[index_rendered_points_local].poses.size()); - - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - spdlog::info( - "{:.20g} - {:.20g} = {:.20g}", - all_data[index_rendered_points_local].points_local[i].timestamp, - all_data[index_rendered_points_local].timestamps[index_pose].first, - all_data[index_rendered_points_local].points_local[i].timestamp - - all_data[index_rendered_points_local].timestamps[index_pose].first); - - if (fabs( - all_data[index_rendered_points_local].points_local[i].timestamp - - all_data[index_rendered_points_local].timestamps[index_pose].first) > max_diff) - { - // spdlog::info("{:.20g}", all_data[index_rendered_points_local].points_local[i].timestamp); - max_diff = fabs( - all_data[index_rendered_points_local].points_local[i].timestamp - - all_data[index_rendered_points_local].timestamps[index_pose].first); - } - } - } - spdlog::info("max_diff: {} [s]", max_diff); - spdlog::info("----------------"); - for (size_t k = 0; k < all_data[index_rendered_points_local].timestamps.size(); k++) - spdlog::info("{:.20g}", all_data[index_rendered_points_local].timestamps[k].first); - } - } - } - - ImGui::End(); -} - -void display() -{ - ImGuiIO& io = ImGui::GetIO(); - glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - glClearColor(bg_color.x * bg_color.w, bg_color.y * bg_color.w, bg_color.z * bg_color.w, bg_color.w); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - updateCameraTransition(); - - viewLocal = Eigen::Affine3f::Identity(); - - if (!is_ortho) - { - reshape((GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - viewLocal.translate(rotation_center); - - viewLocal.translate(Eigen::Vector3f(translate_x, translate_y, translate_z)); - if (!lock_z) - viewLocal.rotate(Eigen::AngleAxisf(rotate_x * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - else - viewLocal.rotate(Eigen::AngleAxisf(-90.0 * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - viewLocal.rotate(Eigen::AngleAxisf(rotate_y * DEG_TO_RAD, Eigen::Vector3f::UnitZ())); - - viewLocal.translate(-rotation_center); - - glLoadMatrixf(viewLocal.matrix().data()); - } - else - updateOrthoView(); - - // - /* glPointSize(point_size); - glBegin(GL_POINTS); - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_points_local.size()) - { - for (size_t i = 0; i < all_points_local[index_rendered_points_local].size(); i++) - { - if (all_lidar_ids[index_rendered_points_local][i] == 0) - { - glColor3f(pc_color.x, pc_color.y, pc_color.z); - } - else - { - glColor3f(pc_color2.x, pc_color2.y, pc_color2.z); - } - glVertex3f(all_points_local[index_rendered_points_local][i].point.x(), - all_points_local[index_rendered_points_local][i].point.y(), all_points_local[index_rendered_points_local][i].point.z()); - } - } - glEnd(); - glPointSize(1);*/ - - glPointSize(point_size); - glBegin(GL_POINTS); - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - double max_diff = 0.0; - float max_intensity = 0.0f; - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - if (color_by_intensity && all_data[index_rendered_points_local].points_local[i].intensity > max_intensity) - max_intensity = all_data[index_rendered_points_local].points_local[i].intensity; - - auto lower = std::lower_bound( - all_data[index_rendered_points_local].timestamps.begin(), - all_data[index_rendered_points_local].timestamps.end(), - all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - if (fabs( - all_data[index_rendered_points_local].points_local[i].timestamp - - all_data[index_rendered_points_local].timestamps[index_pose].first) > max_diff) - { - max_diff = fabs( - all_data[index_rendered_points_local].points_local[i].timestamp - - all_data[index_rendered_points_local].timestamps[index_pose].first); - } - } - } - const float inv_max_intensity = max_intensity > 0.0f ? 1.0f / max_intensity : 0.0f; - - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - auto lower = std::lower_bound( - all_data[index_rendered_points_local].timestamps.begin(), - all_data[index_rendered_points_local].timestamps.end(), - all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - - if (max_diff < 0.1) - { - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - // if (fabs(all_data[index_rendered_points_local].timestamps[index_pose].first - - // all_data[index_rendered_points_local].points_local[i].timestamp) < 0.001) - //{ - Eigen::Affine3d m = all_data[index_rendered_points_local].poses[index_pose]; - Eigen::Vector3d p = m * all_data[index_rendered_points_local].points_local[i].point; - - if (color_by_intensity) - { - float ii = all_data[index_rendered_points_local].points_local[i].intensity * inv_max_intensity; - ii = std::clamp(ii, 0.0f, 1.0f); - if (intensity_gamma != 1.0f) - ii = std::pow(ii, intensity_gamma); - glColor3f(ii, ii, ii); - } - else if (all_data[index_rendered_points_local].lidar_ids[i] == 0) - glColor3f(pc_color.x, pc_color.y, pc_color.z); - else - glColor3f(pc_color2.x, pc_color2.y, pc_color2.z); - - glVertex3f(p.x(), p.y(), p.z()); - //} - } - } - } - } - glEnd(); - glPointSize(1); - - if (index_rendered_points_local >= 0 && index_rendered_points_local < all_data.size()) - { - for (size_t i = 0; i < all_data[index_rendered_points_local].points_local.size(); i++) - { - auto lower = std::lower_bound( - all_data[index_rendered_points_local].timestamps.begin(), - all_data[index_rendered_points_local].timestamps.end(), - all_data[index_rendered_points_local].points_local[i].timestamp, - [](std::pair lhs, double rhs) -> bool - { - return lhs.first < rhs; - }); - - int index_pose = std::distance(all_data[index_rendered_points_local].timestamps.begin(), lower) - 1; - - if (index_pose >= 0 && index_pose < all_data[index_rendered_points_local].poses.size()) - { - /*Eigen::Affine3d m = all_data[index_rendered_points_local].poses[index_pose]; - Eigen::Vector3d p = m * all_data[index_rendered_points_local].points_local[i].point; - - if (all_data[index_rendered_points_local].lidar_ids[i] == 0) - { - glColor3f(pc_color.x, pc_color.y, pc_color.z); - } - else - { - glColor3f(pc_color2.x, pc_color2.y, pc_color2.z); - } - glVertex3f(p.x(), p.y(), p.z());*/ - - Eigen::Affine3d m = all_data[index_rendered_points_local].poses[index_pose]; - glLineWidth(2.0); - glBegin(GL_LINES); - glColor3f(1.0f, 0.0f, 0.0f); - glVertex3f(m(0, 3), m(1, 3), m(2, 3)); - glVertex3f(m(0, 3) + m(0, 0), m(1, 3) + m(1, 0), m(2, 3) + m(2, 0)); - - glColor3f(0.0f, 1.0f, 0.0f); - glVertex3f(m(0, 3), m(1, 3), m(2, 3)); - glVertex3f(m(0, 3) + m(0, 1), m(1, 3) + m(1, 1), m(2, 3) + m(2, 1)); - - glColor3f(0.0f, 0.0f, 1.0f); - glVertex3f(m(0, 3), m(1, 3), m(2, 3)); - glVertex3f(m(0, 3) + m(0, 2), m(1, 3) + m(1, 2), m(2, 3) + m(2, 2)); - glEnd(); - glLineWidth(1.0); - break; - } - } - } - - if (show_rgd_nn) - { - glColor3f(0, 0, 0); - glBegin(GL_LINES); - for (const auto& nn : rgd_nn) - { - glVertex3f(nn.first.x(), nn.first.y(), nn.first.z()); - glVertex3f(nn.second.x(), nn.second.y(), nn.second.z()); - } - glEnd(); - } - - if (show_mean_cov) - { - for (const auto& mc : mean_cov) - draw_ellipse(mc.second, mc.first, Eigen::Vector3f(1, 0, 0), 1); - } - - showAxes(); - - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGLUT_NewFrame(); - ImGui::NewFrame(); - - ShowMainDockSpace(); - - view_kbd_shortcuts(); - - if (all_data.size() > 0) - { - if ((!io.KeyCtrl && !io.KeyShift && ImGui::IsKeyPressed(ImGuiKey_RightArrow, true)) || ImGui::IsKeyPressed(ImGuiKey_PageUp, true) || - ImGui::IsKeyPressed(ImGuiKey_KeypadAdd, true)) - index_rendered_points_local += 1; - if ((!io.KeyCtrl && !io.KeyShift && ImGui::IsKeyPressed(ImGuiKey_LeftArrow, true)) || - ImGui::IsKeyPressed(ImGuiKey_PageDown, true) || ImGui::IsKeyPressed(ImGuiKey_KeypadSubtract, true)) - index_rendered_points_local -= 1; - - if (index_rendered_points_local < 0) - index_rendered_points_local = 0; - if (index_rendered_points_local >= all_data.size()) - index_rendered_points_local = all_data.size() - 1; - } - - // ask to load the nearest photo - if (show_cameras_data && index_rendered_points_local >= 0 && index_rendered_points_local < indexes_to_filename.size()) - { - double ts = all_data[index_rendered_points_local].points_local[0].timestamp; // * 1e9; - render_nearest_photo(ts); - } - - if (ImGui::BeginMainMenuBar()) - { - { - if (ImGui::Button("Open folder")) - openFolder(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select folder containing files for analyze (Ctrl+O)"); - - ImGui::SameLine(); - - if (ImGui::ArrowButton("##menuArrow", ImGuiDir_Down)) - ImGui::OpenPopup("OpenMenu"); - - if (ImGui::BeginPopup("OpenMenu")) - { - if (ImGui::MenuItem("Open files")) - openFiles(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select files for analyze"); - - ImGui::EndPopup(); - } - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - } - - if (ImGui::BeginMenu("View")) - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points size", &point_size); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("keyboard 1-9 keys"); - if (point_size < 1) - point_size = 1; - else if (point_size > 10) - point_size = 10; - - ImGui::Separator(); - - if (ImGui::MenuItem("Orthographic", "key O", &is_ortho)) - { - if (is_ortho) - { - new_rotation_center = rotation_center; - new_rotate_x = 0.0; - new_rotate_y = 0.0; - new_translate_x = translate_x; - new_translate_y = translate_y; - new_translate_z = translate_z; - camera_transition_active = true; - } - } - - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Switch between perspective view (3D) and orthographic view (2D/flat)"); - - ImGui::MenuItem("Show axes", "key X", &show_axes); - ImGui::MenuItem("Show compass/ruler", "key C", &compass_ruler); - - ImGui::MenuItem("Lock Z", "Shift + Z", &lock_z, !is_ortho); - - ImGui::Separator(); - - ImGui::BeginDisabled(!is_init); - if (ImGui::MenuItem("Show RGD / NN", nullptr, &show_rgd_nn)) - { - if (show_rgd_nn) - rgd_nn = get_nn(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show Regular/Range Grid Data / Nearest Neighbors"); - - if (ImGui::MenuItem("Show mean covs", nullptr, &show_mean_cov)) - { - if (show_mean_cov) - mean_cov = get_mean_cov(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show the mean and covariance ellipsoid representation"); - - ImGui::MenuItem("Show IMU data", nullptr, &show_imu_data); - ImGui::MenuItem("Show cameras data", nullptr, &show_cameras_data); - - ImGui::MenuItem("Color by intensity", nullptr, &color_by_intensity); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Render points as grayscale from LiDAR intensity (normalized to current block max)"); - if (color_by_intensity) - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::SliderFloat("Intensity gamma", &intensity_gamma, 0.1f, 3.0f, "%.2f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Gamma applied to normalized intensity (<1 brightens, >1 darkens)"); - } - ImGui::EndDisabled(); - - ImGui::Separator(); - - if (ImGui::BeginMenu("Colors")) - { - ImGui::ColorEdit3("Background", (float*)&bg_color, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("Point cloud 1", (float*)&pc_color, ImGuiColorEditFlags_NoInputs); - ImGui::ColorEdit3("Point cloud 2", (float*)&pc_color2, ImGuiColorEditFlags_NoInputs); - - ImGui::EndMenu(); - } - - ImGui::Separator(); - - ImGui::MenuItem("Settings", nullptr, &is_settings_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show power user settings window with more parameters"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Scene view relevant parameters"); - - camMenu(); - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - if (all_data.size() > 0) - { - int tempIndex = index_rendered_points_local; - ImGui::Text("Index: "); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Index of rendered points local"); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::SliderInt("##irpls", &tempIndex, 0, static_cast(all_data.size() - 1)); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - std::string fn = laz_files[indexes_to_filename[index_rendered_points_local]]; - ImGui::Text(fn.c_str()); - ImGui::EndTooltip(); - } - ImGui::SameLine(); - ImGui::InputInt("##irpli", &tempIndex, 1, 10); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - std::string fn = laz_files[indexes_to_filename[index_rendered_points_local]]; - ImGui::Text(fn.c_str()); - ImGui::EndTooltip(); - } - ImGui::PopItemWidth(); - - if ((tempIndex >= 0) && (tempIndex < all_data.size())) - index_rendered_points_local = tempIndex; - - ImGui::SameLine(); - double ts = all_data[index_rendered_points_local].points_local[0].timestamp; // * 1e9; - ImGui::Text("Timestamp: %.6f [ns]", ts); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Click to copy to clipboard"); - if (ImGui::IsItemClicked()) - { - char tmp[64]; - snprintf(tmp, sizeof(tmp), "%.6f", ts); - ImGui::SetClipboardText(tmp); - } - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - } - - ImGui::SameLine(); - ImGui::Text("(%.1f FPS)", ImGui::GetIO().Framerate); - - ImGui::SameLine( - ImGui::GetWindowWidth() - ImGui::CalcTextSize("Info").x - ImGui::GetStyle().ItemSpacing.x * 2 - - ImGui::GetStyle().FramePadding.x * 2); - - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_Header)); - if (ImGui::SmallButton("Info")) - info_gui = !info_gui; - - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(3); - - ImGui::EndMainMenuBar(); - } - - info_window(infoLines, appShortcuts); - - if (compass_ruler) - drawMiniCompassWithRuler(); - - if (show_cameras_data && photos::photo_texture_cam0) - { - if (ImGui::Begin("CAM0")) - { - using namespace photos; - ImGui::Text("fn name: %s ", photos::imgToShowFn.c_str()); - ImGui::Text("timestamp: %s", std::to_string(photos::nearestTs).c_str()); - // get available size - DisplayImageFit((ImTextureID)photos::photo_texture_cam0, photo_width_cam0, photo_height_cam0); - } - - ImGui::End(); - } - - if (show_imu_data) - imu_data_gui(); - - if (is_settings_gui) - settings_gui(); - - ImGui::Render(); - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -void mouse(int glut_button, int state, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - int button = -1; - if (glut_button == GLUT_LEFT_BUTTON) - button = 0; - if (glut_button == GLUT_RIGHT_BUTTON) - button = 1; - if (glut_button == GLUT_MIDDLE_BUTTON) - button = 2; - if (button != -1 && state == GLUT_DOWN) - io.MouseDown[button] = true; - if (button != -1 && state == GLUT_UP) - io.MouseDown[button] = false; - - static int glutMajorVersion = glutGet(GLUT_VERSION) / 10000; - if (state == GLUT_DOWN && (glut_button == 3 || glut_button == 4) && glutMajorVersion < 3) - { - wheel(glut_button, glut_button == 3 ? 1 : -1, x, y); - } - - if (!io.WantCaptureMouse) - { - if (glut_button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN && io.KeyCtrl) - { - } - - if (state == GLUT_DOWN) - { - mouse_buttons |= 1 << glut_button; - } - else if (state == GLUT_UP) - { - mouse_buttons = 0; - } - mouse_old_x = x; - mouse_old_y = y; - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (checkClHelp(argc, argv)) - { - std::cout << winTitle << "\n\n" - << "USAGE:\n" - << std::filesystem::path(argv[0]).stem().string() << " /?\n\n" - << "where\n" - << " Path where scan files are located (*.csv, *.laz, *.sn)\n" - << " -h, /h, --help, /? Show this help and exit\n\n"; - - return 0; - } - - initGL(&argc, argv, winTitle, display, mouse); - ImPlot::CreateContext(); - - if (argc == 2) - { - std::vector input_file_names; - - if (fs::exists(argv[1])) - { - for (const auto& entry : fs::recursive_directory_iterator(argv[1])) - if (entry.is_regular_file()) - input_file_names.push_back(entry.path().string()); - - loadFiles(input_file_names); - } - } - - glutMainLoop(); - - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGLUT_Shutdown(); - ImGui::DestroyContext(); - ImPlot::DestroyContext(); - } catch (const std::bad_alloc& e) - { - spdlog::error("System is out of memory : {}", e.what()); - mandeye::fd::OutOfMemMessage(); - } catch (const std::exception& e) - { - spdlog::error(e.what()); - } catch (...) - { - spdlog::error("Unknown fatal error occurred!"); - } - - return 0; -} \ No newline at end of file diff --git a/apps/mandeye_raw_data_viewer_legacy/resource.h b/apps/mandeye_raw_data_viewer_legacy/resource.h deleted file mode 100644 index 4f3204cae..000000000 --- a/apps/mandeye_raw_data_viewer_legacy/resource.h +++ /dev/null @@ -1,17 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDI_ICON1 101 // application icon -#define VS_VERSION_INFO 1 // version info - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/apps/mandeye_raw_data_viewer_legacy/resource.rc b/apps/mandeye_raw_data_viewer_legacy/resource.rc deleted file mode 100644 index fcf8049bb..000000000 --- a/apps/mandeye_raw_data_viewer_legacy/resource.rc +++ /dev/null @@ -1,50 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,100,1 - PRODUCTVERSION 0,0,100,1 - FILEFLAGSMASK 0x3fL - FILEOS 0x40004 - FILETYPE 0x1 -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "Mandeye\0" - VALUE "FileDescription", "HDMapping Raw Data Viewer\0" - VALUE "FileVersion", "0.100.1\0" - VALUE "InternalName", "Raw data viewer\0" - VALUE "LegalCopyright", "(c) 2026 github.com/MapsHD/HDMapping\0" - VALUE "OriginalFilename", "mandeye_raw_data_viewer.exe\0" - VALUE "ProductVersion", "0.100.1\0" - VALUE "ProgramID", "github.com/MapsHD/HDMapping\0" - VALUE "ProductName", "HDMapping\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 0x04B0 - END -END -///////////////////////////////////////////////////////////////////////////// - diff --git a/apps/multi_session_registration_legacy/CMakeLists.txt b/apps/multi_session_registration_legacy/CMakeLists.txt deleted file mode 100644 index 01c03fbe2..000000000 --- a/apps/multi_session_registration_legacy/CMakeLists.txt +++ /dev/null @@ -1,73 +0,0 @@ -cmake_minimum_required(VERSION 4.0.0) - -# Legacy GLUT + legacy immediate-mode OpenGL build of step3, kept side by -# side with apps/multi_session_registration (raylib-based since it was -# ported off GLUT), the same way step2 keeps multi_view_tls_registration_legacy. -# This is a full, independent copy of the app as it was before that port -- -# not sharing translation units with apps/multi_session_registration -- so -# the two can diverge or be retired independently. -project(multi_session_registration_step_3_legacy) - -# Source files -set(SOURCES - multi_session_registration.cpp - multi_session_factor_graph.cpp - "../../core/src/utils.cpp" -) - -# Windows: add resource file -if(WIN32) - list(APPEND SOURCES "resource.rc") -endif() - -add_executable( - multi_session_registration_step_3_legacy ${SOURCES} - ) - -target_compile_definitions(multi_session_registration_step_3_legacy PRIVATE -DWITH_GUI=1) - -target_include_directories( - multi_session_registration_step_3_legacy - PRIVATE include - ${REPOSITORY_DIRECTORY}/core/include - ${REPOSITORY_DIRECTORY}/core_hd_mapping/include - ${THIRDPARTY_DIRECTORY} - ${THIRDPARTY_DIRECTORY}/glm - ${EIGEN3_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/imgui - ${THIRDPARTY_DIRECTORY}/imgui/backends - ${THIRDPARTY_DIRECTORY}/ImGuizmo - ${THIRDPARTY_DIRECTORY}/json/include - ${THIRDPARTY_DIRECTORY}/portable-file-dialogs-master - ${THIRDPARTY_DIRECTORY}/glew-cmake/include - ${THIRDPARTY_DIRECTORY}/observation_equations/codes - ${THIRDPARTY_DIRECTORY}/freeglut/include - ${LASZIP_INCLUDE_DIR}/LASzip/include) - -target_link_libraries( - multi_session_registration_step_3_legacy - # PRIVATE ${THIRDPARTY_DIRECTORY}/glew-2.2.0/lib/Release/x64/glew32s.lib - ${FREEGLUT_LIBRARY} - ${OPENGL_gl_LIBRARY} - OpenGL::GLU - ${PLATFORM_LASZIP_LIB} - ${PLATFORM_MISCELLANEOUS_LIBS} - ${CORE_LIBRARIES} - ${GUI_LIBRARIES}) - -if(WIN32) - add_custom_command( - TARGET multi_session_registration_step_3_legacy - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy - $ - $ - COMMAND_EXPAND_LISTS) -endif() - -if (MSVC) - target_compile_options(multi_session_registration_step_3_legacy PRIVATE /bigobj) -endif() - -hdmapping_install_app(multi_session_registration_step_3_legacy) \ No newline at end of file diff --git a/apps/multi_session_registration_legacy/icon.ico b/apps/multi_session_registration_legacy/icon.ico deleted file mode 100644 index f8a2cb27bbcc89f5edfb3ecc7b3b1c71e1f87324..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23088 zcmXV11y~zhlm&{rd(q%l9Ew}9Vuc{Z-6246_hQA0d!e`#cXtgGcemp1u=DTk@bM)i zVKVdHm2=NM7X}6v`1$XEg`t8W{R#s^2t1EaRhGp-B}E0EV#v!$fBEm-|9+7Xfd@V3 zVhb1;olSXZ2@Q{>lPq^1eDl}Ab?#c;cA|thg)@`?wwb{ zA}S(PI?B8F*X2Le)yn16yTc-{X>|wIUNnlPLC}t_tGBx z_B=bFcTc_`>JV{R+5JrExeVZu2$B`OaS%t^c<|V z@-s0pp;HK_?(CTL^!B={O->y;z)``QSyFC~a&($a7b+dEG$)!4)|8Z%?r2oYCV+6r z$v>a1wUdbY2uv5LSZ?*9$tfsECxBi`4-e|_zIe;Rwdk>TyuEsBR_YBu-W&}N4Oz|2 ziV5M%P%|+_5t-QAL51z_g0$@DnG8m1WSf2%9Z!a#dQbB$A3`ZV$U<4 zhex6HKIerb z-j{J_mgoO*2ZNjpw5jI%LS2kKu-nTmJ_o>r zU}wMasiQ#OMw_w%YT%XOA8wRI*($ciSH8Gu%=~I_YTAa11XXVj9BOIE7SY0Q zdKfQq6)LCwG6cVWZ;09z7DJ}vG0IjEy$;QVNJ-*HC78GFzs_4cQQX z`SGT+b9RKHwL00`1{Pv|ZRjrKq+LN;TH{lxxdzw zKTA>ABhdF=Us1FPniu;Cg`bXVeV$Gl9|`8VcbzYK(4a0C{X{OaV6BUXWHzsS4}l6j zn2hlObrq3ag4H6q^RgKOJ#w7r(yYf44sUeP*0t`5k&kZR*#sS}*zw=6aALuMJ1}Uy z!7s!l3J9cBkNFPRdUonH<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y)Hm0pXeiEW{arg~q(xO(t)-M0#e}N3 z0@bM+_=x~EpiGfBg&rCv|Lam=UomL7qX|vqmKG7v$tTH~_27+!rS#M5r;bXW0URJq zs|-n=$HT@!=CB4i<2ulIAUqzm_Xd{3-IqzBzxk&WkFT%=M{Q)!O^bsf+gMny%@oN0VK z+l31kz|k0x7UHf&nBTlU`W^)iN6s+UPW6uzFedb~t&RtQ=LArN z_*qDcrZ`+WGp9+^IpRYE`pDyk9?`;Of9GKGO6NXxbpM`S$79-Sj^y?Rb)8cBE)ete z-&HIb*`>Armt_$5-=7NmhE`&1{kfeiW?+$=8^Ra_D~+hHi1Sy0cf>9rfHBOZ09G$( z>=7fvsm~rPze<9ho*qTU1nQPlEy%*0SttiPdv7+S4=nVWy$T=iS&tv;cWa;KD247} zGVjmuLcol~>{rpv`KwDAWiF8r6!aq)rC6yU+hk&Q-Eoo>&;<~ec}_bV(xMD@2XClv zK_KOtdH)Fjv{HI{dJK^)n#XV9uO+~Z;)^Bmqae7(9q0Yo2cgnm7^IyAiFCwEfUD-3AZ?*W4u~F#WEGyFl1FFZ$CbP?0v)x$!O3Gx zOykw0E=O8XDP6sSn2v!5-8jd0cSFtRR|^er0EN2zyu7)M%=5QzE5Yc1W82G<)^}PZ zVUDa#x^Rc4iI~hTDvA{j{rdv$f=t>ERFM*sK{IEXWW>GnQX(3b%fZocezZ;t&dM~@ z&s|&MMFoXAa=|^Ztdyexi~+H4VrFI+9ItbjZ6$SebvW8EffF&}gU`;UhgP8JW_Zm% z7OxlbIX6RE=OxgffGI*c za>K^P(A)dey?gg;97L{g01Hkz6?Om?lnsc)dU}UpuAbIUghVViA&G`bR*&ozr@sdp ojQ>MS{(mvb|NF~ex_wr{MF|rZ>)bS8KGR*%HN04I!7l870F=0lwEzGB diff --git a/apps/multi_session_registration_legacy/multi_session_factor_graph.cpp b/apps/multi_session_registration_legacy/multi_session_factor_graph.cpp deleted file mode 100644 index e4afff848..000000000 --- a/apps/multi_session_registration_legacy/multi_session_factor_graph.cpp +++ /dev/null @@ -1,928 +0,0 @@ -#include "multi_session_factor_graph.h" - -#include -#include - -#include -#include -#include -#include -#include - -bool optimize(std::vector& sessions, const std::vector& edges, TaitBryanPose motion_model_weights) -{ - for (auto& session : sessions) - { - for (auto& pc : session.point_clouds_container.point_clouds) - pc.m_pose_temp = pc.m_pose; - } - - std::vector sums; - sums.push_back(0); - int sum = 0; - std::vector vfixed_x; - std::vector vfixed_y; - std::vector vfixed_z; - std::vector vfixed_om; - std::vector vfixed_fi; - std::vector vfixed_ka; - - for (size_t i = 0; i < sessions.size(); i++) - { - sum += sessions[i].point_clouds_container.point_clouds.size(); - sums.push_back(sum); - - for (size_t j = 0; j < sessions[i].point_clouds_container.point_clouds.size(); j++) - { - vfixed_x.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_x); - vfixed_y.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_y); - vfixed_z.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_z); - - vfixed_om.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_om); - vfixed_fi.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_fi); - vfixed_ka.push_back(sessions[i].point_clouds_container.point_clouds[j].fixed_ka); - } - } - - bool is_ok = true; - std::vector m_poses; - std::vector poses_motion_model; - std::vector index_trajectory; - - for (size_t j = 0; j < sessions.size(); j++) - { - for (size_t i = 0; i < sessions[j].point_clouds_container.point_clouds.size(); i++) - { - m_poses.push_back(sessions[j].point_clouds_container.point_clouds[i].m_pose); - poses_motion_model.push_back(sessions[j].point_clouds_container.point_clouds[i].m_initial_pose); - // poses_motion_model.push_back(sessions[j].point_clouds_container.point_clouds[i].m_pose); - index_trajectory.push_back(j); - } - } - - std::vector poses; - - bool is_wc = true; - bool is_cw = false; - int iterations = 1; - bool is_fix_first_node = true; - // std::vector indexes_ground_truth; - for (size_t j = 0; j < sessions.size(); j++) - { - for (size_t i = 0; i < sessions[j].point_clouds_container.point_clouds.size(); i++) - { - if (is_wc) - { - poses.push_back(pose_tait_bryan_from_affine_matrix(sessions[j].point_clouds_container.point_clouds[i].m_pose)); - } - else if (is_cw) - { - poses.push_back(pose_tait_bryan_from_affine_matrix(sessions[j].point_clouds_container.point_clouds[i].m_pose.inverse())); - } - // if (sessions[j].is_ground_truth) - //{ - // indexes_ground_truth.push_back(poses.size() - 1); - // } - } - } - - std::vector all_edges; - - // motion model edges; - // double angle = * DEG_TO_RAD; - // double wangle = 1.0 / (angle * angle); - - for (size_t i = 1; i < poses_motion_model.size(); i++) - { - if (index_trajectory[i - 1] == index_trajectory[i]) - { - Eigen::Affine3d m_rel = poses_motion_model[i - 1].inverse() * poses_motion_model[i]; - Edge edge; - edge.index_from = i - 1; - edge.index_to = i; - edge.index_session_from = -1; - edge.index_session_to = -1; - edge.relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_rel); - edge.relative_pose_tb_weights.om = 1.0 / (motion_model_weights.om * DEG_TO_RAD * motion_model_weights.om * DEG_TO_RAD); - edge.relative_pose_tb_weights.fi = 1.0 / (motion_model_weights.fi * DEG_TO_RAD * motion_model_weights.fi * DEG_TO_RAD); - edge.relative_pose_tb_weights.ka = 1.0 / (motion_model_weights.ka * DEG_TO_RAD * motion_model_weights.ka * DEG_TO_RAD); - edge.relative_pose_tb_weights.px = - motion_model_weights.px > 0 ? 1.0 / (motion_model_weights.px * motion_model_weights.px) : 1000000.0; - edge.relative_pose_tb_weights.py = - motion_model_weights.py > 0 ? 1.0 / (motion_model_weights.py * motion_model_weights.py) : 1000000.0; - edge.relative_pose_tb_weights.pz = - motion_model_weights.pz > 0 ? 1.0 / (motion_model_weights.pz * motion_model_weights.pz) : 1000000.0; - all_edges.push_back(edge); - } - } - - for (size_t i = 0; i < sessions.size(); i++) - { - for (size_t j = 0; j < sessions[i].pose_graph_loop_closure.edges.size(); j++) - { - Edge edge; - edge.index_from = sessions[i].pose_graph_loop_closure.edges[j].index_from + sums[i]; - edge.index_to = sessions[i].pose_graph_loop_closure.edges[j].index_to + sums[i]; - edge.relative_pose_tb = sessions[i].pose_graph_loop_closure.edges[j].relative_pose_tb; - edge.relative_pose_tb_weights = sessions[i].pose_graph_loop_closure.edges[j].relative_pose_tb_weights; - // edge.is_fixed_fi = ToDo - all_edges.push_back(edge); - } - } - - for (size_t i = 0; i < edges.size(); i++) - { - Edge edge; - edge.index_from = edges[i].index_from + sums[edges[i].index_session_from]; - edge.index_to = edges[i].index_to + sums[edges[i].index_session_to]; - edge.relative_pose_tb = edges[i].relative_pose_tb; - edge.relative_pose_tb_weights = edges[i].relative_pose_tb_weights; - // edge.is_fixed_fi = ToDo - all_edges.push_back(edge); - } - - for (int iter = 0; iter < iterations; iter++) - { - std::vector> tripletListA; - std::vector> tripletListP; - std::vector> tripletListB; - - for (size_t i = 0; i < all_edges.size(); i++) - { - Eigen::Matrix delta; - Eigen::Matrix jacobian; - // auto relative_pose = pose_tait_bryan_from_affine_matrix(all_edges[i].relative_pose_tb); - if (is_wc) - { - relative_pose_obs_eq_tait_bryan_wc_case1( - delta, - poses[all_edges[i].index_from].px, - poses[all_edges[i].index_from].py, - poses[all_edges[i].index_from].pz, - normalize_angle(poses[all_edges[i].index_from].om), - normalize_angle(poses[all_edges[i].index_from].fi), - normalize_angle(poses[all_edges[i].index_from].ka), - poses[all_edges[i].index_to].px, - poses[all_edges[i].index_to].py, - poses[all_edges[i].index_to].pz, - normalize_angle(poses[all_edges[i].index_to].om), - normalize_angle(poses[all_edges[i].index_to].fi), - normalize_angle(poses[all_edges[i].index_to].ka), - all_edges[i].relative_pose_tb.px, - all_edges[i].relative_pose_tb.py, - all_edges[i].relative_pose_tb.pz, - normalize_angle(all_edges[i].relative_pose_tb.om), - normalize_angle(all_edges[i].relative_pose_tb.fi), - normalize_angle(all_edges[i].relative_pose_tb.ka)); - relative_pose_obs_eq_tait_bryan_wc_case1_jacobian( - jacobian, - poses[all_edges[i].index_from].px, - poses[all_edges[i].index_from].py, - poses[all_edges[i].index_from].pz, - normalize_angle(poses[all_edges[i].index_from].om), - normalize_angle(poses[all_edges[i].index_from].fi), - normalize_angle(poses[all_edges[i].index_from].ka), - poses[all_edges[i].index_to].px, - poses[all_edges[i].index_to].py, - poses[all_edges[i].index_to].pz, - normalize_angle(poses[all_edges[i].index_to].om), - normalize_angle(poses[all_edges[i].index_to].fi), - normalize_angle(poses[all_edges[i].index_to].ka)); - } - else if (is_cw) - { - relative_pose_obs_eq_tait_bryan_cw_case1( - delta, - poses[all_edges[i].index_from].px, - poses[all_edges[i].index_from].py, - poses[all_edges[i].index_from].pz, - normalize_angle(poses[all_edges[i].index_from].om), - normalize_angle(poses[all_edges[i].index_from].fi), - normalize_angle(poses[all_edges[i].index_from].ka), - poses[all_edges[i].index_to].px, - poses[all_edges[i].index_to].py, - poses[all_edges[i].index_to].pz, - normalize_angle(poses[all_edges[i].index_to].om), - normalize_angle(poses[all_edges[i].index_to].fi), - normalize_angle(poses[all_edges[i].index_to].ka), - all_edges[i].relative_pose_tb.px, - all_edges[i].relative_pose_tb.py, - all_edges[i].relative_pose_tb.pz, - normalize_angle(all_edges[i].relative_pose_tb.om), - normalize_angle(all_edges[i].relative_pose_tb.fi), - normalize_angle(all_edges[i].relative_pose_tb.ka)); - relative_pose_obs_eq_tait_bryan_cw_case1_jacobian( - jacobian, - poses[all_edges[i].index_from].px, - poses[all_edges[i].index_from].py, - poses[all_edges[i].index_from].pz, - normalize_angle(poses[all_edges[i].index_from].om), - normalize_angle(poses[all_edges[i].index_from].fi), - normalize_angle(poses[all_edges[i].index_from].ka), - poses[all_edges[i].index_to].px, - poses[all_edges[i].index_to].py, - poses[all_edges[i].index_to].pz, - normalize_angle(poses[all_edges[i].index_to].om), - normalize_angle(poses[all_edges[i].index_to].fi), - normalize_angle(poses[all_edges[i].index_to].ka)); - } - - int ir = tripletListB.size(); - - int ic_1 = all_edges[i].index_from * 6; - int ic_2 = all_edges[i].index_to * 6; - - for (size_t row = 0; row < 6; row++) - { - tripletListA.emplace_back(ir + row, ic_1, -jacobian(row, 0)); - tripletListA.emplace_back(ir + row, ic_1 + 1, -jacobian(row, 1)); - tripletListA.emplace_back(ir + row, ic_1 + 2, -jacobian(row, 2)); - tripletListA.emplace_back(ir + row, ic_1 + 3, -jacobian(row, 3)); - tripletListA.emplace_back(ir + row, ic_1 + 4, -jacobian(row, 4)); - tripletListA.emplace_back(ir + row, ic_1 + 5, -jacobian(row, 5)); - - tripletListA.emplace_back(ir + row, ic_2, -jacobian(row, 6)); - tripletListA.emplace_back(ir + row, ic_2 + 1, -jacobian(row, 7)); - tripletListA.emplace_back(ir + row, ic_2 + 2, -jacobian(row, 8)); - tripletListA.emplace_back(ir + row, ic_2 + 3, -jacobian(row, 9)); - tripletListA.emplace_back(ir + row, ic_2 + 4, -jacobian(row, 10)); - tripletListA.emplace_back(ir + row, ic_2 + 5, -jacobian(row, 11)); - } - - tripletListB.emplace_back(ir, 0, delta(0, 0)); - tripletListB.emplace_back(ir + 1, 0, delta(1, 0)); - tripletListB.emplace_back(ir + 2, 0, delta(2, 0)); - tripletListB.emplace_back(ir + 3, 0, normalize_angle(delta(3, 0))); - tripletListB.emplace_back(ir + 4, 0, normalize_angle(delta(4, 0))); - tripletListB.emplace_back(ir + 5, 0, normalize_angle(delta(5, 0))); - - tripletListP.emplace_back(ir, ir, all_edges[i].relative_pose_tb_weights.px * get_cauchy_w(delta(0, 0), 1)); - tripletListP.emplace_back(ir + 1, ir + 1, all_edges[i].relative_pose_tb_weights.py * get_cauchy_w(delta(1, 0), 1)); - tripletListP.emplace_back(ir + 2, ir + 2, all_edges[i].relative_pose_tb_weights.pz * get_cauchy_w(delta(2, 0), 1)); - tripletListP.emplace_back(ir + 3, ir + 3, all_edges[i].relative_pose_tb_weights.om * get_cauchy_w(delta(3, 0), 1)); - tripletListP.emplace_back(ir + 4, ir + 4, all_edges[i].relative_pose_tb_weights.fi * get_cauchy_w(delta(4, 0), 1)); - tripletListP.emplace_back(ir + 5, ir + 5, all_edges[i].relative_pose_tb_weights.ka * get_cauchy_w(delta(5, 0), 1)); - } - - if (is_fix_first_node) - { - int ir = tripletListB.size(); - tripletListA.emplace_back(ir, 0, 1); - tripletListA.emplace_back(ir + 1, 1, 1); - tripletListA.emplace_back(ir + 2, 2, 1); - tripletListA.emplace_back(ir + 3, 3, 1); - tripletListA.emplace_back(ir + 4, 4, 1); - tripletListA.emplace_back(ir + 5, 5, 1); - - tripletListP.emplace_back(ir, ir, 0.0001); - tripletListP.emplace_back(ir + 1, ir + 1, 0.0001); - tripletListP.emplace_back(ir + 2, ir + 2, 0.0001); - tripletListP.emplace_back(ir + 3, ir + 3, 0.0001); - tripletListP.emplace_back(ir + 4, ir + 4, 0.0001); - tripletListP.emplace_back(ir + 5, ir + 5, 0.0001); - - tripletListB.emplace_back(ir, 0, 0); - tripletListB.emplace_back(ir + 1, 0, 0); - tripletListB.emplace_back(ir + 2, 0, 0); - tripletListB.emplace_back(ir + 3, 0, 0); - tripletListB.emplace_back(ir + 4, 0, 0); - tripletListB.emplace_back(ir + 5, 0, 0); - - for (size_t i = 1; i < index_trajectory.size(); i++) - { - if (index_trajectory[i - 1] != index_trajectory[i]) - { - ir = tripletListB.size(); - tripletListA.emplace_back(ir, i * 6 + 0, 1); - tripletListA.emplace_back(ir + 1, i * 6 + 1, 1); - tripletListA.emplace_back(ir + 2, i * 6 + 2, 1); - tripletListA.emplace_back(ir + 3, i * 6 + 3, 1); - tripletListA.emplace_back(ir + 4, i * 6 + 4, 1); - tripletListA.emplace_back(ir + 5, i * 6 + 5, 1); - - tripletListP.emplace_back(ir, ir, 0.0001); - tripletListP.emplace_back(ir + 1, ir + 1, 0.0001); - tripletListP.emplace_back(ir + 2, ir + 2, 0.0001); - tripletListP.emplace_back(ir + 3, ir + 3, 0.0001); - tripletListP.emplace_back(ir + 4, ir + 4, 0.0001); - tripletListP.emplace_back(ir + 5, ir + 5, 0.0001); - - tripletListB.emplace_back(ir, 0, 0); - tripletListB.emplace_back(ir + 1, 0, 0); - tripletListB.emplace_back(ir + 2, 0, 0); - tripletListB.emplace_back(ir + 3, 0, 0); - tripletListB.emplace_back(ir + 4, 0, 0); - tripletListB.emplace_back(ir + 5, 0, 0); - } - } - } - - /*double angle = 1.0 * DEG_TO_RAD; - double wangle = 1.0 / (angle * angle); - - for (size_t index = 0; index < indexes_ground_truth.size(); index++) - { - int ir = tripletListB.size(); - int ic = indexes_ground_truth[index] * 6; - tripletListA.emplace_back(ir, ic + 0, 1); - tripletListA.emplace_back(ir + 1, ic + 1, 1); - tripletListA.emplace_back(ir + 2, ic + 2, 1); - tripletListA.emplace_back(ir + 3, ic + 3, 1); - tripletListA.emplace_back(ir + 4, ic + 4, 1); - tripletListA.emplace_back(ir + 5, ic + 5, 1); - - tripletListP.emplace_back(ir , ir , 10000.0); - tripletListP.emplace_back(ir + 1, ir + 1, 10000.0); - tripletListP.emplace_back(ir + 2, ir + 2, 10000.0); - tripletListP.emplace_back(ir + 3, ir + 3, wangle); - tripletListP.emplace_back(ir + 4, ir + 4, wangle); - tripletListP.emplace_back(ir + 5, ir + 5, wangle); - - tripletListB.emplace_back(ir, 0, 0); - tripletListB.emplace_back(ir + 1, 0, 0); - tripletListB.emplace_back(ir + 2, 0, 0); - tripletListB.emplace_back(ir + 3, 0, 0); - tripletListB.emplace_back(ir + 4, 0, 0); - tripletListB.emplace_back(ir + 5, 0, 0); - }*/ - - // gnss - // for (const auto &pc : point_clouds_container.point_clouds) - /*for (size_t index_pose = 0; index_pose < point_clouds_container.point_clouds.size(); index_pose++) - { - const auto &pc = point_clouds_container.point_clouds[index_pose]; - for (size_t i = 0; i < gnss.gnss_poses.size(); i++) - { - double time_stamp = gnss.gnss_poses[i].timestamp; - - auto it = std::lower_bound(pc.local_trajectory.begin(), pc.local_trajectory.end(), - time_stamp, [](const PointCloud::LocalTrajectoryNode &lhs, const double &time) -> bool - { return lhs.timestamp < time; }); - - int index = it - pc.local_trajectory.begin(); - - if (index > 0 && index < pc.local_trajectory.size()) - { - - if (fabs(time_stamp - pc.local_trajectory[index].timestamp) < 10e12) - { - - Eigen::Matrix jacobian; - TaitBryanPose pose_s; - pose_s = pose_tait_bryan_from_affine_matrix(m_poses[index_pose]); - Eigen::Vector3d p_s = pc.local_trajectory[index].m_pose.translation(); - point_to_point_source_to_target_tait_bryan_wc_jacobian(jacobian, pose_s.px, pose_s.py, pose_s.pz, pose_s.om, - pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z()); - - double delta_x; - double delta_y; - double delta_z; - Eigen::Vector3d p_t(gnss.gnss_poses[i].x - gnss.offset_x, gnss.gnss_poses[i].y - gnss.offset_y, - gnss.gnss_poses[i].alt - gnss.offset_alt); point_to_point_source_to_target_tait_bryan_wc(delta_x, delta_y, delta_z, pose_s.px, - pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z(), p_t.x(), p_t.y(), p_t.z()); - - std::cout << " delta_x " << delta_x << " delta_y " << delta_y << " delta_z " << delta_z << std::endl; - - int ir = tripletListB.size(); - int ic = index_pose * 6; - for (int row = 0; row < 3; row++) - { - for (int col = 0; col < 6; col++) - { - if (jacobian(row, col) != 0.0) - { - tripletListA.emplace_back(ir + row, ic + col, -jacobian(row, col)); - } - } - } - tripletListP.emplace_back(ir, ir, get_cauchy_w(delta_x, 1)); - tripletListP.emplace_back(ir + 1, ir + 1, get_cauchy_w(delta_y, 1)); - tripletListP.emplace_back(ir + 2, ir + 2, get_cauchy_w(delta_z, 1)); - - tripletListB.emplace_back(ir, 0, delta_x); - tripletListB.emplace_back(ir + 1, 0, delta_y); - tripletListB.emplace_back(ir + 2, 0, delta_z); - - // jacobian3x6 = get_point_to_point_jacobian_tait_bryan(pose_convention, - point_clouds_container.point_clouds[i].m_pose, p_s, p_t); - - // auto m = pc.m_pose * pc.local_trajectory[index].m_pose; - // glVertex3f(m(0, 3), m(1, 3), m(2, 3)); - // glVertex3f(gnss_poses[i].x - offset_x, gnss_poses[i].y - offset_y, gnss_poses[i].alt - offset_alt); - } - } - } - }*/ - // - - for (size_t j = 0; j < sessions.size(); j++) - { - for (size_t jj = 0; jj < sessions[j].ground_control_points.gpcs.size(); jj++) - { - Eigen::Vector3d p_s = - sessions[j] - .point_clouds_container.point_clouds[sessions[j].ground_control_points.gpcs[jj].index_to_node_inner] - .local_trajectory[sessions[j].ground_control_points.gpcs[jj].index_to_node_outer] - .m_pose.translation(); - Eigen::Matrix jacobian; - TaitBryanPose pose_s; - pose_s = pose_tait_bryan_from_affine_matrix( - sessions[j].point_clouds_container.point_clouds[sessions[j].ground_control_points.gpcs[jj].index_to_node_inner].m_pose); - point_to_point_source_to_target_tait_bryan_wc_jacobian( - jacobian, pose_s.px, pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z()); - - double delta_x; - double delta_y; - double delta_z; - Eigen::Vector3d p_t( - sessions[j].ground_control_points.gpcs[jj].x, - sessions[j].ground_control_points.gpcs[jj].y, - sessions[j].ground_control_points.gpcs[jj].z + sessions[j].ground_control_points.gpcs[jj].lidar_height_above_ground); - point_to_point_source_to_target_tait_bryan_wc( - delta_x, - delta_y, - delta_z, - pose_s.px, - pose_s.py, - pose_s.pz, - pose_s.om, - pose_s.fi, - pose_s.ka, - p_s.x(), - p_s.y(), - p_s.z(), - p_t.x(), - p_t.y(), - p_t.z()); - - int ir = tripletListB.size(); - int ic = sessions[j].ground_control_points.gpcs[jj].index_to_node_inner * 6 + sums[j] * 6; - - for (int row = 0; row < 3; row++) - { - for (int col = 0; col < 6; col++) - { - if (jacobian(row, col) != 0.0) - { - tripletListA.emplace_back(ir + row, ic + col, -jacobian(row, col)); - } - } - } - tripletListP.emplace_back( - ir + 0, - ir + 0, - (1.0 / (sessions[j].ground_control_points.gpcs[jj].sigma_x * sessions[j].ground_control_points.gpcs[jj].sigma_x)) * - get_cauchy_w(delta_x, 1)); - tripletListP.emplace_back( - ir + 1, - ir + 1, - (1.0 / (sessions[j].ground_control_points.gpcs[jj].sigma_y * sessions[j].ground_control_points.gpcs[jj].sigma_y)) * - get_cauchy_w(delta_y, 1)); - tripletListP.emplace_back( - ir + 2, - ir + 2, - (1.0 / (sessions[j].ground_control_points.gpcs[jj].sigma_z * sessions[j].ground_control_points.gpcs[jj].sigma_z)) * - get_cauchy_w(delta_z, 1)); - - tripletListB.emplace_back(ir, 0, delta_x); - tripletListB.emplace_back(ir + 1, 0, delta_y); - tripletListB.emplace_back(ir + 2, 0, delta_z); - - std::cout << "gcp: delta_x " << delta_x << " delta_y " << delta_y << " delta_z " << delta_z << std::endl; - } - } - - /////////////////////////////////////////////////////// - for (size_t i = 0; i < sessions.size(); i++) - { - for (size_t index_pose = 0; index_pose < sessions[i].point_clouds_container.point_clouds.size(); index_pose++) - { - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_x || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_y || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6 + 1; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_z || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6 + 2; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_om || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6 + 3; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_fi || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6 + 4; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - - if (sessions[i].point_clouds_container.point_clouds[index_pose].fixed_ka || sessions[i].is_ground_truth) - { - int ir = tripletListB.size(); - int ic = (index_pose + sums[i]) * 6 + 5; - tripletListA.emplace_back(ir + 0, ic, 1000000000000); - tripletListP.emplace_back(ir, ir, 1); - tripletListB.emplace_back(ir, 0, 0); - } - } - } - - double error_imu = 0; - double error_imu_sum = 0; - - for (size_t j = 0; j < sessions.size(); j++) - { - for (size_t index_pose = 0; index_pose < sessions[j].point_clouds_container.point_clouds.size(); index_pose++) - { - const auto& pc = sessions[j].point_clouds_container.point_clouds[index_pose]; - if (!pc.fuse_inclination_from_IMU) - { - continue; - } - if (pc.local_trajectory.size() == 0) - { - continue; - } - - TaitBryanPose target_pose; - target_pose.om = pc.local_trajectory[0].imu_om_fi_ka.x(); - target_pose.fi = pc.local_trajectory[0].imu_om_fi_ka.y(); - target_pose.ka = pc.local_trajectory[0].imu_om_fi_ka.z(); - target_pose.px = pc.m_pose(0, 3); - target_pose.py = pc.m_pose(1, 3); - target_pose.pz = pc.m_pose(2, 3); - - Eigen::Affine3d target_mpose = affine_matrix_from_pose_tait_bryan(target_pose); - - double xtg = target_mpose(0, 3); - double ytg = target_mpose(1, 3); - double ztg = target_mpose(2, 3); - double vzx = target_mpose(0, 2); - double vzy = target_mpose(1, 2); - double vzz = target_mpose(2, 2); - - TaitBryanPose current_pose = pose_tait_bryan_from_affine_matrix(pc.m_pose); - - Eigen::Matrix delta; - point_to_plane_tait_bryan_wc( - delta, - current_pose.px, - current_pose.py, - current_pose.pz, - current_pose.om, - current_pose.fi, - current_pose.ka, - 1, - 0, - 0, // add 0,1,0 - xtg, - ytg, - ztg, - vzx, - vzy, - vzz); - - Eigen::Matrix delta_jacobian; - point_to_plane_tait_bryan_wc_jacobian( - delta_jacobian, - current_pose.px, - current_pose.py, - current_pose.pz, - current_pose.om, - current_pose.fi, - current_pose.ka, - 1, - 0, - 0, - xtg, - ytg, - ztg, - vzx, - vzy, - vzz); - - int ir = tripletListB.size(); - int ic = (index_pose + sums[j]) * 6; - tripletListA.emplace_back(ir + 0, ic + 3, -delta_jacobian(0, 3)); - tripletListA.emplace_back(ir + 0, ic + 4, -delta_jacobian(0, 4)); - - tripletListP.emplace_back(ir, ir, /*get_cauchy_w(delta(0, 0), 1) * 10000*/ 1); - - tripletListB.emplace_back(ir, 0, delta(0, 0)); - - /////////////////////////////// - point_to_plane_tait_bryan_wc( - delta, - current_pose.px, - current_pose.py, - current_pose.pz, - current_pose.om, - current_pose.fi, - current_pose.ka, - 0, - 1, - 0, - xtg, - ytg, - ztg, - vzx, - vzy, - vzz); - - point_to_plane_tait_bryan_wc_jacobian( - delta_jacobian, - current_pose.px, - current_pose.py, - current_pose.pz, - current_pose.om, - current_pose.fi, - current_pose.ka, - 0, - 1, - 0, - xtg, - ytg, - ztg, - vzx, - vzy, - vzz); - - ir = tripletListB.size(); - // ic = index_pose * 6; - ic = (index_pose + sums[j]) * 6; - - tripletListA.emplace_back(ir + 0, ic + 3, -delta_jacobian(0, 3)); - tripletListA.emplace_back(ir + 0, ic + 4, -delta_jacobian(0, 4)); - - tripletListP.emplace_back(ir, ir, /*get_cauchy_w(delta(0, 0), 1) * 10000*/ 1); - - tripletListB.emplace_back(ir, 0, delta(0, 0)); - } - } - - // fuse control points - for (size_t j = 0; j < sessions.size(); j++) - { - // CPs - auto& cps = sessions[j].control_points; - auto& point_clouds_container = sessions[j].point_clouds_container; - - for (int i = 0; i < cps.cps.size(); i++) - { - if (!cps.cps[i].is_z_0) - { - Eigen::Vector3d p_s(cps.cps[i].x_source_local, cps.cps[i].y_source_local, cps.cps[i].z_source_local); - - Eigen::Matrix jacobian; - TaitBryanPose pose_s; - pose_s = pose_tait_bryan_from_affine_matrix(point_clouds_container.point_clouds[cps.cps[i].index_to_pose].m_pose); - - point_to_point_source_to_target_tait_bryan_wc_jacobian( - jacobian, pose_s.px, pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z()); - - double delta_x; - double delta_y; - double delta_z; - Eigen::Vector3d p_t(cps.cps[i].x_target_global, cps.cps[i].y_target_global, cps.cps[i].z_target_global); - point_to_point_source_to_target_tait_bryan_wc( - delta_x, - delta_y, - delta_z, - pose_s.px, - pose_s.py, - pose_s.pz, - pose_s.om, - pose_s.fi, - pose_s.ka, - p_s.x(), - p_s.y(), - p_s.z(), - p_t.x(), - p_t.y(), - p_t.z()); - - int ir = tripletListB.size(); - - //(index_pose + sums[j]) * 6; - int ic = (cps.cps[i].index_to_pose + sums[j]) * 6; - - for (int row = 0; row < 3; row++) - { - for (int col = 0; col < 6; col++) - { - if (jacobian(row, col) != 0.0) - { - tripletListA.emplace_back(ir + row, ic + col, -jacobian(row, col)); - } - } - } - tripletListP.emplace_back(ir + 0, ir + 0, (1.0 / (cps.cps[i].sigma_x * cps.cps[i].sigma_x)) * get_cauchy_w(delta_x, 1)); - tripletListP.emplace_back(ir + 1, ir + 1, (1.0 / (cps.cps[i].sigma_y * cps.cps[i].sigma_y)) * get_cauchy_w(delta_y, 1)); - tripletListP.emplace_back(ir + 2, ir + 2, (1.0 / (cps.cps[i].sigma_z * cps.cps[i].sigma_z)) * get_cauchy_w(delta_z, 1)); - - tripletListB.emplace_back(ir, 0, delta_x); - tripletListB.emplace_back(ir + 1, 0, delta_y); - tripletListB.emplace_back(ir + 2, 0, delta_z); - - std::cout << "cp [not z == 0]: delta_x " << delta_x << " delta_y " << delta_y << " delta_z " << delta_z << std::endl; - } - else - { - Eigen::Vector3d p_s(cps.cps[i].x_source_local, cps.cps[i].y_source_local, cps.cps[i].z_source_local); - - Eigen::Matrix jacobian; - TaitBryanPose pose_s; - pose_s = pose_tait_bryan_from_affine_matrix(point_clouds_container.point_clouds[cps.cps[i].index_to_pose].m_pose); - - point_to_point_source_to_target_tait_bryan_wc_jacobian( - jacobian, pose_s.px, pose_s.py, pose_s.pz, pose_s.om, pose_s.fi, pose_s.ka, p_s.x(), p_s.y(), p_s.z()); - - double delta_x; - double delta_y; - double delta_z; - Eigen::Vector3d p_t(cps.cps[i].x_target_global, cps.cps[i].y_target_global, 0.0 /*cps.cps[i].z_target_global*/); - point_to_point_source_to_target_tait_bryan_wc( - delta_x, - delta_y, - delta_z, - pose_s.px, - pose_s.py, - pose_s.pz, - pose_s.om, - pose_s.fi, - pose_s.ka, - p_s.x(), - p_s.y(), - p_s.z(), - p_t.x(), - p_t.y(), - p_t.z()); - - int ir = tripletListB.size(); - // int ic = cps.cps[i].index_to_pose * 6; - int ic = (cps.cps[i].index_to_pose + sums[j]) * 6; - - for (int row = 2; row < 3; row++) - { - for (int col = 0; col < 6; col++) - { - if (jacobian(row, col) != 0.0) - { - tripletListA.emplace_back(ir, ic + col, -jacobian(row, col)); - } - } - } - // tripletListP.emplace_back(ir + 0, ir + 0, (1.0 / (cps.cps[i].sigma_x * cps.cps[i].sigma_x)) * get_cauchy_w(delta_x, - // 1)); tripletListP.emplace_back(ir + 1, ir + 1, (1.0 / (cps.cps[i].sigma_y * cps.cps[i].sigma_y)) * - // get_cauchy_w(delta_y, 1)); - tripletListP.emplace_back(ir, ir, (1.0 / (cps.cps[i].sigma_z * cps.cps[i].sigma_z))); - - // tripletListB.emplace_back(ir, 0, delta_x); - // tripletListB.emplace_back(ir + 1, 0, delta_y); - tripletListB.emplace_back(ir, 0, delta_z); - - std::cout << "cp [not z == 0]: delta_z " << delta_z << std::endl; - } - } - } - - ////////////////////////////////////////////////////// - // for (size_t i = 0; i < gcps.gpcs.size(); i++) - //{ - - Eigen::SparseMatrix matA(tripletListB.size(), poses.size() * 6); - Eigen::SparseMatrix matP(tripletListB.size(), tripletListB.size()); - Eigen::SparseMatrix matB(tripletListB.size(), 1); - - matA.setFromTriplets(tripletListA.begin(), tripletListA.end()); - matP.setFromTriplets(tripletListP.begin(), tripletListP.end()); - matB.setFromTriplets(tripletListB.begin(), tripletListB.end()); - - Eigen::SparseMatrix AtPA(poses.size() * 6, poses.size() * 6); - Eigen::SparseMatrix AtPB(poses.size() * 6, 1); - - { - Eigen::SparseMatrix AtP = matA.transpose() * matP; - AtPA = (AtP)*matA; - AtPB = (AtP)*matB; - } - - tripletListA.clear(); - tripletListP.clear(); - tripletListB.clear(); - - Eigen::SimplicialCholesky> solver(AtPA); - - Eigen::SparseMatrix x = solver.solve(AtPB); - - std::vector h_x; - - for (int k = 0; k < x.outerSize(); ++k) - { - for (Eigen::SparseMatrix::InnerIterator it(x, k); it; ++it) - { - h_x.push_back(it.value()); - } - } - - if (h_x.size() == 6 * poses.size()) - { - int counter = 0; - - for (size_t i = 0; i < poses.size(); i++) - { - TaitBryanPose pose = poses[i]; - pose.px += h_x[counter++] * 0.1; - pose.py += h_x[counter++] * 0.1; - pose.pz += h_x[counter++] * 0.1; - pose.om += h_x[counter++] * 0.1; - pose.fi += h_x[counter++] * 0.1; - pose.ka += h_x[counter++] * 0.1; - - poses[i].px = pose.px; - poses[i].py = pose.py; - poses[i].pz = pose.pz; - poses[i].om = pose.om; - poses[i].fi = pose.fi; - poses[i].ka = pose.ka; - } - } - else - { - std::cout << "optimizing with tait bryan FAILED" << std::endl; - std::cout << "h_x.size(): " << h_x.size() << " should be: " << 6 * poses.size() << std::endl; - is_ok = false; - break; - } - - if (is_ok) - { - for (size_t i = 0; i < m_poses.size(); i++) - { - if (is_wc) - m_poses[i] = affine_matrix_from_pose_tait_bryan(poses[i]); - else if (is_cw) - m_poses[i] = affine_matrix_from_pose_tait_bryan(poses[i]).inverse(); - } - } - - if (is_ok) - { - int index = 0; - for (size_t i = 0; i < m_poses.size(); i++) - { - if (i > 0) - { - if (index_trajectory[i - 1] != index_trajectory[i]) - index = 0; - } - // if (!sessions[index_trajectory[i]].is_ground_truth) - //{ - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].m_pose = m_poses[i]; - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose = - pose_tait_bryan_from_affine_matrix(sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].m_pose); - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_translation[0] = - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.px; - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_translation[1] = - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.py; - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_translation[2] = - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.pz; - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_rotation[0] = - rad2deg(sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.om); - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_rotation[1] = - rad2deg(sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.fi); - sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].gui_rotation[2] = - rad2deg(sessions[index_trajectory[i]].point_clouds_container.point_clouds[index].pose.ka); - //} - index++; - } - } - } - return true; -} \ No newline at end of file diff --git a/apps/multi_session_registration_legacy/multi_session_factor_graph.h b/apps/multi_session_registration_legacy/multi_session_factor_graph.h deleted file mode 100644 index b173f04e6..000000000 --- a/apps/multi_session_registration_legacy/multi_session_factor_graph.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -struct Edge -{ - TaitBryanPose relative_pose_tb; - TaitBryanPose relative_pose_tb_weights; - int index_session_from; - int index_session_to; - int index_from; - int index_to; - bool is_fixed_px = false; - bool is_fixed_py = false; - bool is_fixed_pz = false; - bool is_fixed_om = false; - bool is_fixed_fi = false; - bool is_fixed_ka = false; -}; - -bool optimize(std::vector& sessions, const std::vector& edges, TaitBryanPose motion_model_weights); diff --git a/apps/multi_session_registration_legacy/multi_session_registration.cpp b/apps/multi_session_registration_legacy/multi_session_registration.cpp deleted file mode 100644 index eae68a791..000000000 --- a/apps/multi_session_registration_legacy/multi_session_registration.cpp +++ /dev/null @@ -1,4392 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifdef _WIN32 -#include "resource.h" -#include - -#endif - -#include "multi_session_factor_graph.h" - -std::string winTitle = std::string("Step 3 (Multi session registration) ") + HDMAPPING_CONFIGURE_PROJECT_VERSION; - -std::vector infoLines = { - "This program is third/final step in MANDEYE process", - "", - "First step: create project by adding sessions (result of 'multi_view_tls_registration_step_2' program)", - "Last step: save project", - "To produce map use 'multi_view_tls_registration_step_2' export functionality" -}; - -// App specific shortcuts (Type and Shortcut are just for easy reference) -static const std::vector appShortcuts = { { "Normal keys", "A", "" }, - { "", "Ctrl+A", "Add session(s)" }, - { "", "B", "" }, - { "", "Ctrl+B", "" }, - { "", "C", "" }, - { "", "Ctrl+C", "" }, - { "", "D", "" }, - { "", "Ctrl+D", "" }, - { "", "E", "" }, - { "", "Ctrl+E", "" }, - { "", "F", "" }, - { "", "Ctrl+F", "" }, - { "", "G", "" }, - { "", "Ctrl+G", "" }, - { "", "H", "" }, - { "", "Ctrl+H", "" }, - { "", "I", "" }, - { "", "Ctrl+I", "" }, - { "", "J", "" }, - { "", "Ctrl+K", "" }, - { "", "K", "" }, - { "", "Ctrl+K", "" }, - { "", "L", "" }, - { "", "Ctrl+L", "Load sessions" }, - { "", "M", "" }, - { "", "Ctrl+M", "" }, - { "", "N", "" }, - { "", "Ctrl+N", "" }, - { "", "O", "" }, - { "", "Ctrl+O", "Open project" }, - { "", "P", "" }, - { "", "Ctrl+P", "" }, - { "", "Q", "" }, - { "", "Ctrl+Q", "" }, - { "", "R", "" }, - { "", "Ctrl+R", "Remove session(s)" }, - { "", "Shift+R", "" }, - { "", "S", "" }, - { "", "Ctrl+S", "Save project" }, - { "", "Ctrl+Shift+S", "" }, - { "", "T", "" }, - { "", "Ctrl+T", "" }, - { "", "U", "" }, - { "", "Ctrl+U", "" }, - { "", "V", "" }, - { "", "Ctrl+V", "" }, - { "", "W", "" }, - { "", "Ctrl+W", "" }, - { "", "X", "" }, - { "", "Ctrl+X", "" }, - { "", "Y", "" }, - { "", "Ctrl+Y", "" }, - { "", "Z", "" }, - { "", "Ctrl+Z", "" }, - { "", "Shift+Z", "" }, - { "", "1-9", "" }, - { "Special keys", "Up arrow", "" }, - { "", "Shift + up arrow", "" }, - { "", "Ctrl + up arrow", "" }, - { "", "Down arrow", "" }, - { "", "Shift + down arrow", "" }, - { "", "Ctrl + down arrow", "" }, - { "", "Left arrow", "" }, - { "", "Shift + left arrow", "" }, - { "", "Ctrl + left arrow", "" }, - { "", "Right arrow", "" }, - { "", "Shift + right arrow", "" }, - { "", "Ctrl + right arrow", "" }, - { "", "Pg down", "" }, - { "", "Pg up", "" }, - { "", "- key", "" }, - { "", "+ key", "" }, - { "Mouse related", "Left click + drag", "" }, - { "", "Right click + drag", "n" }, - { "", "Scroll", "" }, - { "", "Shift + scroll", "" }, - { "", "Shift + drag", "" }, - { "", "Ctrl + left click", "" }, - { "", "Ctrl + right click", "" }, - { "", "Ctrl + middle click", "" } }; - -float m_gizmo[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; - -bool is_decimate = true; -double bucket_x = 0.1; -double bucket_y = 0.1; -double bucket_z = 0.1; -bool calculate_offset = false; -ObservationPicking observation_picking; -int index_loop_closure_source = -1; -int index_loop_closure_target = -1; -int first_session_index = -1; -int second_session_index = -1; -double search_radius = 0.3; -bool loaded_sessions = false; -bool optimized = false; -bool gizmo_all_sessions = false; -bool is_ndt_gui = false; -bool is_loop_closure_gui = false; -bool remove_gui = false; -NDT ndt; - -bool update_rotation_center = false; - -bool is_settings_gui = true; - -int number_visible_sessions = 0; -int index_gt = -1; -int old_index_gt = -1; -int index_gizmo = -1; -int old_index_gizmo = -1; - -double time_stamp_offset = 0.0; - -struct ProjectSettings -{ - std::vector session_file_names; -}; - -std::vector edges; -int index_active_edge = -1; -bool manipulate_active_edge = false; -bool edge_gizmo = false; - -ProjectSettings project_settings; -std::vector sessions; - -int viewer_reduce_rendered_trajectory = 1; -namespace fs = std::filesystem; - -int num_edge_extended_before = 0; -int num_edge_extended_after = 0; - -int gui_point_size = 2; - -TaitBryanPose motion_model_weights = { 0.01, 0.01, 0.01, 0.1, 0.1, 0.1 }; -/////////////////////////////////////////////////////////////////////////////////// - -void ndt_gui() -{ - static bool compute_mean_and_cov_for_bucket = false; - if (ImGui::Begin("Normal Distributions Transform", &is_ndt_gui, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::InputFloat3("Bucket size [m] (x, y,z)", ndt.bucket_size); - if (ndt.bucket_size[0] < 0.01) - ndt.bucket_size[0] = 0.01f; - if (ndt.bucket_size[1] < 0.01) - ndt.bucket_size[1] = 0.01f; - if (ndt.bucket_size[2] < 0.01) - ndt.bucket_size[2] = 0.01f; - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Number of threads", &ndt.number_of_threads); - if (ndt.number_of_threads < 1) - ndt.number_of_threads = 1; - ImGui::SameLine(); - ImGui::InputInt("Number of iterations", &ndt.number_of_iterations); - if (ndt.number_of_iterations < 1) - ndt.number_of_iterations = 1; - ImGui::PopItemWidth(); - - if (ImGui::Button("NDT optimization")) - { - for (auto& s : sessions) - { - s.is_gizmo = false; - } - - double rms_initial = 0.0; - double rms_final = 0.0; - double mui = 0.0; - - ndt.optimize(sessions, false, compute_mean_and_cov_for_bucket); - } - ImGui::End(); - } - -#if 0 - ImGui::Checkbox("ndt fix_first_node (add I to first pose in Hessian)", &ndt.is_fix_first_node); - - ImGui::Checkbox("ndt Gauss-Newton", &ndt.is_gauss_newton); - if (ndt.is_gauss_newton) - { - ndt.is_levenberg_marguardt = false; - } - - ImGui::SameLine(); - ImGui::Checkbox("ndt Levenberg-Marguardt", &ndt.is_levenberg_marguardt); - if (ndt.is_levenberg_marguardt) - { - ndt.is_gauss_newton = false; - } - - ImGui::Checkbox("ndt poses expressed as camera<-world (cw)", &ndt.is_cw); - if (ndt.is_cw) - { - ndt.is_wc = false; - } - ImGui::SameLine(); - ImGui::Checkbox("ndt poses expressed as camera->world (wc)", &ndt.is_wc); - if (ndt.is_wc) - { - ndt.is_cw = false; - } - - ImGui::Checkbox("ndt Tait-Bryan angles (om fi ka: RxRyRz)", &ndt.is_tait_bryan_angles); - if (ndt.is_tait_bryan_angles) - { - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - } - - ImGui::SameLine(); - ImGui::Checkbox("ndt Quaternion (q0 q1 q2 q3)", &ndt.is_quaternion); - if (ndt.is_quaternion) - { - ndt.is_tait_bryan_angles = false; - ndt.is_rodrigues = false; - } - - ImGui::SameLine(); - ImGui::Checkbox("ndt Rodrigues (sx sy sz)", &ndt.is_rodrigues); - if (ndt.is_rodrigues) - { - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - } - - if (ImGui::Button("compute mean mahalanobis distance")) - { - double rms_initial = 0.0; - double rms_final = 0.0; - double mui = 0.0; - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - } - - ImGui::Text("--------------------------------------------------------------------------------------------------------"); - - if (ImGui::Button("ndt_optimization(Lie-algebra left Jacobian)")) - { - // icp.optimize_source_to_target_lie_algebra_left_jacobian(point_clouds_container); - ndt.optimize_lie_algebra_left_jacobian(session.point_clouds_container.point_clouds, compute_mean_and_cov_for_bucket); - } - if (ImGui::Button("ndt_optimization(Lie-algebra right Jacobian)")) - { - // icp.optimize_source_to_target_lie_algebra_right_jacobian(point_clouds_container); - ndt.optimize_lie_algebra_right_jacobian(session.point_clouds_container.point_clouds, compute_mean_and_cov_for_bucket); - } - - ImGui::Text("--------------------------------------------------------------------------------------------------------"); - - ImGui::Checkbox("generalized", &ndt.is_generalized); - - if (ndt.is_generalized) - { - ImGui::InputDouble("sigma_r", &ndt.sigma_r, 0.01, 0.01); - ImGui::InputDouble("sigma_polar_angle_rad", &ndt.sigma_polar_angle, 0.0001, 0.0001); - ImGui::InputDouble("sigma_azimuthal_angle_rad", &ndt.sigma_azimuthal_angle, 0.0001, 0.0001); - ImGui::InputInt("num_extended_points", &ndt.num_extended_points, 1, 1); - - ImGui::Checkbox("compute_mean_and_cov_for_bucket", &compute_mean_and_cov_for_bucket); - } - - if (ImGui::Button("Set Zoller+Fröhlich TLS Imager 5006i errors")) - { - ndt.sigma_r = 0.0068; - ndt.sigma_polar_angle = 0.007 * DEG_TO_RAD; - ndt.sigma_azimuthal_angle = 0.007 * DEG_TO_RAD; - } - - if (ImGui::Button("Set Zoller+Fröhlich TLS Imager 5010C errors")) - { - ndt.sigma_r = 0.01; - ndt.sigma_polar_angle = 0.007 * DEG_TO_RAD; - ndt.sigma_azimuthal_angle = 0.007 * DEG_TO_RAD; - } - - if (ImGui::Button("Set Zoller+Fröhlich TLS Imager 5016 errors")) - { - ndt.sigma_r = 0.00025; - ndt.sigma_polar_angle = 0.004 * DEG_TO_RAD; - ndt.sigma_azimuthal_angle = 0.004 * DEG_TO_RAD; - } - if (ImGui::Button("Set Faro Focus3D errors")) - { - ndt.sigma_r = 0.001; - ndt.sigma_polar_angle = 19.0 * (1.0 / 3600.0) * DEG_TO_RAD; - ndt.sigma_azimuthal_angle = 19.0 * (1.0 / 3600.0) * DEG_TO_RAD; - } - if (ImGui::Button("Set Leica ScanStation C5 C10 errors")) - { - ndt.sigma_r = 0.006; - ndt.sigma_polar_angle = 0.00006; - ndt.sigma_azimuthal_angle = 0.00006; - } - if (ImGui::Button("Set Riegl VZ400 errors")) - { - ndt.sigma_r = 0.005; - ndt.sigma_polar_angle = 0.0005 * DEG_TO_RAD + 0.0003; // Laser Beam Dicvergence - ndt.sigma_azimuthal_angle = 0.0005 * DEG_TO_RAD + 0.0003; // Laser Beam Dicvergence - } - if (ImGui::Button("Set Leica HDS6100 errors")) - { - ndt.sigma_r = 0.009; - ndt.sigma_polar_angle = 0.000125; - ndt.sigma_azimuthal_angle = 0.000125; - } - if (ImGui::Button("Set Leica P40 errors")) - { - ndt.sigma_r = 0.0012; - ndt.sigma_polar_angle = 8.0 / 3600; - ndt.sigma_azimuthal_angle = 8.0 / 3600; - } -#endif -} - -void loop_closure_gui() -{ - if (ImGui::Begin("Manual Pose Graph Loop Closure Mode", &is_loop_closure_gui, ImGuiWindowFlags_AlwaysAutoResize)) - { - if (ImGui::Button("Optimize GRAPH")) - { - for (int i = 0; i < 100; i++) - { - std::cout << "Iteration [" << i + 1 << "] of: " << 100 << std::endl; - optimize(sessions, edges, motion_model_weights); - } - optimized = true; - } - - ImGui::Checkbox("update_rotation_center", &update_rotation_center); - - // - auto point_cloud_upper = sessions[first_session_index].point_clouds_container.point_clouds.size() - 1; - - ImGui::InputInt("gui_point_size", &gui_point_size); - if (gui_point_size < 1) - gui_point_size = 1; - - ImGui::Text("Num edge extended:"); - - ImGui::Text("before: "); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::SliderInt("##fs", &num_edge_extended_before, 0, point_cloud_upper); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - ImGui::SameLine(); - ImGui::InputInt("##fi", &num_edge_extended_before, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - if (num_edge_extended_before < 0) - num_edge_extended_before = 0; - if (num_edge_extended_before >= point_cloud_upper) - num_edge_extended_before = point_cloud_upper; - - point_cloud_upper = sessions[second_session_index].point_clouds_container.point_clouds.size() - 1; - - ImGui::Text(" after: "); - ImGui::SameLine(); - - ImGui::SliderInt("##ts", &num_edge_extended_after, index_loop_closure_target, static_cast(point_cloud_upper)); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - ImGui::SameLine(); - ImGui::InputInt("##ti", &num_edge_extended_after, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - if (num_edge_extended_after < 0) - num_edge_extended_after = 0; - if (num_edge_extended_after >= point_cloud_upper) - num_edge_extended_after = point_cloud_upper; - ImGui::PopItemWidth(); - // - - if (!manipulate_active_edge) - { - ImGui::InputInt("index_loop_closure_source", &index_loop_closure_source); - if (index_loop_closure_source < 0) - index_loop_closure_source = 0; - if (index_loop_closure_source >= sessions[first_session_index].point_clouds_container.point_clouds.size() - 1) - index_loop_closure_source = sessions[first_session_index].point_clouds_container.point_clouds.size() - 1; - ImGui::InputInt("index_loop_closure_target", &index_loop_closure_target); - if (index_loop_closure_target < 0) - index_loop_closure_target = 0; - if (index_loop_closure_target >= sessions[second_session_index].point_clouds_container.point_clouds.size() - 1) - index_loop_closure_target = sessions[second_session_index].point_clouds_container.point_clouds.size() - 1; - } - if (ImGui::Button("Add edge")) - { - Edge edge; - edge.index_from = index_loop_closure_source; - edge.index_to = index_loop_closure_target; - edge.index_session_from = first_session_index; - edge.index_session_to = second_session_index; - - edge.relative_pose_tb = pose_tait_bryan_from_affine_matrix( - sessions[first_session_index].point_clouds_container.point_clouds[index_loop_closure_source].m_pose.inverse() * - sessions[second_session_index].point_clouds_container.point_clouds[index_loop_closure_target].m_pose); - - edge.relative_pose_tb_weights.px = 1000000.0; - edge.relative_pose_tb_weights.py = 1000000.0; - edge.relative_pose_tb_weights.pz = 1000000.0; - edge.relative_pose_tb_weights.om = 1000000.0; - edge.relative_pose_tb_weights.fi = 1000000.0; - edge.relative_pose_tb_weights.ka = 1000000.0; - - edges.push_back(edge); - - index_active_edge = edges.size() - 1; - } - - std::string number_active_edges = "number_edges: " + std::to_string(edges.size()); - ImGui::Text(number_active_edges.c_str()); - if (edges.size() > 0) - { - ImGui::Checkbox("manipulate_active_edge", &manipulate_active_edge); - if (manipulate_active_edge) - { - int remove_edge_index = -1; - if (ImGui::Button("remove active edge")) - { - edge_gizmo = false; - remove_edge_index = index_active_edge; - } - - int prev_index_active_edge = index_active_edge; - - if (!edge_gizmo) - { - bool is_gizmo = false; - - for (const auto& s : sessions) - { - if (s.is_gizmo) - is_gizmo = true; - } - - if (!is_gizmo) - { - ImGui::InputInt("index_active_edge", &index_active_edge); - - if (index_active_edge < 0) - index_active_edge = 0; - if (index_active_edge >= (int)edges.size()) - index_active_edge = (int)edges.size() - 1; - } - } - - std::string txt = "index_session_from: " + std::to_string(edges[index_active_edge].index_session_from); - ImGui::Text(txt.c_str()); - txt = "index_session_to: " + std::to_string(edges[index_active_edge].index_session_to); - ImGui::Text(txt.c_str()); - txt = "index_from: " + std::to_string(edges[index_active_edge].index_from); - ImGui::Text(txt.c_str()); - txt = "index_to: " + std::to_string(edges[index_active_edge].index_to); - ImGui::Text(txt.c_str()); - - if (remove_edge_index != -1) - { - std::vector new_edges; - for (size_t i = 0; i < edges.size(); i++) - { - if (remove_edge_index != i) - new_edges.push_back(edges[i]); - } - edges = new_edges; - - index_active_edge = remove_edge_index - 1; - manipulate_active_edge = false; - } - - bool prev_gizmo = edge_gizmo; - ImGui::Checkbox("gizmo", &edge_gizmo); - - if (prev_gizmo != edge_gizmo) - { - auto m_to = sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .m_pose * - affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - m_gizmo[0] = (float)m_to(0, 0); - m_gizmo[1] = (float)m_to(1, 0); - m_gizmo[2] = (float)m_to(2, 0); - m_gizmo[3] = (float)m_to(3, 0); - m_gizmo[4] = (float)m_to(0, 1); - m_gizmo[5] = (float)m_to(1, 1); - m_gizmo[6] = (float)m_to(2, 1); - m_gizmo[7] = (float)m_to(3, 1); - m_gizmo[8] = (float)m_to(0, 2); - m_gizmo[9] = (float)m_to(1, 2); - m_gizmo[10] = (float)m_to(2, 2); - m_gizmo[11] = (float)m_to(3, 2); - m_gizmo[12] = (float)m_to(0, 3); - m_gizmo[13] = (float)m_to(1, 3); - m_gizmo[14] = (float)m_to(2, 3); - m_gizmo[15] = (float)m_to(3, 3); - } - if (!edge_gizmo) - { - if (ImGui::Button("ICP")) - { - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 10; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - std::vector source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - std::vector target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, search_radius, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - else - { - int number_of_iterations = 10; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - std::vector source; - auto& e = edges[index_active_edge]; - for (int i = -num_edge_extended_before; i <= num_edge_extended_after; i++) - { - int index_src = e.index_to + i; - if (index_src >= 0 && - index_src < - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.size()) - { - Eigen::Affine3d m_src = sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds.at(index_src) - .m_pose; - for (int k = 0; k < sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[index_src] - .points_local.size(); - k++) - { - Eigen::Vector3d p_g = m_src * - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[index_src] - .points_local[k]; - source.push_back(p_g); - } - // point_clouds_container.point_clouds.at(index_src).render(m_src, 1); - } - } - std::vector target; - - for (int i = -num_edge_extended_before; i <= num_edge_extended_after; i++) - { - int index_trg = e.index_from + i; - if (index_trg >= 0 && - index_trg < sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds.size()) - { - Eigen::Affine3d m_trg = sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds.at(index_trg) - .m_pose; - for (int k = 0; k < sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[index_trg] - .points_local.size(); - k++) - { - Eigen::Vector3d p_g = m_trg * - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[index_trg] - .points_local[k]; - target.push_back(p_g); - } - // point_clouds_container.point_clouds.at(index_src).render(m_src, 1); - } - } - - Eigen::Affine3d m_src_inv = sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[e.index_to] - .m_pose.inverse(); - - for (auto& p : source) - { - p = m_src_inv * p; - } - - Eigen::Affine3d m_trg_inv = sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[e.index_from] - .m_pose.inverse(); - - for (auto& p : target) - { - p = m_trg_inv * p; - } - - if (icp.compute(source, target, search_radius, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - ImGui::SameLine(); - ImGui::InputDouble("search_radius", &search_radius); - if (search_radius < 0.01) - search_radius = 0.01; - - ///////////////////////////////// - if (ImGui::Button("ICP [search radius 2m]")) - { - float sr = 2.0; - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - else - { - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - - ImGui::SameLine(); - if (ImGui::Button("ICP [search radius 1m]")) - { - float sr = 1.0; - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - else - { - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - ImGui::SameLine(); - if (ImGui::Button("ICP [search radius 0.5m]")) - { - float sr = 0.5; - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - else - { - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - } - ImGui::SameLine(); - if (ImGui::Button("ICP [search radius 0.25m]")) - { - float sr = 0.25; - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - else - { - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - } - ImGui::SameLine(); - if (ImGui::Button("ICP [search radius 0.1m]")) - { - float sr = 0.1; - std::cout << "Iterative Closest Point" << std::endl; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth && - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - std::cout << "Two sessions are ground truth!!! ICP is disabled" << std::endl; - } - else - { - bool is_with_ground_truth = false; - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth || - sessions[edges[index_active_edge].index_session_to].is_ground_truth) - { - is_with_ground_truth = true; - } - - if (is_with_ground_truth) - { - int index_session_from = -1; - int index_session_to = -1; - int index_from = -1; - int index_to = -1; - - if (sessions[edges[index_active_edge].index_session_from].is_ground_truth) - { - index_session_from = edges[index_active_edge].index_session_from; - index_session_to = edges[index_active_edge].index_session_to; - index_from = edges[index_active_edge].index_from; - index_to = edges[index_active_edge].index_to; - } - else - { - index_session_from = edges[index_active_edge].index_session_to; - index_session_to = edges[index_active_edge].index_session_from; - index_from = edges[index_active_edge].index_to; - index_to = edges[index_active_edge].index_from; - } - - double x_min = 1000000000000.0; - double y_min = 1000000000000.0; - double z_min = 1000000000000.0; - double x_max = -1000000000000.0; - double y_max = -1000000000000.0; - double z_max = -1000000000000.0; - - auto& points_to = sessions[index_session_to].point_clouds_container.point_clouds[index_to]; - - for (const auto& p : points_to.points_local) - { - auto pg = points_to.m_pose * p; - if (pg.x() < x_min) - x_min = pg.x(); - if (pg.y() < y_min) - y_min = pg.y(); - if (pg.z() < z_min) - z_min = pg.z(); - - if (pg.x() > x_max) - x_max = pg.x(); - if (pg.y() > y_max) - y_max = pg.y(); - if (pg.z() > z_max) - z_max = pg.z(); - } - auto& points_from = sessions[index_session_from].point_clouds_container.point_clouds[index_from]; - std::vector ground_truth; - for (const auto& p : points_from.points_local) - { - auto pg = points_from.m_pose * p; - if (pg.x() > x_min && pg.x() < x_max) - { - if (pg.y() > y_min && pg.y() < y_max) - { - if (pg.z() > z_min && pg.z() < z_max) - ground_truth.push_back(p); - } - } - } - - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - ground_truth; // sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - else - { - int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - const std::vector& source = - sessions[edges[index_active_edge].index_session_to] - .point_clouds_container.point_clouds[edges[index_active_edge].index_to] - .points_local; - const std::vector& target = - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[edges[index_active_edge].index_from] - .points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } - } - } - } -#if 0 - if (ImGui::Button("Save src")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Output file name", mandeye::fd::LAS_LAZ_filter, ".laz"); - std::cout << "laz file to save: '" << output_file_name << "'" << std::endl; - - if (output_file_name.size() > 0) - { - std::vector source = sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds[edges[index_active_edge].index_to].points_local; - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - - for (size_t i = 0; i < source.size(); i++) - { - pointcloud.push_back(source[i]); - intensity.push_back(0); - timestamps.push_back(0.0); - } - - exportLaz( - output_file_name[0], - pointcloud, - intensity, - timestamps); - } - - /*int number_of_iterations = 30; - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - std::vector source = sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds[edges[index_active_edge].index_to].points_local; - std::vector target = sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[edges[index_active_edge].index_from].points_local; - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - { - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - }*/ - //save - } - ImGui::SameLine(); - if (ImGui::Button("Save trg (transfromed only by rotation)")) - { - } -#endif - ////////////////////////////////// - } - } - } - - ImGui::End(); - } -} - -void save_trajectories_to_laz( - const Session& session, - const std::string& output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling) -{ - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - - float consecutive_distance = 0; - for (auto& p : session.point_clouds_container.point_clouds) - { - if (p.visible) - { - for (size_t i = 0; i < p.local_trajectory.size(); i++) - { - const auto& pp = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d vp; - vp = p.m_pose * pp; // + session.point_clouds_container.offset; - - if (i > 0) - { - double dist = (p.local_trajectory[i].m_pose.translation() - p.local_trajectory[i - 1].m_pose.translation()).norm(); - consecutive_distance += dist; - } - - bool is_curve = false; - - if (i > 100 && i < p.local_trajectory.size() - 100) - { - Eigen::Vector3d position_prev = p.local_trajectory[i - 100].m_pose.translation(); - Eigen::Vector3d position_curr = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d position_next = p.local_trajectory[i + 100].m_pose.translation(); - - Eigen::Vector3d v1 = position_curr - position_prev; - Eigen::Vector3d v2 = position_next - position_curr; - - if (v1.norm() > 0 && v2.norm() > 0) - { - double angle_deg = fabs(acos(v1.dot(v2) / (v1.norm() * v2.norm())) * RAD_TO_DEG); - - if (angle_deg > 10.0) - { - is_curve = true; - } - } - } - double tol = not_curve_consecutive_distance_meters; - - if (is_curve) - { - tol = curve_consecutive_distance_meters; - } - - if (!is_trajectory_export_downsampling) - { - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(p.local_trajectory[i].timestamps.first); - } - else - { - if (consecutive_distance >= tol) - { - consecutive_distance = 0; - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(p.local_trajectory[i].timestamps.first); - } - } - } - } - } - // if (!exportLaz(output_file_name, pointcloud, intensity, gnss.offset_x, gnss.offset_y, gnss.offset_alt)) - if (!exportLaz( - output_file_name, - pointcloud, - intensity, - timestamps, - session.point_clouds_container.offset.x(), - session.point_clouds_container.offset.y(), - session.point_clouds_container.offset.z())) - { - std::cout << "problem with saving file: " << output_file_name << std::endl; - } -} - -void createDXFPolyline(const std::string& filename, const std::vector& points) -{ - std::ofstream dxfFile(filename); - dxfFile << std::setprecision(20); - if (!dxfFile.is_open()) - { - std::cerr << "Failed to open file: " << filename << std::endl; - return; - } - - // DXF header - dxfFile << "0\nSECTION\n2\nHEADER\n0\nENDSEC\n"; - dxfFile << "0\nSECTION\n2\nTABLES\n0\nENDSEC\n"; - - // Start the ENTITIES section - dxfFile << "0\nSECTION\n2\nENTITIES\n"; - - // Start the POLYLINE entity - dxfFile << "0\nPOLYLINE\n"; - dxfFile << "8\n0\n"; // Layer 0 - dxfFile << "66\n1\n"; // Indicates the presence of vertices - dxfFile << "70\n8\n"; // 1 = Open polyline - - // Write the VERTEX entities - for (const auto& point : points) - { - dxfFile << "0\nVERTEX\n"; - dxfFile << "8\n0\n"; // Layer 0 - dxfFile << "10\n" << point.x() << "\n"; // X coordinate - dxfFile << "20\n" << point.y() << "\n"; // Y coordinate - dxfFile << "30\n" << point.z() << "\n"; // Z coordinate - } - - // End the POLYLINE - dxfFile << "0\nSEQEND\n"; - - // End the ENTITIES section - dxfFile << "0\nENDSEC\n"; - - // End the DXF file - dxfFile << "0\nEOF\n"; - - dxfFile.close(); - std::cout << "DXF file created: " << filename << std::endl; -} - -void save_trajectories( - Session& session, - const std::string& output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling, - bool write_lidar_timestamp, - bool write_unix_timestamp, - bool use_quaternions, - bool save_to_dxf) -{ - std::ofstream outfile; - if (!save_to_dxf) - { - outfile.open(output_file_name); - } - if (save_to_dxf || outfile.good()) - { - float consecutive_distance = 0; - std::vector polylinePoints; - for (auto& p : session.point_clouds_container.point_clouds) - { - if (p.visible) - { - for (size_t i = 0; i < p.local_trajectory.size(); i++) - { - const auto& m = p.local_trajectory[i].m_pose; - Eigen::Affine3d pose = p.m_pose * m; - pose.translation() += session.point_clouds_container.offset; - - if (i > 0) - { - double dist = (p.local_trajectory[i].m_pose.translation() - p.local_trajectory[i - 1].m_pose.translation()).norm(); - consecutive_distance += dist; - } - - bool is_curve = false; - - if (i > 100 && i < p.local_trajectory.size() - 100) - { - Eigen::Vector3d position_prev = p.local_trajectory[i - 100].m_pose.translation(); - Eigen::Vector3d position_curr = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d position_next = p.local_trajectory[i + 100].m_pose.translation(); - - Eigen::Vector3d v1 = position_curr - position_prev; - Eigen::Vector3d v2 = position_next - position_curr; - - if (v1.norm() > 0 && v2.norm() > 0) - { - double angle_deg = fabs(acos(v1.dot(v2) / (v1.norm() * v2.norm())) * RAD_TO_DEG); - - if (angle_deg > 10.0) - is_curve = true; - } - } - double tol = not_curve_consecutive_distance_meters; - - if (is_curve) - tol = curve_consecutive_distance_meters; - - if (!is_trajectory_export_downsampling || (is_trajectory_export_downsampling && consecutive_distance >= tol)) - { - if (is_trajectory_export_downsampling) - consecutive_distance = 0; - if (save_to_dxf) - polylinePoints.push_back(pose.translation()); - else - { - outfile << std::setprecision(20); - - if (write_lidar_timestamp) - outfile << p.local_trajectory[i].timestamps.first << ","; - if (write_unix_timestamp) - outfile << p.local_trajectory[i].timestamps.second << ","; - - outfile << pose(0, 3) << "," << pose(1, 3) << "," << pose(2, 3) << ","; - if (use_quaternions) - { - Eigen::Quaterniond q(pose.rotation()); - outfile << q.x() << "," << q.y() << "," << q.z() << "," << q.w() << std::endl; - } - else - outfile << pose(0, 0) << "," << pose(0, 1) << "," << pose(0, 2) << "," << pose(1, 0) << "," << pose(1, 1) - << "," << pose(1, 2) << "," << pose(2, 0) << "," << pose(2, 1) << "," << pose(2, 2) << std::endl; - } - } - } - } - } - if (!save_to_dxf) - outfile.close(); - else - createDXFPolyline(output_file_name, polylinePoints); - } -} - -bool save_project_settings(const std::string& file_name, const ProjectSettings& _project_settings) -{ - std::cout << "saving file: '" << file_name << "'" << std::endl; - - nlohmann::json jj; - - nlohmann::json jsession_file_names; - for (const auto& pc : _project_settings.session_file_names) - { - nlohmann::json jfn{ { "session_file_name", toSessionPath(pc, file_name) } }; - jsession_file_names.push_back(jfn); - } - jj["session_file_names"] = jsession_file_names; - - nlohmann::json jloop_closure_edges; - for (const auto& edge : edges) - { - nlohmann::json jloop_closure_edge{ - { "px", edge.relative_pose_tb.px }, - { "py", edge.relative_pose_tb.py }, - { "pz", edge.relative_pose_tb.pz }, - { "om", edge.relative_pose_tb.om }, - { "fi", edge.relative_pose_tb.fi }, - { "ka", edge.relative_pose_tb.ka }, - { "w_px", edge.relative_pose_tb_weights.px }, - { "w_py", edge.relative_pose_tb_weights.py }, - { "w_pz", edge.relative_pose_tb_weights.pz }, - { "w_om", edge.relative_pose_tb_weights.om }, - { "w_fi", edge.relative_pose_tb_weights.fi }, - { "w_ka", edge.relative_pose_tb_weights.ka }, - { "index_from", edge.index_from }, - { "index_to", edge.index_to }, - { "is_fixed_px", edge.is_fixed_px }, - { "is_fixed_py", edge.is_fixed_py }, - { "is_fixed_pz", edge.is_fixed_pz }, - { "is_fixed_om", edge.is_fixed_om }, - { "is_fixed_fi", edge.is_fixed_fi }, - { "is_fixed_ka", edge.is_fixed_ka }, - { "index_session_from", edge.index_session_from }, - { "index_session_to", edge.index_session_to }, - }; - jloop_closure_edges.push_back(jloop_closure_edge); - } - jj["loop_closure_edges"] = jloop_closure_edges; - - std::ofstream fs(file_name); - if (!fs.good()) - return false; - fs << jj.dump(2); - fs.close(); - - return true; -} - -void update_timestamp_offset() -{ - std::cout << "update_timestamp" << std::endl; - time_stamp_offset = std::numeric_limits::max(); - - for (const auto& s : sessions) - { - if (!s.point_clouds_container.point_clouds.empty() && !s.point_clouds_container.point_clouds[0].local_trajectory.empty()) - { - double ts = s.point_clouds_container.point_clouds[0].local_trajectory[0].timestamps.first; - if (ts < time_stamp_offset) - time_stamp_offset = ts; - } - } - - std::cout << "new time_stamp_offset = " << time_stamp_offset << std::endl; -} - -bool revert(std::vector& sessions) -{ - for (auto& session : sessions) - { - for (auto& pc : session.point_clouds_container.point_clouds) - pc.m_pose = pc.m_pose_temp; - } - return true; -} - -bool revert_to_initial(std::vector& sessions) -{ - for (auto& session : sessions) - { - for (auto& pc : session.point_clouds_container.point_clouds) - pc.m_pose = pc.m_initial_pose; - } - return true; -} - -bool save_results(std::vector& sessions) -{ - for (auto& session : sessions) - { - if (!session.is_ground_truth) - { - std::cout << "saving result to: " << session.point_clouds_container.poses_file_name << std::endl; - session.point_clouds_container.save_poses(fs::path(session.point_clouds_container.poses_file_name).string(), false); - } - } - return true; -} - -Eigen::Vector3d GLWidgetGetOGLPos(int x, int y, const ObservationPicking& observation_picking) -{ - const auto laser_beam = GetLaserBeam(x, y); - - RegistrationPlaneFeature::Plane pl; - - pl.a = 0; - pl.b = 0; - pl.c = 1; - pl.d = -observation_picking.picking_plane_height; - - Eigen::Vector3d pos = rayIntersection(laser_beam, pl); - - std::cout << "intersection: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl; - - return pos; -} - -bool loadProject(const std::string& file_name, ProjectSettings& _project_settings) -{ - std::cout << "Opening project file: '" << file_name << "'\n"; - - try - { - std::ifstream fs(file_name); - if (!fs.good()) - return false; - nlohmann::json data = nlohmann::json::parse(fs); - fs.close(); - - _project_settings.session_file_names.clear(); - - std::cout << "Contained sessions:\n"; - - for (const auto& fn_json : data["session_file_names"]) - { - const std::string fn = resolveProjectPath(fn_json["session_file_name"].get(), file_name); - _project_settings.session_file_names.push_back(fn); - std::cout << "'" << fn << "'"; - if (!fs::exists(fn)) - std::cout << " (WARNING: session file does not exist! Please manually adapt path)"; - std::cout << "\n"; - } - - edges.clear(); - for (const auto& edge_json : data["loop_closure_edges"]) - { - Edge edge; - edge.index_from = edge_json["index_from"]; - edge.index_to = edge_json["index_to"]; - edge.is_fixed_fi = edge_json["is_fixed_fi"]; - edge.is_fixed_ka = edge_json["is_fixed_ka"]; - edge.is_fixed_om = edge_json["is_fixed_om"]; - edge.is_fixed_px = edge_json["is_fixed_px"]; - edge.is_fixed_py = edge_json["is_fixed_py"]; - edge.is_fixed_pz = edge_json["is_fixed_pz"]; - edge.relative_pose_tb.fi = edge_json["fi"]; - edge.relative_pose_tb.ka = edge_json["ka"]; - edge.relative_pose_tb.om = edge_json["om"]; - edge.relative_pose_tb.px = edge_json["px"]; - edge.relative_pose_tb.py = edge_json["py"]; - edge.relative_pose_tb.pz = edge_json["pz"]; - edge.relative_pose_tb_weights.fi = edge_json["w_fi"]; - edge.relative_pose_tb_weights.ka = edge_json["w_ka"]; - edge.relative_pose_tb_weights.om = edge_json["w_om"]; - edge.relative_pose_tb_weights.px = edge_json["w_px"]; - edge.relative_pose_tb_weights.py = edge_json["w_py"]; - edge.relative_pose_tb_weights.pz = edge_json["w_pz"]; - edge.index_session_from = edge_json["index_session_from"]; - edge.index_session_to = edge_json["index_session_to"]; - edges.push_back(edge); - } - - std::cout << "Found " << edges.size() << "edges\nOpening done\n"; - - return true; - } catch (std::exception& e) - { - std::cout << "can't load project settings: " << e.what() << std::endl; - return false; - } - - std::string newTitle = winTitle + " - " + truncPath(file_name); - glutSetWindowTitle(newTitle.c_str()); - - loaded_sessions = false; - time_stamp_offset = 0.0; - - return true; -} - -void openProject() -{ - std::string input_file_name = ""; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Open project", mandeye::fd::Project_filter); - - if (input_file_name.size() > 0) - { - loadProject(fs::path(input_file_name).string(), project_settings); - } -} - -void saveProject() -{ - std::string output_file_name = ""; - output_file_name = mandeye::fd::SaveFileDialog("Save project file", mandeye::fd::Project_filter, ".mjp", "project"); - - if (output_file_name.size() > 0) - if (save_project_settings(fs::path(output_file_name).string(), project_settings)) - { - std::string newTitle = winTitle + " - " + truncPath(output_file_name); - glutSetWindowTitle(newTitle.c_str()); - } -} - -void addSession() -{ - auto input_file_names = mandeye::fd::OpenFileDialog("Add session(s)", mandeye::fd::Session_filter, true); - - if (input_file_names.size() > 0) - { - for (const auto& input_file_name : input_file_names) - { - std::cout << "Adding session file: '" << input_file_name << "'" << std::endl; - project_settings.session_file_names.push_back(input_file_name); - } - - loaded_sessions = false; - time_stamp_offset = 0.0; - } -} - -void loadSessions() -{ - sessions.clear(); - for (const auto& ps : project_settings.session_file_names) - { - Session session; - session.load(fs::path(ps).string(), is_decimate, bucket_x, bucket_y, bucket_z, calculate_offset); - - // making sure irelevant session specific settings that could affect rendering are off - session.point_clouds_container.xz_intersection = false; - session.point_clouds_container.yz_intersection = false; - session.point_clouds_container.xy_intersection = false; - session.point_clouds_container.xz_grid_10x10 = false; - session.point_clouds_container.xz_grid_1x1 = false; - session.point_clouds_container.xz_grid_01x01 = false; - session.point_clouds_container.yz_grid_10x10 = false; - session.point_clouds_container.yz_grid_1x1 = false; - session.point_clouds_container.yz_grid_01x01 = false; - session.point_clouds_container.xy_grid_10x10 = false; - session.point_clouds_container.xy_grid_1x1 = false; - session.point_clouds_container.xy_grid_01x01 = false; - - sessions.push_back(session); - if (session.is_ground_truth) - index_gt = sessions.size() - 1; - } - loaded_sessions = true; - - // reorder - std::vector sessions_reorder; - std::vector session_file_names_reordered; - - std::map map_reorder; - // project_settings.session_file_names. - int new_index = 0; - for (size_t i = 0; i < sessions.size(); i++) - { - if (sessions[i].is_ground_truth) - { - sessions_reorder.push_back(sessions[i]); - session_file_names_reordered.push_back(project_settings.session_file_names[i]); - map_reorder[i] = new_index++; - } - } - for (size_t i = 0; i < sessions.size(); i++) - { - if (!sessions[i].is_ground_truth) - { - sessions_reorder.push_back(sessions[i]); - session_file_names_reordered.push_back(project_settings.session_file_names[i]); - map_reorder[i] = new_index++; - } - } - sessions = sessions_reorder; - project_settings.session_file_names = session_file_names_reordered; - - for (auto& e : edges) - { - e.index_session_from = map_reorder[e.index_session_from]; - e.index_session_to = map_reorder[e.index_session_to]; - } - - std::cout << "sessions reordered, ground truth should be in front" << std::endl; - for (const auto& s : sessions) - { - std::cout << "session: '" << s.session_file_name << "' ground truth [" << int(s.is_ground_truth) << "]" << std::endl; - } - - // update time_stamp_offset - std::cout << "update time_stamp_offset" << std::endl; - for (const auto& s : sessions) - { - if (s.point_clouds_container.point_clouds.size() > 0) - { - if (s.point_clouds_container.point_clouds[0].local_trajectory.size() > 0) - { - if (s.point_clouds_container.point_clouds[0].local_trajectory[0].timestamps.first > time_stamp_offset) - { - time_stamp_offset = s.point_clouds_container.point_clouds[0].local_trajectory[0].timestamps.first; - } - } - } - } -} - -void generate_loop_closures(const std::vector& sessions, std::vector& edges) -{ - edges.clear(); - // Implementation for generating loop closures - - // bool found_edge = false; - - for (int i1 = 0; i1 < sessions.size(); i1++) - { - for (int j1 = 0; j1 < sessions[i1].point_clouds_container.point_clouds.size(); j1++) - { - Eigen::Affine3d pose_i = sessions[i1].point_clouds_container.point_clouds[j1].m_pose; - - for (int i2 = i1 + 1; i2 < sessions.size(); i2++) - { - for (int j2 = 0; j2 < sessions[i2].point_clouds_container.point_clouds.size(); j2++) - { - Eigen::Affine3d pose_j = sessions[i2].point_clouds_container.point_clouds[j2].m_pose; - - if ((pose_i.translation() - pose_j.translation()).norm() < 10.0) // Example threshold for proximity - { - // found_edge = true; - // Create a loop closure edge between pose_i and pose_j - /*Edge edge; - edge.index_session_from = i1; - edge.index_from = j1; - edge.index_session_to = i2; - edge.index_to = j2; - - // Initialize other edge parameters as needed - edges.push_back(edge);*/ - - Edge edge; - - edge.index_session_from = i1; - edge.index_session_to = i2; - - edge.index_from = j1; - edge.index_to = j2; - - std::cout << "Found loop closure edge between session " << i1 << " (pose " << j1 << ") and session " << i2 - << " (pose " << j2 << ")" << std::endl; - - edge.relative_pose_tb = pose_tait_bryan_from_affine_matrix( - sessions[edge.index_session_from].point_clouds_container.point_clouds[edge.index_from].m_pose.inverse() * - sessions[edge.index_session_to].point_clouds_container.point_clouds[edge.index_to].m_pose); - - edge.relative_pose_tb_weights.px = 1.0; - edge.relative_pose_tb_weights.py = 1.0; - edge.relative_pose_tb_weights.pz = 1.0; - edge.relative_pose_tb_weights.om = 1.0; - edge.relative_pose_tb_weights.fi = 1.0; - edge.relative_pose_tb_weights.ka = 1.0; - - edges.push_back(edge); - - // j1 += 20; - // j2 += 20; - } - } - } // for(int i2 = i1 + 1; i2 < sessions.size(); i2++) - } // for(int j1 = 0; j1 < sessions[i1].point_clouds_container.point_clouds.size(); j1++) - } // for(int i1 = 0; i1 < sessions.size(); i1++) -} - -void icp_all_edges(std::vector& sessions, std::vector& edges, float sr) -{ - std::cout << "icp_all_edges" << std::endl; - - int number_of_iterations = 10; - - for (size_t index_active_edge = 0; index_active_edge < edges.size(); index_active_edge++) - { - PairWiseICP icp; - auto m_pose = affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - std::vector source; - auto& e = edges[index_active_edge]; - for (int i = -num_edge_extended_before; i <= num_edge_extended_after; i++) - { - int index_src = e.index_to + i; - if (index_src >= 0 && - index_src < sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.size()) - { - Eigen::Affine3d m_src = - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.at(index_src).m_pose; - for (int k = 0; k < - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds[index_src].points_local.size(); - k++) - { - Eigen::Vector3d p_g = m_src * - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds[index_src].points_local[k]; - source.push_back(p_g); - } - // point_clouds_container.point_clouds.at(index_src).render(m_src, 1); - } - } - std::vector target; - - for (int i = -num_edge_extended_before; i <= num_edge_extended_after; i++) - { - int index_trg = e.index_from + i; - if (index_trg >= 0 && - index_trg < sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.size()) - { - Eigen::Affine3d m_trg = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_trg).m_pose; - for (int k = 0; k < sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[index_trg] - .points_local.size(); - k++) - { - Eigen::Vector3d p_g = m_trg * - sessions[edges[index_active_edge].index_session_from] - .point_clouds_container.point_clouds[index_trg] - .points_local[k]; - target.push_back(p_g); - } - // point_clouds_container.point_clouds.at(index_src).render(m_src, 1); - } - } - - Eigen::Affine3d m_src_inv = - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds[e.index_to].m_pose.inverse(); - - for (auto& p : source) - { - p = m_src_inv * p; - } - - Eigen::Affine3d m_trg_inv = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds[e.index_from].m_pose.inverse(); - - for (auto& p : target) - { - p = m_trg_inv * p; - } - - if (icp.compute(source, target, sr, number_of_iterations, m_pose)) - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_pose); - } -} - -void settings_gui() -{ - if (ImGui::Begin("Settings", &is_settings_gui)) - { - ImGui::Checkbox("Downsample during load", &is_decimate); - ImGui::SameLine(); - ImGui::Text("Bucket [m]:"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("X##b", &bucket_x, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("Y##b", &bucket_y, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("Z##b", &bucket_z, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::PopItemWidth(); - - ImGui::NewLine(); - - ImGui::Separator(); - - ImGui::Text("Benchmark settings:"); - - ImGui::PushItemWidth(ImGuiNumberWidth * 2); - - static double fast_plus = 100000000.0; - static double fast_plus_plus = 1000000000.0; - - ImGui::InputDouble("Increment", &fast_plus); - ImGui::InputDouble("Fast increment", &fast_plus_plus); - ImGui::InputDouble("Timestamp offset", &time_stamp_offset, fast_plus, fast_plus_plus); - ImGui::PopItemWidth(); - ImGui::SameLine(); - if (ImGui::Button("Set to origin")) - { - bool is_first_gt = false; - - if (sessions.size() > 0) - { - if (sessions[0].is_ground_truth) - is_first_gt = true; - } - - Eigen::Affine3d m_gt = Eigen::Affine3d::Identity(); - if (sessions.size() > 0) - { - int index_point_clouds = -1; - int index_local_trajectory = -1; - bool found = false; - for (size_t a = 0; a < sessions[0].point_clouds_container.point_clouds.size(); a++) - { - for (size_t b = 0; b < sessions[0].point_clouds_container.point_clouds[a].local_trajectory.size(); b++) - { - if (sessions[0].point_clouds_container.point_clouds[a].local_trajectory[b].timestamps.first > time_stamp_offset) - { - if (!found) - { - found = true; - index_point_clouds = a; - index_local_trajectory = b; - break; - } - } - } - } - - if (index_point_clouds != -1 && index_local_trajectory != -1) - { - m_gt = sessions[0].point_clouds_container.point_clouds[index_point_clouds].m_pose * - sessions[0].point_clouds_container.point_clouds[index_point_clouds].local_trajectory[index_local_trajectory].m_pose; - } - } - - // for (auto& session : sessions) - for (auto& session : sessions) - { - if (is_first_gt) - { - if (session.is_ground_truth) - continue; - } - - int index_point_clouds = -1; - int index_local_trajectory = -1; - bool found = false; - for (size_t a = 0; a < session.point_clouds_container.point_clouds.size(); a++) - { - for (size_t b = 0; b < session.point_clouds_container.point_clouds[a].local_trajectory.size(); b++) - { - if (session.point_clouds_container.point_clouds[a].local_trajectory[b].timestamps.first > time_stamp_offset) - { - if (!found) - { - found = true; - index_point_clouds = a; - index_local_trajectory = b; - break; - } - } - } - } - - if (index_point_clouds != -1 && index_local_trajectory != -1) - { - auto m1 = session.point_clouds_container.point_clouds[index_point_clouds].m_pose; - auto m2 = - session.point_clouds_container.point_clouds[index_point_clouds].local_trajectory[index_local_trajectory].m_pose; - - auto inv = Eigen::Affine3d::Identity(); - inv = (m1 * m2).inverse(); - for (size_t index = 0; index < session.point_clouds_container.point_clouds.size(); index++) - session.point_clouds_container.point_clouds[index].m_pose = - inv * session.point_clouds_container.point_clouds[index].m_pose; - - for (size_t index = 0; index < session.point_clouds_container.point_clouds.size(); index++) - session.point_clouds_container.point_clouds[index].m_pose = - m_gt * session.point_clouds_container.point_clouds[index].m_pose; - } - } - } - - static bool open_import_popup = false; - static bool show_instruction = false; - - ImGui::Dummy(ImVec2(0, 10)); - - if (ImGui::Button("Import Benchmark Output Folders")) - { - open_import_popup = true; - ImGui::OpenPopup("Import Benchmark"); - } - - if (ImGui::BeginPopupModal("Import Benchmark", NULL, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::Text("Import benchmark sessions"); - ImGui::Separator(); - ImGui::SetNextWindowSize(ImVec2(740, 340), ImGuiCond_Once); - if (ImGui::Button("Instruction")) - { - show_instruction = !show_instruction; - } - - ImGui::Dummy(ImVec2(0, 10)); - if (ImGui::Button("Select Folder")) - { - const std::string algorithms[] = { "ct-icp", "glim", "super-lio", "dlio", - "i2ekf-lo", "superOdom", "lego-loam", "faster-lio", - "kiss-icp", "fast-lio", "lio-ekf", "genz-icp", - "point-lio", "ig-lio", "dlo", "lidar_odometry_ros_wrapper" }; - - std::vector missing; - std::unordered_map algo_map; - - for (const auto& algo : algorithms) - { - if (algo == "kiss-icp") - { - algo_map[algo] = "output_hdmapping-kiss"; - } - else if (algo == "genz-icp") - { - algo_map[algo] = "output_hdmapping-genz"; - } - else if (algo == "lidar_odometry_ros_wrapper") - { - algo_map[algo] = "output_hdmapping-lidar-odometry-ros"; - } - else - { - algo_map[algo] = "output_hdmapping-" + algo; - } - } - - fs::path path = fs::path(mandeye::fd::SelectFolder("Add sessions")); - - for (const auto& algo : algorithms) - { - fs::path output_folder = path / algo / algo_map[algo]; - fs::path session_file = output_folder / "session.json"; - - if (fs::is_directory(output_folder)) - { - auto it = - std::find(project_settings.session_file_names.begin(), project_settings.session_file_names.end(), session_file); - - if (it == project_settings.session_file_names.end()) - { - std::cout << "Adding session file: '" << session_file << "'" << std::endl; - project_settings.session_file_names.push_back(session_file.string()); - } - } - else - { - missing.push_back(output_folder); - } - } - - for (const auto& miss : missing) - { - std::cout << miss << " doesn't exist" << std::endl; - } - } - - ImGui::SameLine(); - - if (ImGui::Button("Close")) - { - ImGui::CloseCurrentPopup(); - show_instruction = false; - } - - if (show_instruction) - { - ImGui::BeginChild("InstructionChild", ImVec2(720, 300), true, ImGuiWindowFlags_HorizontalScrollbar); - ImGui::Separator(); - - ImGui::TextWrapped("Required folder structure:"); - - ImGui::Spacing(); - - ImGui::TextWrapped("Folders must follow the structure generated in benchmark-HDMapping-Orchestration (step 3):"); - ImGui::TextWrapped("https://github.com/MapsHD/benchmark-HDMapping-Orchestration"); - - ImGui::Spacing(); - ImGui::Separator(); - - ImGui::BulletText("chosen_folder/"); - ImGui::BulletText(" ct-icp/output_hdmapping-ct-icp/session.json"); - ImGui::BulletText(" glim/output_hdmapping-glim/session.json"); - ImGui::BulletText(" kiss-icp/output_hdmapping-kiss/session.json"); - ImGui::BulletText(" fast-lio/output_hdmapping-fast-lio/session.json"); - ImGui::BulletText(" ... (same pattern for other algorithms)"); - - ImGui::Spacing(); - ImGui::EndChild(); - } - - ImGui::EndPopup(); - } - if (project_settings.session_file_names.size() > 0) - { - ImGui::Separator(); - - ImGui::Text("Sessions:"); - - for (size_t i = 0; i < project_settings.session_file_names.size(); i++) - { - ImGui::Text(truncPath(project_settings.session_file_names[i]).c_str()); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(project_settings.session_file_names[i].c_str()); - - if (project_settings.session_file_names.size() == sessions.size()) - { - ImGui::BeginDisabled(is_loop_closure_gui); - { - ImGui::SameLine(); - ImGui::Checkbox(("Visible##" + std::to_string(i)).c_str(), &sessions[i].visible); - } - ImGui::EndDisabled(); - - ImGui::SameLine(); - if (ImGui::RadioButton(("Ground truth##" + std::to_string(i)).c_str(), &index_gt, i)) - if (old_index_gt == i) - index_gt = -1; // unselect - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select session as unmovable reference"); - - ImGui::BeginDisabled(!sessions[i].visible); - { - ImGui::BeginDisabled(sessions[i].is_ground_truth); - { - ImGui::SameLine(); - if (ImGui::RadioButton(("Gizmo##" + std::to_string(i)).c_str(), &index_gizmo, i)) - if (old_index_gizmo == i) - index_gizmo = -1; // unselect - } - ImGui::EndDisabled(); - - ImGui::SameLine(); - ImGui::ColorEdit3( - ("Color##" + std::to_string(i)).c_str(), (float*)&sessions[i].render_color, ImGuiColorEditFlags_NoInputs); - for (auto& pc : sessions[i].point_clouds_container.point_clouds) - { - pc.traj_color[0] = sessions[i].render_color[0]; - pc.traj_color[1] = sessions[i].render_color[1]; - pc.traj_color[2] = sessions[i].render_color[2]; - pc.render_color[0] = sessions[i].render_color[0]; - pc.render_color[1] = sessions[i].render_color[1]; - pc.render_color[2] = sessions[i].render_color[2]; - } - } - ImGui::EndDisabled(); - - // - if (sessions[i].point_clouds_container.point_clouds.size() > 0) - { - if (sessions[i].point_clouds_container.point_clouds[0].local_trajectory.size() > 0) - { - if (sessions[i] - .point_clouds_container.point_clouds[sessions[i].point_clouds_container.point_clouds.size() - 1] - .local_trajectory.size() > 0) - { - ImGui::SameLine(); - - int index_last = sessions[i].point_clouds_container.point_clouds.size() - 1; - int index_last2 = sessions[i].point_clouds_container.point_clouds[index_last].local_trajectory.size() - 1; - - ImGui::Text( - "Timestamp range: <%.0f, %.0f>", - sessions[i].point_clouds_container.point_clouds[0].local_trajectory[0].timestamps.first, - sessions[i] - .point_clouds_container.point_clouds[index_last] - .local_trajectory[index_last2] - .timestamps.first); - } - } - } - } - } - - if (project_settings.session_file_names.size() == sessions.size()) - { - if ((old_index_gt != index_gt) || (old_index_gizmo != index_gizmo)) - { - for (size_t i = 0; i < sessions.size(); i++) - { - sessions[i].is_ground_truth = (i == index_gt); - sessions[i].is_gizmo = (i == index_gizmo); - } - - old_index_gt = index_gt; - old_index_gizmo = index_gizmo; - } - - if (index_gizmo != -1 && index_gizmo < sessions.size()) - { - // sessions[index_gizmo].is_gizmo = true; - m_gizmo[0] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(0, 0); - m_gizmo[1] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(1, 0); - m_gizmo[2] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(2, 0); - m_gizmo[3] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(3, 0); - m_gizmo[4] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(0, 1); - m_gizmo[5] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(1, 1); - m_gizmo[6] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(2, 1); - m_gizmo[7] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(3, 1); - m_gizmo[8] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(0, 2); - m_gizmo[9] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(1, 2); - m_gizmo[10] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(2, 2); - m_gizmo[11] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(3, 2); - m_gizmo[12] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(0, 3); - m_gizmo[13] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(1, 3); - m_gizmo[14] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(2, 3); - m_gizmo[15] = (float)sessions[index_gizmo].point_clouds_container.point_clouds[0].m_pose(3, 3); - } - } - - ImGui::BeginDisabled((project_settings.session_file_names.size() < 2) || (index_gizmo == -1)); - { - ImGui::Checkbox("Gizmo all sessions", &gizmo_all_sessions); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Gizmo will move all sessions except ground truth one"); - } - ImGui::EndDisabled(); - - ImGui::Separator(); - - ImGui::NewLine(); - - if (project_settings.session_file_names.size() == sessions.size()) - { - number_visible_sessions = 0; - - bool first_session_index_found = false; - for (size_t index = 0; index < sessions.size(); index++) - { - if (sessions[index].visible) - { - number_visible_sessions++; - if (!first_session_index_found) - { - first_session_index = index; - second_session_index = index; - first_session_index_found = true; - } - else - { - second_session_index = index; - } - } - } - - if (!is_loop_closure_gui) - { - static int nr_iter = 100; - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Number of iterations", &nr_iter); - if (nr_iter < 1) - nr_iter = 1; - - ImGui::InputDouble("Motion Model Weight (1 sigma m): position x [px]", &motion_model_weights.px, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("Motion Model Weight (1 sigma m): position y [py]", &motion_model_weights.py, 0.0, 0.0, "%.3f"); - ImGui::InputDouble("Motion Model Weight (1 sigma m): position z [pz]", &motion_model_weights.pz, 0.0, 0.0, "%.3f"); - ImGui::InputDouble( - "Motion Model Weight (1 sigma degree): orientation om [om]", &motion_model_weights.om, 0.0, 0.0, "%.3f"); - ImGui::InputDouble( - "Motion Model Weight (1 sigma degree): orientation fi [fi]", &motion_model_weights.fi, 0.0, 0.0, "%.3f"); - ImGui::InputDouble( - "Motion Model Weight (1 sigma degree): orientation ka [ka]", &motion_model_weights.ka, 0.0, 0.0, "%.3f"); - - std::string bn = "Optimize (number of iterations: " + std::to_string(nr_iter) + ")"; - - if (ImGui::Button(bn.c_str())) - { - for (int i = 0; i < nr_iter; i++) - { - std::cout << "Iteration [" << i + 1 << "] of: " << nr_iter << std::endl; - optimize(sessions, edges, motion_model_weights); - } - optimized = true; - } - - // if (optimized) - //{ - ImGui::SameLine(); - if (ImGui::Button("Revert")) - revert(sessions); - ImGui::SameLine(); - if (ImGui::Button("Save results")) - save_results(sessions); - ImGui::SameLine(); - if (ImGui::Button("Revert to initial")) - revert_to_initial(sessions); - //} - - if (ImGui::Button("Generate loop closures")) - { - generate_loop_closures(sessions, edges); - } - - if (ImGui::Button("ICP all edges")) - { - icp_all_edges(sessions, edges, search_radius); - } - ImGui::SameLine(); - ImGui::InputDouble("search_radius", &search_radius); - if (search_radius < 0.01) - search_radius = 0.01; - } - - // if (!is_loop_closure_gui && prev_is_loop_closure_gui) - //{ - // exit(1); - // } - } - } - } - - ImGui::End(); -} - -void display() -{ - ImGuiIO& io = ImGui::GetIO(); - glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - glClearColor(bg_color.x * bg_color.w, bg_color.y * bg_color.w, bg_color.z * bg_color.w, bg_color.w); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - float ratio = float(io.DisplaySize.x) / float(io.DisplaySize.y); - - updateCameraTransition(); - - viewLocal = Eigen::Affine3f::Identity(); - - for (auto& s : sessions) - { - for (auto& pc : s.point_clouds_container.point_clouds) - { - pc.point_size = gui_point_size; - } - } - - if (!is_ortho) - { - reshape((GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - glTranslatef(translate_x, translate_y, translate_z); - - // janusz - if (is_loop_closure_gui) - { - // sessions[first_session_index].point_clouds_container.point_clouds.at(index_loop_closure_source).render(false, - // observation_picking, viewer_decmiate_point_cloud, false, false, false, false, false, false, false, false, false, false, - // false, false, 100000); - // sessions[second_session_index].point_clouds_container.point_clouds.at(index_loop_closure_target).render(false, - // observation_picking, viewer_decmiate_point_cloud, false, false, false, false, false, false, false, false, false, false, - // false, false, 100000); - - if (first_session_index < sessions[first_session_index].point_clouds_container.point_clouds.size()) - { - if (update_rotation_center) - { - rotation_center.x() = sessions[first_session_index] - .point_clouds_container.point_clouds[index_loop_closure_source] - .m_pose.translation() - .x(); - rotation_center.y() = sessions[first_session_index] - .point_clouds_container.point_clouds[index_loop_closure_source] - .m_pose.translation() - .y(); - rotation_center.z() = sessions[first_session_index] - .point_clouds_container.point_clouds[index_loop_closure_source] - .m_pose.translation() - .z(); - } - } - - if (manipulate_active_edge) - { - if (edges.size() > 0) - { - int index_src = edges[index_active_edge].index_from; - Eigen::Affine3d m_src = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).m_pose; - - if (update_rotation_center) - { - rotation_center.x() = m_src(0, 3); - rotation_center.y() = m_src(1, 3); - rotation_center.z() = m_src(2, 3); - } - } - } - - /*if (session.pose_graph_loop_closure.manipulate_active_edge) - { - if (session.pose_graph_loop_closure.edges.size() > 0) - { - if (session.pose_graph_loop_closure.index_active_edge < session.pose_graph_loop_closure.edges.size()) - { - rotation_center.x() = - session.point_clouds_container.point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge].index_from].m_pose(0, - 3); rotation_center.y() = - session.point_clouds_container.point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge].index_from].m_pose(1, - 3); rotation_center.z() = - session.point_clouds_container.point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge].index_from].m_pose(2, - 3); - } - } - }*/ - } - - viewLocal.translate(rotation_center); - - viewLocal.translate(Eigen::Vector3f(translate_x, translate_y, translate_z)); - if (!lock_z) - viewLocal.rotate(Eigen::AngleAxisf(rotate_x * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - else - viewLocal.rotate(Eigen::AngleAxisf(-90.0 * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - viewLocal.rotate(Eigen::AngleAxisf(rotate_y * DEG_TO_RAD, Eigen::Vector3f::UnitZ())); - - viewLocal.translate(-rotation_center); - - glLoadMatrixf(viewLocal.matrix().data()); - } - else - updateOrthoView(); - - showAxes(); - - if (is_loop_closure_gui) - { - if (manipulate_active_edge) - { - if (edges.size() > 0) - { - /*int index_src = edges[index_active_edge].index_from; - int index_trg = edges[index_active_edge].index_to; - - Eigen::Affine3d m_src = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).m_pose; - Eigen::Affine3d m_trg = m_src * affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).render( - m_src, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).render_color); - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.at(index_trg).render( - m_trg, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.at(index_trg).render_color);*/ - - int index_src = edges[index_active_edge].index_from; - int index_trg = edges[index_active_edge].index_to; - - Eigen::Affine3d _m_src = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).m_pose; - Eigen::Affine3d _m_trg = _m_src * affine_matrix_from_pose_tait_bryan(edges[index_active_edge].relative_pose_tb); - - Eigen::Affine3d m_src_0 = - sessions[first_session_index].point_clouds_container.point_clouds.at(index_loop_closure_source).m_pose; // Todo - - for (int i = index_loop_closure_source - num_edge_extended_before; i <= index_loop_closure_source + num_edge_extended_after; - i++) - { - if (i >= 0 && i < sessions[first_session_index].point_clouds_container.point_clouds.size() && - sessions[first_session_index].point_clouds_container.point_clouds.size() > 0) - { - // ObservationPicking observation_picking; - // point_clouds_container.point_clouds.at(i).render(false, observation_picking, 1, 1, false, false, false, 10000, - // false); - - Eigen::Affine3d m_src_curr = sessions[first_session_index].point_clouds_container.point_clouds.at(i).m_pose; // Todo - Eigen::Affine3d m_src = _m_src * (m_src_0.inverse() * m_src_curr); - - // sessions[first_session_index].point_clouds_container.point_clouds.at(i).point_size = gui_point_size; - - sessions[first_session_index].point_clouds_container.point_clouds.at(i).render( - m_src, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(i).render_color); - } - } - - Eigen::Affine3d m_trg_0 = - sessions[second_session_index].point_clouds_container.point_clouds.at(index_loop_closure_target).m_pose; // Todo - - for (int i = index_loop_closure_target - num_edge_extended_before; i <= index_loop_closure_target + num_edge_extended_after; - i++) - { - if (i >= 0 && i < sessions[second_session_index].point_clouds_container.point_clouds.size() && - sessions[second_session_index].point_clouds_container.point_clouds.size() > 0) - { - // ObservationPicking observation_picking; - // point_clouds_container.point_clouds.at(i).render(false, observation_picking, 1, 1, false, false, false, 10000, - // false); - Eigen::Affine3d m_trg_curr = - sessions[second_session_index].point_clouds_container.point_clouds.at(i).m_pose; // Todo - Eigen::Affine3d m_trg = _m_trg * (m_trg_0.inverse() * m_trg_curr); - - // sessions[second_session_index].point_clouds_container.point_clouds.at(i).point_size = gui_point_size; - sessions[second_session_index].point_clouds_container.point_clouds.at(i).render( - m_trg, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - sessions[edges[index_active_edge].index_session_to].point_clouds_container.point_clouds.at(i).render_color); - } - } - } - } - else - { - ObservationPicking observation_picking; - - /*sessions[first_session_index] - .point_clouds_container.point_clouds.at(index_loop_closure_source) - .render( - false, - observation_picking, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - false, - false, - false, - 100000, - false);*/ - - for (int i = index_loop_closure_source - num_edge_extended_before; i <= index_loop_closure_source + num_edge_extended_after; - i++) - { - if (i >= 0 && i < sessions[first_session_index].point_clouds_container.point_clouds.size() && - sessions[first_session_index].point_clouds_container.point_clouds.size() > 0) - { - // ObservationPicking observation_picking; - // point_clouds_container.point_clouds.at(i).render(false, observation_picking, 1, 1, false, false, false, 10000, - // false); - Eigen::Affine3d m_src = sessions[first_session_index].point_clouds_container.point_clouds.at(i).m_pose; - - sessions[first_session_index].point_clouds_container.point_clouds.at(i).render( - false, - observation_picking, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - false, - false, - false, - 100000, - false); - } - } - - /*sessions[second_session_index] - .point_clouds_container.point_clouds.at(index_loop_closure_target) - .render( - false, - observation_picking, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - false, - false, - false, - 100000, - false);*/ - - for (int i = index_loop_closure_target - num_edge_extended_before; i <= index_loop_closure_target + num_edge_extended_after; - i++) - { - if (i >= 0 && i < sessions[second_session_index].point_clouds_container.point_clouds.size() && - sessions[second_session_index].point_clouds_container.point_clouds.size() > 0) - { - // ObservationPicking observation_picking; - // point_clouds_container.point_clouds.at(i).render(false, observation_picking, 1, 1, false, false, false, 10000, - // false); - Eigen::Affine3d m_src = sessions[second_session_index].point_clouds_container.point_clouds.at(i).m_pose; - - sessions[second_session_index].point_clouds_container.point_clouds.at(i).render( - false, - observation_picking, - viewer_decimate_point_cloud, - viewer_reduce_rendered_trajectory, - false, - false, - false, - 100000, - false); - } - } - } - - // sessions[first_session_index].point_clouds_container.render(); - - glBegin(GL_LINE_STRIP); - for (auto& pc : sessions[first_session_index].point_clouds_container.point_clouds) - { - glColor3f(pc.render_color[0], pc.render_color[1], pc.render_color[2]); - glVertex3f(pc.m_pose(0, 3), pc.m_pose(1, 3), pc.m_pose(2, 3)); - } - glEnd(); - - int i = 0; - for (auto& pc : sessions[first_session_index].point_clouds_container.point_clouds) - { - glColor3f(pc.render_color[0], pc.render_color[1], pc.render_color[2]); - glRasterPos3f(pc.m_pose(0, 3), pc.m_pose(1, 3), pc.m_pose(2, 3) + 0.1); - glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)std::to_string(i).c_str()); - i++; - } - - glBegin(GL_LINE_STRIP); - for (auto& pc : sessions[second_session_index].point_clouds_container.point_clouds) - { - glColor3f(pc.render_color[0], pc.render_color[1], pc.render_color[2]); - glVertex3f(pc.m_pose(0, 3), pc.m_pose(1, 3), pc.m_pose(2, 3)); - } - glEnd(); - - i = 0; - for (auto& pc : sessions[second_session_index].point_clouds_container.point_clouds) - { - glColor3f(pc.render_color[0], pc.render_color[1], pc.render_color[2]); - glRasterPos3f(pc.m_pose(0, 3), pc.m_pose(1, 3), pc.m_pose(2, 3) + 0.1); - glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)std::to_string(i).c_str()); - i++; - } - - for (size_t i = 0; i < sessions.size(); i++) - { - for (size_t j = 0; j < sessions[i].pose_graph_loop_closure.edges.size(); j++) - { - int index_src = sessions[i].pose_graph_loop_closure.edges[j].index_from; - int index_trg = sessions[i].pose_graph_loop_closure.edges[j].index_to; - - glColor3f(0.0f, 0.0f, 1.0f); - glBegin(GL_LINES); - auto v1 = sessions[i].point_clouds_container.point_clouds.at(index_src).m_pose.translation(); - auto v2 = sessions[i].point_clouds_container.point_clouds.at(index_trg).m_pose.translation(); - glVertex3f(v1.x(), v1.y(), v1.z()); - glVertex3f(v2.x(), v2.y(), v2.z()); - - glVertex3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5); - glVertex3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5 + 10); - glEnd(); - - glRasterPos3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5 + 10 + 0.1); - glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)std::to_string(j).c_str()); - } - } - - for (size_t i = 0; i < edges.size(); i++) - { - int index_src = edges[i].index_from; - int index_trg = edges[i].index_to; - - int index_session_from = edges[i].index_session_from; - int index_session_to = edges[i].index_session_to; - - if (sessions[index_session_from].is_ground_truth || sessions[index_session_to].is_ground_truth) - glColor3f(0.0f, 1.0f, 1.0f); - else - glColor3f(1.0f, 1.0f, 0.0f); - - glBegin(GL_LINES); - auto v1 = sessions[index_session_from].point_clouds_container.point_clouds.at(index_src).m_pose.translation(); - auto v2 = sessions[index_session_to].point_clouds_container.point_clouds.at(index_trg).m_pose.translation(); - glVertex3f(v1.x(), v1.y(), v1.z()); - glVertex3f(v2.x(), v2.y(), v2.z()); - - glVertex3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5); - glVertex3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5 + 10); - glEnd(); - - glRasterPos3f((v1.x() + v2.x()) * 0.5, (v1.y() + v2.y()) * 0.5, (v1.z() + v2.z()) * 0.5 + 10 + 0.1); - glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*)std::to_string(i).c_str()); - } - } - else - { - for (auto& session : sessions) - { - if (session.visible) - { - session.point_clouds_container.render(observation_picking, viewer_decimate_point_cloud, viewer_reduce_rendered_trajectory); - session.ground_control_points.render(session.point_clouds_container); - session.control_points.render(session.point_clouds_container, false); - - //// - int index_point_clouds = -1; - int index_local_trajectory = -1; - bool found = false; - for (size_t a = 0; a < session.point_clouds_container.point_clouds.size(); a++) - { - for (size_t b = 0; b < session.point_clouds_container.point_clouds[a].local_trajectory.size(); b++) - { - if (session.point_clouds_container.point_clouds[a].local_trajectory[b].timestamps.first > time_stamp_offset) - { - if (!found) - { - found = true; - index_point_clouds = a; - index_local_trajectory = b; - break; - } - } - } - } - - if (index_point_clouds != -1 && index_local_trajectory != -1) - { - if (index_local_trajectory < session.point_clouds_container.point_clouds[index_point_clouds].local_trajectory.size()) - { - glColor3f( - session.point_clouds_container.point_clouds[index_point_clouds].render_color[0], - session.point_clouds_container.point_clouds[index_point_clouds].render_color[1], - session.point_clouds_container.point_clouds[index_point_clouds].render_color[2]); - glBegin(GL_LINES); - - auto m1 = session.point_clouds_container.point_clouds[index_point_clouds].m_pose; - auto m2 = - session.point_clouds_container.point_clouds[index_point_clouds].local_trajectory[index_local_trajectory].m_pose; - - auto v1 = (m1 * m2).translation(); - - glVertex3f(v1.x() - 5.0, v1.y(), v1.z()); - glVertex3f(v1.x() + 5.0, v1.y(), v1.z()); - - glVertex3f(v1.x(), v1.y() - 5.0, v1.z()); - glVertex3f(v1.x(), v1.y() + 5.0, v1.z()); - - glVertex3f(v1.x(), v1.y(), v1.z() - 5.0); - glVertex3f(v1.x(), v1.y(), v1.z() + 5.0); - - glEnd(); - } - } - } - } - } - - /*if (is_loop_closure_gui) - { - session.manual_pose_graph_loop_closure.Render(session.point_clouds_container, index_loop_closure_source, index_loop_closure_target); - } - else - { - for (const auto &g : available_geo_points) - { - glBegin(GL_LINES); - glColor3f(1.0f, 0.0f, 0.0f); - auto c = g.coordinates - session.point_clouds_container.offset; - glVertex3f(c.x() - 0.5, c.y(), c.z()); - glVertex3f(c.x() + 0.5, c.y(), c.z()); - - glVertex3f(c.x(), c.y() - 0.5, c.z()); - glVertex3f(c.x(), c.y() + 0.5, c.z()); - - glVertex3f(c.x(), c.y(), c.z() - 0.5); - glVertex3f(c.x(), c.y(), c.z() + 0.5); - glEnd(); - } - - // - for (const auto &pc : session.point_clouds_container.point_clouds) - { - for (const auto &gp : pc.available_geo_points) - { - if (gp.choosen) - { - auto c = pc.m_pose * gp.coordinates; - glBegin(GL_LINES); - glColor3f(1.0f, 0.0f, 0.0f); - glVertex3f(c.x() - 0.5, c.y(), c.z()); - glVertex3f(c.x() + 0.5, c.y(), c.z()); - - glVertex3f(c.x(), c.y() - 0.5, c.z()); - glVertex3f(c.x(), c.y() + 0.5, c.z()); - - glVertex3f(c.x(), c.y(), c.z() - 0.5); - glVertex3f(c.x(), c.y(), c.z() + 0.5); - glEnd(); - - glBegin(GL_LINES); - glColor3f(0.0f, 1.0f, 0.0f); - glVertex3f(c.x(), c.y(), c.z()); - glVertex3f(gp.coordinates.x(), gp.coordinates.y(), gp.coordinates.z()); - glEnd(); - - glColor3f(0.0f, 0.0f, 0.0f); - glBegin(GL_LINES); - glVertex3f(c.x(), c.y(), c.z()); - glVertex3f(c.x() + 10, c.y(), c.z()); - glEnd(); - - glRasterPos3f(c.x() + 10, c.y(), c.z()); - glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char *)gp.name.c_str()); - } - } - } - }*/ - - // gnss.render(session.point_clouds_container); - - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGLUT_NewFrame(); - ImGui::NewFrame(); - - ShowMainDockSpace(); - - if (!is_loop_closure_gui) - { - Eigen::Affine3d prev_pose_manipulated = Eigen::Affine3d::Identity(); - Eigen::Affine3d prev_pose_after_gismo = Eigen::Affine3d::Identity(); - - for (size_t i = 0; i < sessions.size(); i++) - { - // guizmo_all_sessions; - if (sessions[i].is_gizmo && !sessions[i].is_ground_truth) - { - if (sessions[i].point_clouds_container.point_clouds.size() > 0) - { - prev_pose_manipulated = sessions[i].point_clouds_container.point_clouds[0].m_pose; - std::vector all_m_poses; - for (size_t j = 0; j < sessions[i].point_clouds_container.point_clouds.size(); j++) - all_m_poses.push_back(sessions[i].point_clouds_container.point_clouds[j].m_pose); - - ImGuiIO& io = ImGui::GetIO(); - - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - modelview, - projection, - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - } - else - ImGuizmo::Manipulate( - m_ortho_gizmo_view, - m_ortho_projection, - ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | ImGuizmo::ROTATE_Z, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - sessions[i].point_clouds_container.point_clouds[0].m_pose = Eigen::Map(m_gizmo).cast(); - prev_pose_after_gismo = sessions[i].point_clouds_container.point_clouds[0].m_pose; - sessions[i].point_clouds_container.point_clouds[0].pose = - pose_tait_bryan_from_affine_matrix(sessions[i].point_clouds_container.point_clouds[0].m_pose); - - sessions[i].point_clouds_container.point_clouds[0].gui_translation[0] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.px; - sessions[i].point_clouds_container.point_clouds[0].gui_translation[1] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.py; - sessions[i].point_clouds_container.point_clouds[0].gui_translation[2] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.pz; - - sessions[i].point_clouds_container.point_clouds[0].gui_rotation[0] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.om * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[0].gui_rotation[1] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.fi * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[0].gui_rotation[2] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.ka * RAD_TO_DEG); - - Eigen::Affine3d curr_m_pose = sessions[i].point_clouds_container.point_clouds[0].m_pose; - for (size_t j = 1; j < sessions[i].point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose = curr_m_pose * (all_m_poses[j - 1].inverse() * all_m_poses[j]); - sessions[i].point_clouds_container.point_clouds[j].m_pose = curr_m_pose; - sessions[i].point_clouds_container.point_clouds[j].pose = - pose_tait_bryan_from_affine_matrix(sessions[i].point_clouds_container.point_clouds[j].m_pose); - - sessions[i].point_clouds_container.point_clouds[j].gui_translation[0] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.px; - sessions[i].point_clouds_container.point_clouds[j].gui_translation[1] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.py; - sessions[i].point_clouds_container.point_clouds[j].gui_translation[2] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.pz; - - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[0] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.om * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[1] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.fi * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[2] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.ka * RAD_TO_DEG); - } - //} - } - } - } - if (gizmo_all_sessions) - { - for (size_t i = 0; i < sessions.size(); i++) - { - // guizmo_all_sessions; - if (!sessions[i].is_gizmo && !sessions[i].is_ground_truth) - { - std::vector all_m_poses; - for (size_t j = 0; j < sessions[i].point_clouds_container.point_clouds.size(); j++) - all_m_poses.push_back(sessions[i].point_clouds_container.point_clouds[j].m_pose); - - Eigen::Affine3d m_rel_org = prev_pose_manipulated.inverse() * sessions[i].point_clouds_container.point_clouds[0].m_pose; - - Eigen::Affine3d m_new = prev_pose_after_gismo * m_rel_org; - - sessions[i].point_clouds_container.point_clouds[0].m_pose = m_new; - sessions[i].point_clouds_container.point_clouds[0].pose = - pose_tait_bryan_from_affine_matrix(sessions[i].point_clouds_container.point_clouds[0].m_pose); - - sessions[i].point_clouds_container.point_clouds[i].gui_translation[0] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.px; - sessions[i].point_clouds_container.point_clouds[i].gui_translation[1] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.py; - sessions[i].point_clouds_container.point_clouds[i].gui_translation[2] = - (float)sessions[i].point_clouds_container.point_clouds[0].pose.pz; - - sessions[i].point_clouds_container.point_clouds[i].gui_rotation[0] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.om * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[i].gui_rotation[1] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.fi * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[i].gui_rotation[2] = - (float)(sessions[i].point_clouds_container.point_clouds[0].pose.ka * RAD_TO_DEG); - - Eigen::Affine3d curr_m_pose = sessions[i].point_clouds_container.point_clouds[0].m_pose; - for (size_t j = 1; j < sessions[i].point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose = curr_m_pose * (all_m_poses[j - 1].inverse() * all_m_poses[j]); - sessions[i].point_clouds_container.point_clouds[j].m_pose = curr_m_pose; - sessions[i].point_clouds_container.point_clouds[j].pose = - pose_tait_bryan_from_affine_matrix(sessions[i].point_clouds_container.point_clouds[j].m_pose); - - sessions[i].point_clouds_container.point_clouds[j].gui_translation[0] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.px; - sessions[i].point_clouds_container.point_clouds[j].gui_translation[1] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.py; - sessions[i].point_clouds_container.point_clouds[j].gui_translation[2] = - (float)sessions[i].point_clouds_container.point_clouds[j].pose.pz; - - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[0] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.om * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[1] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.fi * RAD_TO_DEG); - sessions[i].point_clouds_container.point_clouds[j].gui_rotation[2] = - (float)(sessions[i].point_clouds_container.point_clouds[j].pose.ka * RAD_TO_DEG); - } - } - } - } - } - else - { - // ImGuizmo ----------------------------------------------- - if (edge_gizmo && edges.size() > 0) - { - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - &modelview[0], - &projection[0], - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - } - else - ImGuizmo::Manipulate( - m_ortho_gizmo_view, - m_ortho_projection, - ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | ImGuizmo::ROTATE_Z, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - Eigen::Affine3d m_g = Eigen::Affine3d::Identity(); - - m_g.matrix() = Eigen::Map(m_gizmo).cast(); - - const int& index_src = edges[index_active_edge].index_from; - - const Eigen::Affine3d& m_src = - sessions[edges[index_active_edge].index_session_from].point_clouds_container.point_clouds.at(index_src).m_pose; - edges[index_active_edge].relative_pose_tb = pose_tait_bryan_from_affine_matrix(m_src.inverse() * m_g); - } - } - - /*if (!is_loop_closure_gui) -{ - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (session.point_clouds_container.point_clouds[i].gizmo) - { - std::vector all_m_poses; - for (size_t j = 0; j < session.point_clouds_container.point_clouds.size(); j++) - all_m_poses.push_back(session.point_clouds_container.point_clouds[j].m_pose); - - ImGuiIO &io = ImGui::GetIO(); - // ImGuizmo ----------------------------------------------- - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate(&modelview[0], &projection[0], ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | -ImGuizmo::ROTATE_Y, ImGuizmo::WORLD, m_gizmo, NULL); - } - else - ImGuizmo::Manipulate(m_ortho_gizmo_view, m_ortho_projection, ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | -ImGuizmo::ROTATE_Z, ImGuizmo::WORLD, m_gizmo, NULL); - - session.point_clouds_container.point_clouds[i].m_pose(0, 0) = m_gizmo[0]; - session.point_clouds_container.point_clouds[i].m_pose(1, 0) = m_gizmo[1]; - session.point_clouds_container.point_clouds[i].m_pose(2, 0) = m_gizmo[2]; - session.point_clouds_container.point_clouds[i].m_pose(3, 0) = m_gizmo[3]; - session.point_clouds_container.point_clouds[i].m_pose(0, 1) = m_gizmo[4]; - session.point_clouds_container.point_clouds[i].m_pose(1, 1) = m_gizmo[5]; - session.point_clouds_container.point_clouds[i].m_pose(2, 1) = m_gizmo[6]; - session.point_clouds_container.point_clouds[i].m_pose(3, 1) = m_gizmo[7]; - session.point_clouds_container.point_clouds[i].m_pose(0, 2) = m_gizmo[8]; - session.point_clouds_container.point_clouds[i].m_pose(1, 2) = m_gizmo[9]; - session.point_clouds_container.point_clouds[i].m_pose(2, 2) = m_gizmo[10]; - session.point_clouds_container.point_clouds[i].m_pose(3, 2) = m_gizmo[11]; - session.point_clouds_container.point_clouds[i].m_pose(0, 3) = m_gizmo[12]; - session.point_clouds_container.point_clouds[i].m_pose(1, 3) = m_gizmo[13]; - session.point_clouds_container.point_clouds[i].m_pose(2, 3) = m_gizmo[14]; - session.point_clouds_container.point_clouds[i].m_pose(3, 3) = m_gizmo[15]; - session.point_clouds_container.point_clouds[i].pose = -pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[i].m_pose); - - session.point_clouds_container.point_clouds[i].gui_translation[0] = -(float)session.point_clouds_container.point_clouds[i].pose.px; session.point_clouds_container.point_clouds[i].gui_translation[1] = -(float)session.point_clouds_container.point_clouds[i].pose.py; session.point_clouds_container.point_clouds[i].gui_translation[2] = -(float)session.point_clouds_container.point_clouds[i].pose.pz; - - session.point_clouds_container.point_clouds[i].gui_rotation[0] = (float)(session.point_clouds_container.point_clouds[i].pose.om -* RAD_TO_DEG); session.point_clouds_container.point_clouds[i].gui_rotation[1] = -(float)(session.point_clouds_container.point_clouds[i].pose.fi * RAD_TO_DEG); session.point_clouds_container.point_clouds[i].gui_rotation[2] -= (float)(session.point_clouds_container.point_clouds[i].pose.ka * RAD_TO_DEG); - - if (!manipulate_only_marked_gizmo) - { - Eigen::Affine3d curr_m_pose = session.point_clouds_container.point_clouds[i].m_pose; - for (size_t j = i + 1; j < session.point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose = curr_m_pose * (all_m_poses[j - 1].inverse() * all_m_poses[j]); - session.point_clouds_container.point_clouds[j].m_pose = curr_m_pose; - session.point_clouds_container.point_clouds[j].pose = -pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[j].m_pose); - - session.point_clouds_container.point_clouds[j].gui_translation[0] = -(float)session.point_clouds_container.point_clouds[j].pose.px; session.point_clouds_container.point_clouds[j].gui_translation[1] = -(float)session.point_clouds_container.point_clouds[j].pose.py; session.point_clouds_container.point_clouds[j].gui_translation[2] = -(float)session.point_clouds_container.point_clouds[j].pose.pz; - - session.point_clouds_container.point_clouds[j].gui_rotation[0] = -(float)(session.point_clouds_container.point_clouds[j].pose.om * RAD_TO_DEG); session.point_clouds_container.point_clouds[j].gui_rotation[1] -= (float)(session.point_clouds_container.point_clouds[j].pose.fi * RAD_TO_DEG); - session.point_clouds_container.point_clouds[j].gui_rotation[2] = -(float)(session.point_clouds_container.point_clouds[j].pose.ka * RAD_TO_DEG); - } - } - } - } - - session.point_clouds_container.render(observation_picking, viewer_decmiate_point_cloud); - observation_picking.render(); - - glPushAttrib(GL_ALL_ATTRIB_BITS); - glPointSize(5); - for (const auto &obs : observation_picking.observations) - { - for (const auto &[key1, value1] : obs) - { - for (const auto &[key2, value2] : obs) - { - if (key1 != key2) - { - Eigen::Vector3d p1, p2; - if (session.point_clouds_container.show_with_initial_pose) - { - p1 = session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_initial_pose * value2; - } - else - { - p1 = session.point_clouds_container.point_clouds[key1].m_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_pose * value2; - } - glColor3f(0, 1, 0); - glBegin(GL_POINTS); - glVertex3f(p1.x(), p1.y(), p1.z()); - glVertex3f(p2.x(), p2.y(), p2.z()); - glEnd(); - glColor3f(1, 0, 0); - glBegin(GL_LINES); - glVertex3f(p1.x(), p1.y(), p1.z()); - glVertex3f(p2.x(), p2.y(), p2.z()); - glEnd(); - } - } - } - } - glPopAttrib(); - - for (const auto &obs : observation_picking.observations) - { - Eigen::Vector3d mean(0, 0, 0); - int counter = 0; - for (const auto &[key1, value1] : obs) - { - mean += session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - counter++; - } - if (counter > 0) - { - mean /= counter; - - glColor3f(1, 0, 0); - glBegin(GL_LINE_STRIP); - glVertex3f(mean.x() - 1, mean.y() - 1, mean.z()); - glVertex3f(mean.x() + 1, mean.y() - 1, mean.z()); - glVertex3f(mean.x() + 1, mean.y() + 1, mean.z()); - glVertex3f(mean.x() - 1, mean.y() + 1, mean.z()); - glVertex3f(mean.x() - 1, mean.y() - 1, mean.z()); - glEnd();F - } - } - - glColor3f(1, 0, 1); - glBegin(GL_POINTS); - for (auto p : picked_points) - { - glVertex3f(p.x(), p.y(), p.z()); - } - glEnd(); -} -else -{ - // ImGuizmo ----------------------------------------------- - if (session.manual_pose_graph_loop_closure.gizmo && session.manual_pose_graph_loop_closure.edges.size() > 0) - { - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate(&modelview[0], &projection[0], ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | -ImGuizmo::ROTATE_Y, ImGuizmo::WORLD, m_gizmo, NULL); - } - else - ImGuizmo::Manipulate(m_ortho_gizmo_view, m_ortho_projection, ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | ImGuizmo::ROTATE_Z, -ImGuizmo::WORLD, m_gizmo, NULL); - - Eigen::Affine3d m_g = Eigen::Affine3d::Identity(); - - m_g(0, 0) = m_gizmo[0]; - m_g(1, 0) = m_gizmo[1]; - m_g(2, 0) = m_gizmo[2]; - m_g(3, 0) = m_gizmo[3]; - m_g(0, 1) = m_gizmo[4]; - m_g(1, 1) = m_gizmo[5]; - m_g(2, 1) = m_gizmo[6]; - m_g(3, 1) = m_gizmo[7]; - m_g(0, 2) = m_gizmo[8]; - m_g(1, 2) = m_gizmo[9]; - m_g(2, 2) = m_gizmo[10]; - m_g(3, 2) = m_gizmo[11]; - m_g(0, 3) = m_gizmo[12]; - m_g(1, 3) = m_gizmo[13]; - m_g(2, 3) = m_gizmo[14]; - m_g(3, 3) = m_gizmo[15]; - - const int &index_src = -session.manual_pose_graph_loop_closure.edges[session.manual_pose_graph_loop_closure.index_active_edge].index_from; - - const Eigen::Affine3d &m_src = session.point_clouds_container.point_clouds.at(index_src).m_pose; - session.manual_pose_graph_loop_closure.edges[session.manual_pose_graph_loop_closure.index_active_edge].relative_pose_tb = -pose_tait_bryan_from_affine_matrix(m_src.inverse() * m_g); - } -}*/ - - view_kbd_shortcuts(); - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_A, false)) - { - addSession(); - - // workaround - io.AddKeyEvent(ImGuiKey_A, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - if ((project_settings.session_file_names.size() > 0) && !loaded_sessions) - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_L, false)) - { - loadSessions(); - - // workaround - io.AddKeyEvent(ImGuiKey_L, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_O, false)) - { - openProject(); - - // workaround - io.AddKeyEvent(ImGuiKey_O, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (project_settings.session_file_names.size() > 0) - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_R, false)) - { - remove_gui = true; - - // workaround - io.AddKeyEvent(ImGuiKey_R, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (sessions.size() > 0) - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_S, false)) - { - saveProject(); - - // workaround - io.AddKeyEvent(ImGuiKey_S, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Open project", "Ctrl+O")) - openProject(); - if (ImGui::MenuItem("Save project", "Ctrl+S", nullptr, project_settings.session_file_names.size() > 0)) - saveProject(); - - ImGui::Separator(); - - if (ImGui::MenuItem("Add session(s)", "Ctrl+A")) - addSession(); - if (ImGui::MenuItem("Remove session(s)", "Ctrl+R", nullptr, project_settings.session_file_names.size() > 0)) - remove_gui = true; - - if (ImGui::MenuItem("Load sessions", "Ctrl+L", nullptr, (project_settings.session_file_names.size() > 0) && !loaded_sessions)) - loadSessions(); - - ImGui::Separator(); - - if (ImGui::BeginMenu("Save all marked trajectories", sessions.size() > 0)) - { - if (ImGui::MenuItem("Save all as las/laz files")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string laz_path = (dir / (folder_name + "_trajectory_laz.laz")).string(); - - std::cout << "Saving trajectory to LAZ: " << laz_path << std::endl; - - save_trajectories_to_laz(session, laz_path, 0.0f, 0.0f, false); - } - - std::cout << "Finished saving all trajectories to .laz files." << std::endl; - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("As one global scan"); - - ImGui::Separator(); - - ImGui::Text("(x,y,z,r00,r01,r02,r10,r11,r12,r20,r21,r22)"); - if (ImGui::MenuItem("Save all as csv (timestamp Lidar)##1")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampLidar_r.csv")).string(); - - std::cout << "Saving trajectory to CSV: " << csv_path << std::endl; - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampLidar,x,y,z," << "r00,r01,r02," << "r10,r11,r12," << "r20,r21,r22\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Matrix3d rot = pose.rotation(); - - outfile << std::fixed << std::setprecision(0) << traj.timestamps.first << "," << std::setprecision(10) - << pos.x() << "," << pos.y() << "," << pos.z() << "," << rot(0, 0) << "," << rot(0, 1) << "," - << rot(0, 2) << "," << rot(1, 0) << "," << rot(1, 1) << "," << rot(1, 2) << "," << rot(2, 0) - << "," << rot(2, 1) << "," << rot(2, 2) << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - - std::cout << "Finished saving all trajectories to CSV files." << std::endl; - } - if (ImGui::MenuItem("Save all as csv (timestamp Unix)##1")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampUnix_r.csv")).string(); - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampUnix,x,y,z," << "r00,r01,r02,r10,r11,r12,r20,r21,r22\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Matrix3d rot = pose.rotation(); - outfile << std::fixed << std::setprecision(0) << traj.timestamps.second << "," // Unix timestamp - << std::setprecision(10) << pos.x() << "," << pos.y() << "," << pos.z() << "," << rot(0, 0) - << "," << rot(0, 1) << "," << rot(0, 2) << "," << rot(1, 0) << "," << rot(1, 1) << "," - << rot(1, 2) << "," << rot(2, 0) << "," << rot(2, 1) << "," << rot(2, 2) << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - } - if (ImGui::MenuItem("Save all as csv (timestamp Lidar, Unix)##1")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampLidarUnix_r.csv")).string(); - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampLidar,timestampUnix,x,y,z," << "r00,r01,r02,r10,r11,r12,r20,r21,r22\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Matrix3d rot = pose.rotation(); - outfile << std::fixed << std::setprecision(0) << traj.timestamps.first << "," // Lidar timestamp - << traj.timestamps.second << "," // Unix timestamp - << std::setprecision(10) << pos.x() << "," << pos.y() << "," << pos.z() << "," << rot(0, 0) - << "," << rot(0, 1) << "," << rot(0, 2) << "," << rot(1, 0) << "," << rot(1, 1) << "," - << rot(1, 2) << "," << rot(2, 0) << "," << rot(2, 1) << "," << rot(2, 2) << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - } - - ImGui::Separator(); - ImGui::Text("(x,y,z,qx,qy,qz,qw)"); - - if (ImGui::MenuItem("Save all as csv (timestamp Lidar)##2")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampLidar_q.csv")).string(); - - std::cout << "Saving trajectory to CSV: " << csv_path << std::endl; - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampLidar,x,y,z,qx,qy,qz,qw\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Quaterniond q(pose.rotation()); - - outfile << std::fixed << std::setprecision(0) << traj.timestamps.first << "," // Lidar timestamp - << std::setprecision(10) << pos.x() << "," << pos.y() << "," << pos.z() << "," << q.x() << "," - << q.y() << "," << q.z() << "," << q.w() << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - - std::cout << "Finished saving all trajectories to CSV files." << std::endl; - } - if (ImGui::MenuItem("Save all as csv (timestamp Unix)##2")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampUnix_q.csv")).string(); - - std::cout << "Saving trajectory to CSV: " << csv_path << std::endl; - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampUnix,x,y,z,qx,qy,qz,qw\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Quaterniond q(pose.rotation()); - - outfile << std::fixed << std::setprecision(0) << traj.timestamps.second << "," // Unix timestamp - << std::setprecision(10) << pos.x() << "," << pos.y() << "," << pos.z() << "," << q.x() << "," - << q.y() << "," << q.z() << "," << q.w() << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - - std::cout << "Finished saving all trajectories to CSV files." << std::endl; - } - if (ImGui::MenuItem("Save all as csv (timestamp Lidar, Unix)##2")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string csv_path = (dir / (folder_name + "_trajectory_timestampLidarUnix_q.csv")).string(); - - std::cout << "Saving trajectory to CSV: " << csv_path << std::endl; - - try - { - std::ofstream outfile(csv_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << csv_path << std::endl; - continue; - } - - outfile << "timestampLidar,timestampUnix,x,y,z,qx,qy,qz,qw\n"; - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Quaterniond q(pose.rotation()); - - outfile << std::fixed << std::setprecision(0) << traj.timestamps.first << "," // Lidar timestamp - << traj.timestamps.second << "," // Unix timestamp - << std::setprecision(10) << pos.x() << "," << pos.y() << "," << pos.z() << "," << q.x() << "," - << q.y() << "," << q.z() << "," << q.w() << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << csv_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << csv_path << ": " << e.what() << std::endl; - } - } - - std::cout << "Finished saving all trajectories to CSV files." << std::endl; - } - if (ImGui::MenuItem("Save all as TUM TXT")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - Session& session = sessions[i]; - std::filesystem::path dir = std::filesystem::path(session_path).parent_path(); - std::string folder_name = dir.filename().string(); - std::string txt_path = (dir / (folder_name + "_trajectory_tum.txt")).string(); - - std::cout << "Saving trajectory to TUM TXT: " << txt_path << std::endl; - try - { - std::ofstream outfile(txt_path); - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << txt_path << std::endl; - continue; - } - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - Eigen::Vector3d pos = pose.translation(); - Eigen::Quaterniond q(pose.rotation()); - - double t_s = static_cast(traj.timestamps.first) / 1e9; - - outfile << std::fixed << std::setprecision(9) << t_s << " " << std::setprecision(10) << pos.x() << " " - << pos.y() << " " << pos.z() << " " << q.x() << " " << q.y() << " " << q.z() << " " << q.w() - << "\n"; - } - } - - outfile.close(); - std::cout << "Saved: " << txt_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << txt_path << ": " << e.what() << std::endl; - } - } - std::cout << "Finished saving all trajectories to TUM TXT files." << std::endl; - } - if (ImGui::MenuItem("Save all as TUM TXT (single folder)")) - { - for (size_t i = 0; i < project_settings.session_file_names.size(); ++i) - { - const auto& session_path = project_settings.session_file_names[i]; - - if (i >= sessions.size()) - { - std::cerr << "No loaded session for: " << session_path << std::endl; - continue; - } - - Session& session = sessions[i]; - - std::filesystem::path session_dir = std::filesystem::path(session_path).parent_path(); - - std::filesystem::path base_dir = session_dir.parent_path(); - - std::filesystem::path output_dir = base_dir / "all_tum_files"; - - try - { - std::filesystem::create_directories(output_dir); - } catch (const std::exception& e) - { - std::cerr << "Failed to create export directory: " << e.what() << std::endl; - continue; - } - - std::string folder_name = session_dir.filename().string(); - - std::filesystem::path txt_path = output_dir / (folder_name + "_trajectory_tum.txt"); - - std::cout << "Saving trajectory to TUM TXT: " << txt_path << std::endl; - - try - { - std::ofstream outfile(txt_path); - - if (!outfile.is_open()) - { - std::cerr << "Failed to create file: " << txt_path << std::endl; - continue; - } - - for (const auto& pc : session.point_clouds_container.point_clouds) - { - if (!pc.visible) - continue; - - for (const auto& traj : pc.local_trajectory) - { - Eigen::Affine3d pose = pc.m_pose * traj.m_pose; - - Eigen::Vector3d pos = pose.translation(); - - Eigen::Quaterniond q(pose.rotation()); - - double t_s = static_cast(traj.timestamps.first) / 1e9; - - outfile << std::fixed << std::setprecision(9) << t_s << " " << std::setprecision(10) << pos.x() << " " - << pos.y() << " " << pos.z() << " " << q.x() << " " << q.y() << " " << q.z() << " " << q.w() - << "\n"; - } - } - - outfile.close(); - - std::cout << "Saved: " << txt_path << std::endl; - } catch (const std::exception& e) - { - std::cerr << "Error creating " << txt_path << ": " << e.what() << std::endl; - } - } - std::cout << "Finished saving all trajectories to single folder." << std::endl; - } - - ImGui::EndMenu(); - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Tools")) - { - ImGui::MenuItem("Normal Distributions Transform", nullptr, &is_ndt_gui, !is_loop_closure_gui && (sessions.size() > 0)); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Point cloud alignment (registration) algorithm"); - ImGui::Text( - "Probabilistic alternative to ICP that models one cloud (the target)\nas a set of Gaussian distributions " - "rather than raw points"); - ImGui::Text( - "Robust for rough initial poses but can converge to a local optimum\nif the initial misalignment is very large"); - ImGui::Text( - "Known for being faster and smoother in optimization because\nit replaces discrete point-point correspondences " - "with continuous probability density functions."); - ImGui::EndTooltip(); - } - - // bool prev_is_loop_closure_gui - ImGui::MenuItem( - "Manual Loop Closure", "Ctrl+L", &is_loop_closure_gui, (number_visible_sessions == 1 || number_visible_sessions == 2)); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Manually connect overlapping scan sections"); - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("View")) - { - ImGui::BeginDisabled(!(sessions.size() > 0)); - { - auto tmp = point_size; - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points size", &point_size); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("keyboard 1-9 keys"); - if (point_size < 1) - point_size = 1; - else if (point_size > 10) - point_size = 10; - - if (tmp != point_size) - for (auto& session : sessions) - for (auto& point_cloud : session.point_clouds_container.point_clouds) - point_cloud.point_size = point_size; - - ImGui::Separator(); - } - ImGui::EndDisabled(); - - if (ImGui::MenuItem("Orthographic", "key O", &is_ortho)) - { - if (is_ortho) - { - new_rotation_center = rotation_center; - new_rotate_x = 0.0; - new_rotate_y = 0.0; - new_translate_x = translate_x; - new_translate_y = translate_y; - new_translate_z = translate_z; - camera_transition_active = true; - } - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Switch between perspective view (3D) and orthographic view (2D/flat)"); - - ImGui::MenuItem("Show axes", "key X", &show_axes); - ImGui::MenuItem("Show compass/ruler", "key C", &compass_ruler); - - ImGui::MenuItem("Lock Z", "Shift + Z", &lock_z, !is_ortho); - - // ImGui::MenuItem("show_covs", nullptr, &show_covs); - - ImGui::Separator(); - - ImGui::Text("Colors:"); - - ImGui::ColorEdit3("Background", (float*)&bg_color, ImGuiColorEditFlags_NoInputs); - - ImGui::Separator(); - - ImGui::MenuItem("Settings", nullptr, &is_settings_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show power user settings window with more parameters"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Scene view relevant parameters"); - - camMenu(); - - ImGui::BeginDisabled(sessions.size() <= 0); - { - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points render downsampling", &viewer_decimate_point_cloud, 10, 100); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("increase for better performance, decrease for rendering more points"); - // ImGui::SameLine(); - - if (viewer_decimate_point_cloud < 1) - viewer_decimate_point_cloud = 1; - - ImGui::SameLine(); - - ImGui::InputInt("Trajectory reduce render", &viewer_reduce_rendered_trajectory, 10, 100); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("increase for better performance, decrease for rendering more nodes in the trajectory"); - // ImGui::SameLine(); - - if (viewer_reduce_rendered_trajectory < 1) - viewer_reduce_rendered_trajectory = 1; - - ImGui::SameLine(); - - ImGui::Text("(%.1f FPS)", ImGui::GetIO().Framerate); - } - ImGui::EndDisabled(); - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - ImGui::SameLine( - ImGui::GetWindowWidth() - ImGui::CalcTextSize("Info").x - ImGui::GetStyle().ItemSpacing.x * 2 - - ImGui::GetStyle().FramePadding.x * 2); - - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_Header)); - if (ImGui::SmallButton("Info")) - info_gui = !info_gui; - - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(3); - - ImGui::EndMainMenuBar(); - } - - if (remove_gui) - { - ImGui::OpenPopup("Remove session(s)"); - remove_gui = false; - } - - if (ImGui::BeginPopupModal("Remove session(s)", NULL, ImGuiWindowFlags_AlwaysAutoResize)) - { - static std::vector session_marked_for_removal; - if (session_marked_for_removal.size() != project_settings.session_file_names.size()) - session_marked_for_removal.resize(project_settings.session_file_names.size(), false); - - ImGui::Text("Select session(s) to remove:"); - ImGui::Separator(); - - for (size_t i = 0; i < project_settings.session_file_names.size(); i++) - { - bool checked = session_marked_for_removal[i]; - if (ImGui::Checkbox(project_settings.session_file_names[i].c_str(), &checked)) - session_marked_for_removal[i] = checked; - } - - ImGui::Separator(); - - if (ImGui::Button("Remove")) - { - for (size_t i = project_settings.session_file_names.size(); i > 0; --i) - { - size_t idx = i - 1; - - if (session_marked_for_removal[idx]) - { - std::cout << "Removing session: " << project_settings.session_file_names[idx] << std::endl; - - project_settings.session_file_names.erase(project_settings.session_file_names.begin() + idx); - - if (idx < sessions.size()) - sessions.erase(sessions.begin() + idx); - } - } - session_marked_for_removal.clear(); - - if (!sessions.empty()) - update_timestamp_offset(); - else - { - loaded_sessions = false; - time_stamp_offset = 0.0; - } - - ImGui::CloseCurrentPopup(); - } - - ImGui::SameLine(); - if (ImGui::Button("Cancel")) - { - session_marked_for_removal.clear(); - ImGui::CloseCurrentPopup(); - } - - ImGui::EndPopup(); - } - - if (is_ndt_gui) - ndt_gui(); - - if (is_loop_closure_gui) - loop_closure_gui(); - - cor_window(); - - info_window(infoLines, appShortcuts); - - if (compass_ruler) - drawMiniCompassWithRuler(); - - // my_display_code(); - /*if (is_ndt_gui) - ndt_gui(); - if (is_icp_gui) - icp_gui(); - if (is_pose_graph_slam) - pose_graph_slam_gui(); - if (is_registration_plane_feature) - registration_plane_feature_gui(); - if (is_manual_analisys) - observation_picking_gui();*/ - // if (is_loop_closure_gui) - // manual_pose_graph_loop_closure.Gui(); - - if (is_settings_gui) - settings_gui(); - - ImGui::Render(); - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -void mouse(int glut_button, int state, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - int button = -1; - if (glut_button == GLUT_LEFT_BUTTON) - button = 0; - if (glut_button == GLUT_RIGHT_BUTTON) - button = 1; - if (glut_button == GLUT_MIDDLE_BUTTON) - button = 2; - if (button != -1 && state == GLUT_DOWN) - io.MouseDown[button] = true; - if (button != -1 && state == GLUT_UP) - io.MouseDown[button] = false; - - static int glutMajorVersion = glutGet(GLUT_VERSION) / 10000; - if (state == GLUT_DOWN && (glut_button == 3 || glut_button == 4) && glutMajorVersion < 3) - wheel(glut_button, glut_button == 3 ? 1 : -1, x, y); - - if (!io.WantCaptureMouse) - { - if ((glut_button == GLUT_MIDDLE_BUTTON || glut_button == GLUT_RIGHT_BUTTON) && state == GLUT_DOWN && (io.KeyCtrl || io.KeyShift) && - !manipulate_active_edge) - { - // if (s_loop_closure_gui) - if ((sessions.size() > 0) && (number_visible_sessions > 0) && update_rotation_center) - { - getClosestTrajectoriesPoint( - sessions, - x, - y, - first_session_index, - second_session_index, - number_visible_sessions, - index_loop_closure_source, - index_loop_closure_target, - io.KeyShift, - time_stamp_offset); - } - else - { - if (update_rotation_center) - { - setNewRotationCenter(x, y); - } - } - } - - if (state == GLUT_DOWN) - { - mouse_buttons |= 1 << glut_button; - - /*if (observation_picking.is_observation_picking_mode) - { - Eigen::Vector3d p = GLWidgetGetOGLPos(x, y, observation_picking); - int number_active_pcs = 0; - int index_picked = -1; - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (session.point_clouds_container.point_clouds[i].visible) - { - number_active_pcs++; - index_picked = i; - } - } - if (number_active_pcs == 1) - { - observation_picking.add_picked_to_current_observation(index_picked, p); - } - }*/ - } - else if (state == GLUT_UP) - { - mouse_buttons = 0; - } - mouse_old_x = x; - mouse_old_y = y; - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (checkClHelp(argc, argv)) - { - std::cout << winTitle << "\n\n" - << "USAGE:\n" - << std::filesystem::path(argv[0]).stem().string() << " /?\n\n" - << "where\n" - << " Path to Mandeye JSON Project file (*.mjp)\n" - << " -h, /h, --help, /? Show this help and exit\n\n"; - - return 0; - } - - initGL(&argc, argv, winTitle, display, mouse); - - if (argc > 1) - { - for (int i = 1; i < argc; i++) - { - std::string ext = fs::path(argv[i]).extension().string(); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - - if (ext == ".mjp") - { - loadProject(argv[i], project_settings); - - break; - } - } - } - - glutMainLoop(); - - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGLUT_Shutdown(); - ImGui::DestroyContext(); - } catch (const std::bad_alloc& e) - { - std::cerr << "System is out of memory : " << e.what() << std::endl; - mandeye::fd::OutOfMemMessage(); - } catch (const std::exception& e) - { - std::cout << e.what(); - } catch (...) - { - std::cerr << "Unknown fatal error occurred." << std::endl; - } - - return 0; -} \ No newline at end of file diff --git a/apps/multi_session_registration_legacy/resource.h b/apps/multi_session_registration_legacy/resource.h deleted file mode 100644 index 4f3204cae..000000000 --- a/apps/multi_session_registration_legacy/resource.h +++ /dev/null @@ -1,17 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDI_ICON1 101 // application icon -#define VS_VERSION_INFO 1 // version info - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/apps/multi_session_registration_legacy/resource.rc b/apps/multi_session_registration_legacy/resource.rc deleted file mode 100644 index e88214861..000000000 --- a/apps/multi_session_registration_legacy/resource.rc +++ /dev/null @@ -1,49 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 0, 0, 100, 1 -PRODUCTVERSION 0, 0, 100, 1 -FILEFLAGSMASK 0x3fL -FILEOS 0x40004 -FILETYPE 0x1 -BEGIN -BLOCK "StringFileInfo" -BEGIN -BLOCK "040904B0" -BEGIN -VALUE "CompanyName", "Mandeye\0" -VALUE "FileDescription", "HDMapping Step 3\0" -VALUE "FileVersion", "0.100.1\0" -VALUE "InternalName", "Multi session registration\0" -VALUE "LegalCopyright", "(c) 2026 github.com/MapsHD/HDMapping\0" -VALUE "OriginalFilename", "multi_session_registration_step_3.exe\0" -VALUE "ProductVersion", "0.100.1\0" -VALUE "ProgramID", "github.com/MapsHD/HDMapping\0" -VALUE "ProductName", "HDMapping\0" -END -END -BLOCK "VarFileInfo" -BEGIN -VALUE "Translation", 0x409, 0x04B0 -END -END -///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/apps/multi_view_tls_registration_legacy/CMakeLists.txt b/apps/multi_view_tls_registration_legacy/CMakeLists.txt deleted file mode 100644 index 51331851d..000000000 --- a/apps/multi_view_tls_registration_legacy/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -cmake_minimum_required(VERSION 4.0.0) - -# Legacy GLUT + legacy immediate-mode OpenGL build of step2, kept side by -# side with apps/multi_view_tls_registration (raylib-based since it was -# ported off GLUT) at a stakeholder's request. This is a full, independent -# copy of the app as it was before that port -- not sharing translation -# units with apps/multi_view_tls_registration -- so the two can diverge or -# be retired independently. -project(multi_view_tls_registration_step_2_legacy) - -# Source files -set(SOURCES - multi_view_tls_registration.cpp perform_experiment.cpp - multi_view_tls_registration_gui.cpp multi_view_tls_registration.h - ../lidar_odometry_step_1/lidar_odometry_utils.cpp - "../../core/src/utils.cpp" -) - -# Windows: add resource file -if(WIN32) - list(APPEND SOURCES "resource.rc") -endif() - -add_executable( - multi_view_tls_registration_step_2_legacy ${SOURCES} - ) - -target_compile_definitions(multi_view_tls_registration_step_2_legacy PRIVATE -DWITH_GUI=1) - -target_include_directories( - multi_view_tls_registration_step_2_legacy - PRIVATE include - ${REPOSITORY_DIRECTORY}/core/include - ${THIRDPARTY_DIRECTORY}/glm - ${EIGEN3_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY} - ${THIRDPARTY_DIRECTORY}/imgui - ${THIRDPARTY_DIRECTORY}/imgui/backends - ${THIRDPARTY_DIRECTORY}/ImGuizmo - ${THIRDPARTY_DIRECTORY}/glew-cmake/include - ${FREEGLUT_INCLUDE_DIR} - ${THIRDPARTY_DIRECTORY}/json/include - ${THIRDPARTY_DIRECTORY}/portable-file-dialogs-master - ${LASZIP_INCLUDE_DIR}/LASzip/include - ${THIRDPARTY_DIRECTORY}/observation_equations/codes - ${THIRDPARTY_DIRECTORY}/vqf/vqf/cpp - ${EXTERNAL_LIBRARIES_DIRECTORY}/include) - - target_link_libraries( - multi_view_tls_registration_step_2_legacy - PRIVATE - WGS84toCartesian - wgs84_do_puwg92 - unordered_dense::unordered_dense - spdlog::spdlog - OpenGL::GLU - ${FREEGLUT_LIBRARY} - ${OPENGL_gl_LIBRARY} - ${PLATFORM_LASZIP_LIB} - ${PLATFORM_MISCELLANEOUS_LIBS} - ${CORE_LIBRARIES} - ${GUI_LIBRARIES} - PROJ::proj) - -if(WIN32) - add_custom_command( - TARGET multi_view_tls_registration_step_2_legacy - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy - $ - $ - COMMAND_EXPAND_LISTS) -endif() - -if (MSVC) - target_compile_options(multi_view_tls_registration_step_2_legacy PRIVATE /bigobj) -endif() - -hdmapping_install_app(multi_view_tls_registration_step_2_legacy) diff --git a/apps/multi_view_tls_registration_legacy/icon.ico b/apps/multi_view_tls_registration_legacy/icon.ico deleted file mode 100644 index 310689ece87833d73eb6857f8869a1703cd082d7..0000000000000000000000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`(vr7KLXYT_^j*FjoS=G&DKE=u_X> zc}8_kOiZ5>o+jIf?HQSR)EjBw -#include -#include - -bool has_extension(const std::string file_path, const std::string extension) -{ - std::string::size_type dot_pos = file_path.find_last_of('.'); - if (dot_pos == std::string::npos) - { - return false; // No extension found - } - std::string file_extension = file_path.substr(dot_pos); - return file_extension == extension; -} - -void initial_pose_to_identity(Session& session) -{ - if (session.point_clouds_container.point_clouds.size() > 0) - { - auto m_inv = session.point_clouds_container.point_clouds[0].m_pose.inverse(); - for (int i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - session.point_clouds_container.point_clouds[i].m_pose = m_inv * session.point_clouds_container.point_clouds[i].m_pose; - } - } -} - -void save_separately_to_las(const Session& session, fs::path outwd, std::string extension) -{ - const auto& clouds = session.point_clouds_container.point_clouds; - if (clouds.size() > 65535) - { - std::cerr << "warning: more than 65535 scans, point_source_ID capped at 65535\n"; - } - for (size_t scan_idx = 0; scan_idx < clouds.size(); ++scan_idx) - { - const auto& p = clouds[scan_idx]; - if (p.visible) - { - const unsigned short psid = static_cast(std::min(scan_idx, 65535)); - fs::path file_path_in = p.file_name; - fs::path file_path_put = outwd; - file_path_put /= (file_path_in.stem().string() + "_processed" + extension); - std::cout << "file_in: " << file_path_in << std::endl; - std::cout << "file_out: " << file_path_put << std::endl; - std::cout << "start save_processed_pc" << std::endl; - bool compressed = (extension == ".laz"); - save_processed_pc(file_path_in, file_path_put, p.m_pose, session.point_clouds_container.offset, compressed, psid); - std::cout << "save_processed_pc finished" << std::endl; - } - } -} - -void save_trajectories_to_laz( - const Session& session, - std::string output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling) -{ - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - std::vector point_source_ids; - - const auto& clouds = session.point_clouds_container.point_clouds; - if (clouds.size() > 65535) - { - std::cerr << "warning: more than 65535 scans, point_source_ID capped at 65535\n"; - } - - float consecutive_distance = 0; - for (size_t scan_idx = 0; scan_idx < clouds.size(); ++scan_idx) - { - const auto& p = clouds[scan_idx]; - if (p.visible) - { - const unsigned short psid = static_cast(std::min(scan_idx, 65535)); - for (int i = 0; i < p.local_trajectory.size(); i++) - { - const auto& pp = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d vp; - vp = p.m_pose * pp; // + session.point_clouds_container.offset; - - if (i > 0) - { - double dist = (p.local_trajectory[i].m_pose.translation() - p.local_trajectory[i - 1].m_pose.translation()).norm(); - consecutive_distance += dist; - } - - bool is_curve = false; - - if (i > 100 && i < p.local_trajectory.size() - 100) - { - Eigen::Vector3d position_prev = p.local_trajectory[i - 100].m_pose.translation(); - Eigen::Vector3d position_curr = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d position_next = p.local_trajectory[i + 100].m_pose.translation(); - - Eigen::Vector3d v1 = position_curr - position_prev; - Eigen::Vector3d v2 = position_next - position_curr; - - if (v1.norm() > 0 && v2.norm() > 0) - { - double angle_deg = fabs(acos(v1.dot(v2) / (v1.norm() * v2.norm())) * 180.0 / M_PI); - - if (angle_deg > 10.0) - { - is_curve = true; - } - } - } - double tol = not_curve_consecutive_distance_meters; - - if (is_curve) - { - tol = curve_consecutive_distance_meters; - } - - if (!is_trajectory_export_downsampling) - { - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(p.local_trajectory[i].timestamps.first); - point_source_ids.push_back(psid); - } - else - { - if (consecutive_distance >= tol) - { - consecutive_distance = 0; - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(p.local_trajectory[i].timestamps.first); - point_source_ids.push_back(psid); - } - } - } - } - } - // if (!exportLaz(output_file_name, pointcloud, intensity, gnss.offset_x, gnss.offset_y, gnss.offset_alt)) - if (!exportLaz( - output_file_name, - pointcloud, - intensity, - timestamps, - session.point_clouds_container.offset.x(), - session.point_clouds_container.offset.y(), - session.point_clouds_container.offset.z(), - &point_source_ids)) - { - std::cout << "problem with saving file: " << output_file_name << std::endl; - } -} - -void createDXFPolyline(const std::string& filename, const std::vector& points) -{ - std::ofstream dxfFile(filename); - dxfFile << std::setprecision(20); - if (!dxfFile.is_open()) - { - std::cerr << "Failed to open file: " << filename << std::endl; - return; - } - - // DXF header - dxfFile << "0\nSECTION\n2\nHEADER\n0\nENDSEC\n"; - dxfFile << "0\nSECTION\n2\nTABLES\n0\nENDSEC\n"; - - // Start the ENTITIES section - dxfFile << "0\nSECTION\n2\nENTITIES\n"; - - // Start the POLYLINE entity - dxfFile << "0\nPOLYLINE\n"; - dxfFile << "8\n0\n"; // Layer 0 - dxfFile << "66\n1\n"; // Indicates the presence of vertices - dxfFile << "70\n8\n"; // 1 = Open polyline - - // Write the VERTEX entities - for (const auto& point : points) - { - dxfFile << "0\nVERTEX\n"; - dxfFile << "8\n0\n"; // Layer 0 - dxfFile << "10\n" << point.x() << "\n"; // X coordinate - dxfFile << "20\n" << point.y() << "\n"; // Y coordinate - dxfFile << "30\n" << point.z() << "\n"; // Z coordinate - } - - // End the POLYLINE - dxfFile << "0\nSEQEND\n"; - - // End the ENTITIES section - dxfFile << "0\nENDSEC\n"; - - // End the DXF file - dxfFile << "0\nEOF\n"; - - dxfFile.close(); - std::cout << "DXF file created: " << filename << std::endl; -} - -void save_trajectories( - Session& session, - std::string output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling, - bool write_lidar_timestamp, - bool write_unix_timestamp, - bool use_quaternions, - bool save_to_dxf) -{ - std::ofstream outfile; - if (!save_to_dxf) - { - outfile.open(output_file_name); - } - if (save_to_dxf || outfile.good()) - { - float consecutive_distance = 0; - std::vector polylinePoints; - for (auto& p : session.point_clouds_container.point_clouds) - { - if (p.visible) - { - for (int i = 0; i < p.local_trajectory.size(); i++) - { - const auto& m = p.local_trajectory[i].m_pose; - Eigen::Affine3d pose = p.m_pose * m; - pose.translation() += session.point_clouds_container.offset; - - if (i > 0) - { - double dist = (p.local_trajectory[i].m_pose.translation() - p.local_trajectory[i - 1].m_pose.translation()).norm(); - consecutive_distance += dist; - } - - bool is_curve = false; - - if (i > 100 && i < p.local_trajectory.size() - 100) - { - Eigen::Vector3d position_prev = p.local_trajectory[i - 100].m_pose.translation(); - Eigen::Vector3d position_curr = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d position_next = p.local_trajectory[i + 100].m_pose.translation(); - - Eigen::Vector3d v1 = position_curr - position_prev; - Eigen::Vector3d v2 = position_next - position_curr; - - if (v1.norm() > 0 && v2.norm() > 0) - { - double angle_deg = fabs(acos(v1.dot(v2) / (v1.norm() * v2.norm())) * 180.0 / M_PI); - - if (angle_deg > 10.0) - { - is_curve = true; - } - } - } - double tol = not_curve_consecutive_distance_meters; - - if (is_curve) - { - tol = curve_consecutive_distance_meters; - } - - if (!is_trajectory_export_downsampling || (is_trajectory_export_downsampling && consecutive_distance >= tol)) - { - if (is_trajectory_export_downsampling) - { - consecutive_distance = 0; - } - if (save_to_dxf) - { - polylinePoints.push_back(pose.translation()); - } - else - { - outfile << std::setprecision(20); - if (write_lidar_timestamp) - { - outfile << p.local_trajectory[i].timestamps.first << ","; - } - if (write_unix_timestamp) - { - outfile << p.local_trajectory[i].timestamps.second << ","; - } - outfile << pose(0, 3) << "," << pose(1, 3) << "," << pose(2, 3) << ","; - if (use_quaternions) - { - Eigen::Quaterniond q(pose.rotation()); - outfile << q.x() << "," << q.y() << "," << q.z() << "," << q.w() << std::endl; - } - else - { - outfile << pose(0, 0) << "," << pose(0, 1) << "," << pose(0, 2) << "," << pose(1, 0) << "," << pose(1, 1) - << "," << pose(1, 2) << "," << pose(2, 0) << "," << pose(2, 1) << "," << pose(2, 2) << std::endl; - } - } - } - } - } - } - if (!save_to_dxf) - { - outfile.close(); - } - else - { - createDXFPolyline(output_file_name, polylinePoints); - } - } -} - -void save_scale_board_to_laz(const Session& session, std::string output_file_name, float dec, float side_len) -{ - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - - float min_x = 1000000000.0; - float max_x = -1000000000.0; - float min_y = 1000000000.0; - float max_y = -1000000000.0; - float min_z = 1000000000.0; - float max_z = -1000000000.0; - float xy_incr = 0.001; - float z = 0.0; - if (side_len < 0.0) - { - for (auto& p : session.point_clouds_container.point_clouds) - { - if (p.visible) - { - for (int i = 0; i < p.local_trajectory.size(); i++) - { - const auto& pp = p.local_trajectory[i].m_pose.translation(); - Eigen::Vector3d vp; - vp = p.m_pose * pp; - if (vp.x() < min_x) - { - min_x = vp.x(); - } - if (vp.x() > max_x) - { - max_x = vp.x(); - } - if (vp.y() < min_y) - { - min_y = vp.y(); - } - if (vp.y() > max_y) - { - max_y = vp.y(); - } - if (vp.z() < min_z) - { - min_z = vp.z(); - } - if (vp.z() > max_z) - { - max_z = vp.z(); - } - } - } - } - min_x -= 100.0; - min_y -= 100.0; - max_x += 100.0; - max_y += 100.0; - z = (max_z + min_z) / 2.0; - } - else - { - min_x = -side_len / 2.0; - min_y = -side_len / 2.0; - max_x = side_len / 2.0; - max_y = side_len / 2.0; - xy_incr = 0.2; - z = 0.0; - } - - for (float x = min_x; x <= max_x; x += dec) - { - for (float y = min_y; y <= max_y; y += xy_incr) - { - Eigen::Vector3d vp(x, y, z); - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(0.0); - } - } - - for (float y = min_y; y <= max_y; y += dec) - { - for (float x = min_x; x <= max_x; x += xy_incr) - { - Eigen::Vector3d vp(x, y, z); - pointcloud.push_back(vp); - intensity.push_back(0); - timestamps.push_back(0.0); - } - } - - if (!exportLaz( - output_file_name, - pointcloud, - intensity, - timestamps, - session.point_clouds_container.offset.x(), - session.point_clouds_container.offset.y(), - session.point_clouds_container.offset.z())) - { - std::cout << "problem with saving file: " << output_file_name << std::endl; - } -} - -std::vector get_matching_files(const std::string& directory, const std::string& pattern) -{ - std::vector matching_files; - std::regex regex_pattern(pattern); - try - { - for (const auto& entry : fs::directory_iterator(directory)) - { - if (entry.is_regular_file()) - { // Ensure it's a regular file - const std::string filename = entry.path().filename().string(); - if (std::regex_match(filename, regex_pattern)) - { - matching_files.push_back(entry.path().string()); - } - } - } - } catch (const std::exception& e) - { - std::cerr << "Error accessing directory: " << e.what() << std::endl; - } - - return matching_files; -} - -void run_multi_view_tls_registration(std::string input_file_name, TLSRegistration& tls_registration, std::string output_dir) -{ - fs::path outwd = fs::path(output_dir); - Session session; - if (!fs::exists(input_file_name)) - { - std::cout << "Provided input path does not exist." << std::endl; - return; - } - if (has_extension(input_file_name, ".json") || has_extension(input_file_name, ".mjs")) - { - std::cout << "Session file: '" << input_file_name << "'" << std::endl; - session.working_directory = fs::path(input_file_name).parent_path().string(); - session.load( - fs::path(input_file_name).string(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - tls_registration.calculate_offset); - } - else if (has_extension(input_file_name, ".reg") || has_extension(input_file_name, ".mjp")) - { - std::cout << "RESSO file: '" << input_file_name << "'" << std::endl; - session.working_directory = fs::path(input_file_name).parent_path().string(); - session.point_clouds_container.load( - session.working_directory.c_str(), - input_file_name.c_str(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - session.load_cache_mode); - } - else if (has_extension(input_file_name, ".txt")) - { - std::cout << "ETH file: '" << input_file_name << "'" << std::endl; - session.working_directory = fs::path(input_file_name).parent_path().string(); - session.point_clouds_container.load_eth( - session.working_directory.c_str(), - input_file_name.c_str(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z); - } - else if (!has_extension(input_file_name, "")) - { - session.point_clouds_container.point_clouds.clear(); - session.working_directory = fs::path(input_file_name).string(); - std::vector las_files; - std::vector txt_files; - for (const auto& entry : std::filesystem::directory_iterator(input_file_name)) - { - auto file_name = entry.path().string(); - if (has_extension(file_name, ".laz") || (has_extension(file_name, ".las"))) - { - las_files.push_back(file_name); - } - else if (has_extension(file_name, ".txt")) - { - txt_files.push_back(file_name); - } - } - if (las_files.size() > 0) - { - std::cout << "Las/Laz files:" << std::endl; - for (size_t i = 0; i < las_files.size(); i++) - { - std::cout << las_files[i] << std::endl; - } - session.point_clouds_container.load_whu_tls( - las_files, - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - tls_registration.calculate_offset, - session.load_cache_mode); - } - else if (txt_files.size() > 0) - { - std::cout << "txt files:" << std::endl; - for (size_t i = 0; i < txt_files.size(); i++) - { - std::cout << txt_files[i] << std::endl; - } - session.point_clouds_container.load_3DTK_tls( - txt_files, tls_registration.is_decimate, tls_registration.bucket_x, tls_registration.bucket_y, tls_registration.bucket_z); - } - else - { - std::cout << "No WHU-TLS / 3DTK files available in the given directory, check path." << std::endl; - return; - } - } - else - { - std::cout << "Session file: '" << input_file_name << "'" << std::endl; - session.load( - fs::path(input_file_name).string(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - tls_registration.calculate_offset); - } - std::cout << "loaded: " << session.point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; - - int number_of_point = 0; - for (const auto& pc : session.point_clouds_container.point_clouds) - { - number_of_point += pc.points_local.size(); - } - session.point_clouds_container.print_point_cloud_dimension(); - - if (tls_registration.resso_upd_init.size() > 0) - { - std::cout << "RESSO file: '" << tls_registration.resso_upd_init << "'" << std::endl; - session.working_directory = fs::path(tls_registration.resso_upd_init).parent_path().string(); - if (!session.point_clouds_container.update_initial_poses_from_RESSO( - session.working_directory.c_str(), tls_registration.resso_upd_init.c_str())) - { - std::cout << "check input files" << std::endl; - return; - } - else - { - session.point_clouds_container.initial_poses_file_name = tls_registration.resso_upd_init; - std::cout << "updated: " << session.point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; - } - } - if (tls_registration.resso_upd.size() > 0) - { - std::cout << "RESSO file: '" << tls_registration.resso_upd << "'" << std::endl; - session.working_directory = fs::path(tls_registration.resso_upd).parent_path().string(); - if (!session.point_clouds_container.update_poses_from_RESSO(session.working_directory.c_str(), tls_registration.resso_upd.c_str())) - { - std::cout << "check input files" << std::endl; - return; - } - else - { - std::cout << "updated: " << session.point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; - session.point_clouds_container.poses_file_name = tls_registration.resso_upd; - } - } - if (tls_registration.resso_upd_inv.size() > 0) - { - std::cout << "RESSO file: '" << tls_registration.resso_upd_inv << "'" << std::endl; - session.working_directory = fs::path(tls_registration.resso_upd_inv).parent_path().string(); - if (!session.point_clouds_container.update_poses_from_RESSO_inverse( - session.working_directory.c_str(), tls_registration.resso_upd_inv.c_str())) - { - std::cout << "check input files" << std::endl; - return; - } - else - { - std::cout << "updated: " << session.point_clouds_container.point_clouds.size() << " point_clouds" << std::endl; - session.point_clouds_container.poses_file_name = tls_registration.resso_upd_inv; - } - } - - if (tls_registration.initial_pose_to_identity) - { - initial_pose_to_identity(session); - } - - if (tls_registration.use_ndt) - { - if (tls_registration.compute_only_mahalanobis_distance) - { - tls_registration.ndt.optimize( - session.point_clouds_container.point_clouds, true, tls_registration.compute_mean_and_cov_for_bucket); - } - else if (tls_registration.use_lie_algebra_left_jacobian_ndt) - { - tls_registration.ndt.optimize_lie_algebra_left_jacobian( - session.point_clouds_container.point_clouds, tls_registration.compute_mean_and_cov_for_bucket); - } - else if (tls_registration.use_lie_algebra_right_jacobian_ndt) - { - tls_registration.ndt.optimize_lie_algebra_right_jacobian( - session.point_clouds_container.point_clouds, tls_registration.compute_mean_and_cov_for_bucket); - } - else - { - std::cout << "No additional optimization option selected for NDT: using default..." << std::endl; - tls_registration.ndt.optimize( - session.point_clouds_container.point_clouds, false, tls_registration.compute_mean_and_cov_for_bucket); - } - } - - if (tls_registration.use_icp) - { - if (tls_registration.point_to_point_source_to_target) - { - tls_registration.icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - } - else if (tls_registration.use_lie_algebra_left_jacobian_icp) - { - tls_registration.icp.optimize_source_to_target_lie_algebra_left_jacobian(session.point_clouds_container); - } - else if (tls_registration.use_lie_algebra_right_jacobian_icp) - { - tls_registration.icp.optimize_source_to_target_lie_algebra_right_jacobian(session.point_clouds_container); - } - else if (tls_registration.point_to_point_source_to_target_compute_rms) - { - double rms = 0.0; - tls_registration.icp.optimization_point_to_point_source_to_target_compute_rms(session.point_clouds_container, rms); - std::cout << "rms(optimization_point_to_point_source_to_target): " << rms << std::endl; - } - else - { - std::cout << "No optimization option selected for ICP: skipping..." << std::endl; - } - } - - if (tls_registration.use_plane_features) - { - if (tls_registration.point_to_projection_onto_plane_source_to_target) - { - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target( - session.point_clouds_container); - } - else if (tls_registration.use_lie_algebra_left_jacobian_plane_features) - { - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian( - session.point_clouds_container); - } - else if (tls_registration.use_lie_algebra_right_jacobian_plane_features) - { - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian( - session.point_clouds_container); - } - else if (tls_registration.point_to_plane_source_to_target_dot_product) - { - tls_registration.registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - } - else if (tls_registration.point_to_plane_source_to_target) - { - tls_registration.registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - } - else if (tls_registration.plane_to_plane_source_to_target) - { - tls_registration.registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - } - else - { - std::cout << "No optimization option selected for the plane features: skipping..." << std::endl; - } - } - - // TODO: add with GTSAM and with MANIF - if (tls_registration.use_pgslam) - { - tls_registration.pose_graph_slam.ndt_bucket_size[0] = tls_registration.ndt.bucket_size[0]; - tls_registration.pose_graph_slam.ndt_bucket_size[1] = tls_registration.ndt.bucket_size[1]; - tls_registration.pose_graph_slam.ndt_bucket_size[2] = tls_registration.ndt.bucket_size[2]; - tls_registration.pose_graph_slam.optimize(session.point_clouds_container); - } - - if (output_dir.length() > 0) - { - if (session.point_clouds_container.initial_poses_file_name.empty() && tls_registration.save_initial_poses) - { - std::string initial_poses_file_name = (outwd / "session_step2_ini_poses.mri").string(); - std::cout << "saving initial poses to: " << initial_poses_file_name << std::endl; - session.point_clouds_container.save_poses(initial_poses_file_name, false); - } - - if (session.point_clouds_container.poses_file_name.empty() && tls_registration.save_poses) - { - std::string poses_file_name = (outwd / "session_step2_poses.mrp").string(); - std::cout << "saving poses to: " << poses_file_name << std::endl; - session.point_clouds_container.save_poses(poses_file_name, false); - } - - session.save( - (outwd / "session_step2.mjs").string(), - session.point_clouds_container.poses_file_name, - session.point_clouds_container.initial_poses_file_name, - false); - std::cout << "saving result to: " << session.point_clouds_container.poses_file_name << std::endl; - session.point_clouds_container.save_poses(fs::path(session.point_clouds_container.poses_file_name).string(), false); - } - - if (tls_registration.save_laz) - { - save_all_to_las(session, (outwd / "all_step_2.laz").string(), false, true); - } - if (tls_registration.save_las) - { - save_all_to_las(session, (outwd / "all_step_2.las").string(), false, true); - } - if (tls_registration.save_as_separate_las) - { - save_separately_to_las(session, outwd, ".las"); - } - if (tls_registration.save_as_separate_laz) - { - save_separately_to_las(session, outwd, ".laz"); - } - - if (tls_registration.save_trajectories_laz) - { - save_trajectories_to_laz( - session, - (outwd / "trajectories.laz").string(), - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling); - } - - if (tls_registration.save_gnss_laz) - { - tls_registration.gnss.save_to_laz( - (outwd / "gnss.laz").string(), - session.point_clouds_container.offset.x(), - session.point_clouds_container.offset.y(), - session.point_clouds_container.offset.z()); - } - - if (tls_registration.save_scale_board_laz) - { - save_scale_board_to_laz( - session, (outwd / "scale_board.laz").string(), tls_registration.scale_board_dec, tls_registration.scale_board_side_len); - } - - if (tls_registration.save_trajectories_csv) - { - save_trajectories( - session, - (outwd / "trajectories.csv").string(), - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - tls_registration.write_lidar_timestamp, - tls_registration.write_unix_timestamp, - tls_registration.use_quaternions, - false); - } - if (tls_registration.save_trajectories_dxf) - { - save_trajectories( - session, - (outwd / "trajectories.dxf").string(), - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - tls_registration.write_lidar_timestamp, - tls_registration.write_unix_timestamp, - tls_registration.use_quaternions, - true); - } -} \ No newline at end of file diff --git a/apps/multi_view_tls_registration_legacy/multi_view_tls_registration.h b/apps/multi_view_tls_registration_legacy/multi_view_tls_registration.h deleted file mode 100644 index 26e321897..000000000 --- a/apps/multi_view_tls_registration_legacy/multi_view_tls_registration.h +++ /dev/null @@ -1,177 +0,0 @@ - -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace fs = std::filesystem; - -struct TLSRegistration -{ - // NDT - bool use_ndt = false; - NDT ndt; - bool compute_only_mahalanobis_distance = false; - bool compute_mean_and_cov_for_bucket = false; - bool use_lie_algebra_left_jacobian_ndt = false; - bool use_lie_algebra_right_jacobian_ndt = false; - void set_zoller_frohlich_tls_imager_5006i_errors() - { - ndt.sigma_r = 0.0068; - ndt.sigma_polar_angle = 0.007 / 180.0 * M_PI; - ndt.sigma_azimuthal_angle = 0.007 / 180.0 * M_PI; - } - void set_zoller_frohlich_tls_imager_5010c_errors() - { - ndt.sigma_r = 0.01; - ndt.sigma_polar_angle = 0.007 / 180.0 * M_PI; - ndt.sigma_azimuthal_angle = 0.007 / 180.0 * M_PI; - } - void set_zoller_frohlich_tls_imager_5016_errors() - { - ndt.sigma_r = 0.00025; - ndt.sigma_polar_angle = 0.004 / 180.0 * M_PI; - ndt.sigma_azimuthal_angle = 0.004 / 180.0 * M_PI; - } - void set_faro_focus3d_errors() - { - ndt.sigma_r = 0.001; - ndt.sigma_polar_angle = 19.0 * (1.0 / 3600.0) / 180.0 * M_PI; - ndt.sigma_azimuthal_angle = 19.0 * (1.0 / 3600.0) / 180.0 * M_PI; - } - void set_leica_scanstation_c5_c10_errors() - { - ndt.sigma_r = 0.006; - ndt.sigma_polar_angle = 0.00006; - ndt.sigma_azimuthal_angle = 0.00006; - } - void set_riegl_vz400_errors() - { - ndt.sigma_r = 0.005; - ndt.sigma_polar_angle = 0.0005 / 180.0 * M_PI + 0.0003; // Laser Beam Dicvergence - ndt.sigma_azimuthal_angle = 0.0005 / 180.0 * M_PI + 0.0003; // Laser Beam Dicvergence - } - void set_leica_hds6100_errors() - { - ndt.sigma_r = 0.009; - ndt.sigma_polar_angle = 0.000125; - ndt.sigma_azimuthal_angle = 0.000125; - } - void set_leica_p40_errors() - { - ndt.sigma_r = 0.0012; - ndt.sigma_polar_angle = 8.0 / 3600; - ndt.sigma_azimuthal_angle = 8.0 / 3600; - } - - void set_livox_mid360_errors() - { - ndt.sigma_r = 0.02; - ndt.sigma_polar_angle = 0.15 / 180.0 * M_PI; - ndt.sigma_azimuthal_angle = 0.15 / 180.0 * M_PI; - } - - // ICP - bool use_icp = false; - ICP icp; - bool point_to_point_source_to_target = true; - bool use_lie_algebra_left_jacobian_icp = false; - bool use_lie_algebra_right_jacobian_icp = false; - bool point_to_point_source_to_target_compute_rms = false; - - // Plane features - bool use_plane_features = false; - RegistrationPlaneFeature registration_plane_feature; - bool point_to_projection_onto_plane_source_to_target = true; - bool use_lie_algebra_left_jacobian_plane_features = false; - bool use_lie_algebra_right_jacobian_plane_features = false; - bool point_to_plane_source_to_target_dot_product = false; - bool point_to_plane_source_to_target = false; - bool plane_to_plane_source_to_target = false; - - // PGSLAM - bool use_pgslam = false; - PoseGraphSLAM pose_graph_slam; - - // GNSS - GNSS gnss; - - // TUM trajectory - TUM tum; - - // Loading - bool calculate_offset; // Whether to calculate offset to point cloud on loading - bool is_decimate = true; // Whether to decimate point clouds on loading - double bucket_x = 0.1; // Bucket size for decimation in x dimension - double bucket_y = 0.1; // Bucket size for decimation in y dimension - double bucket_z = 0.1; // Bucket size for decimation in z dimension - std::string resso_upd_init = ""; // Path to RESSO initial poses - std::string resso_upd = ""; // Path to RESSO poses - std::string resso_upd_inv = ""; // Path to RESSO inverse poses - - // Registration - bool initial_pose_to_identity = true; // Whether to set first pose as identity and recalculate the rest relatively to it - - // Export - bool save_las = false; // Save resulting point cloud as las - bool save_laz = false; // Save resulting point cloud as laz - bool save_as_separate_las = false; // Whether to save all scans as separate global scans in las format - bool save_as_separate_laz = false; // Whether to save all scans as separate global scans in laz format - bool save_trajectories_laz = false; // Save laz with all trajectories - bool save_gnss_laz = false; // Save laz with GNSS data - bool save_scale_board_laz = false; // Save laz with scale board - float scale_board_dec = 0.1; // Decimation for scale board laz export - float scale_board_side_len = -1.0; // Range covered in x and y dimensions - bool save_initial_poses = false; // Path where initial poses are saved - bool save_poses = false; // Path where poses are saved - bool is_trajectory_export_downsampling = false; // Whether to downsample trajectory on export - float curve_consecutive_distance_meters = 1.0f; // Meters after which trajectory point is saved (if downsampling and curve is detected) - float not_curve_consecutive_distance_meters = - 0.05f; // Meters after which trajectory point is saved (if downsampling and no curve detected) - bool save_trajectories_csv = false; // Save trajectories as csv - bool save_trajectories_dxf = false; // Save trajectories as dxf - bool write_lidar_timestamp = true; // Whether lidar timestamp is wrriten to csv trajectory output - bool write_unix_timestamp = false; // Whether unix timestamp is written to csv trajectory - bool use_quaternions = true; // Whether quaternions are used when writing csv trajectory -}; - -bool has_extension(const std::string file_path, const std::string extension); - -void initial_pose_to_identity(Session& session); - -void save_separately_to_las(const Session& session, fs::path outwd, std::string extension = ".las"); - -void save_trajectories_to_laz( - const Session& session, - std::string output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling); - -void save_scale_board_to_laz(const Session& session, std::string output_file_name, float dec, float side_len = -1.0); - -void createDXFPolyline(const std::string& filename, const std::vector& points); - -// void load_available_geo_points(Session& session, std::string input_file_name); - -void save_trajectories( - Session& session, - std::string output_file_name, - float curve_consecutive_distance_meters, - float not_curve_consecutive_distance_meters, - bool is_trajectory_export_downsampling, - bool write_lidar_timestamp = true, - bool write_unix_timestamp = false, - bool use_quaternions = true, - bool save_to_dxf = false); - -void run_multi_view_tls_registration(std::string input_file_name, TLSRegistration& tls_registration, std::string output_dir = ""); diff --git a/apps/multi_view_tls_registration_legacy/multi_view_tls_registration_gui.cpp b/apps/multi_view_tls_registration_legacy/multi_view_tls_registration_gui.cpp deleted file mode 100644 index 0db4f1df0..000000000 --- a/apps/multi_view_tls_registration_legacy/multi_view_tls_registration_gui.cpp +++ /dev/null @@ -1,4253 +0,0 @@ -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include "../lidar_odometry_step_1/lidar_odometry_utils.h" -#include "multi_view_tls_registration.h" - -#include - -#include "WGS84toCartesian/WGS84toCartesian.hpp" -#include "wgs84_do_puwg92/wgs84_do_puwg92.h" - -#include -#ifdef _WIN32 -#include "resource.h" -#include - -#endif - -/////////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 -bool consWin = true; -#endif -bool consImGui = false; - -std::string winTitle = std::string("Step 2 (Multi view TSL registration) ") + HDMAPPING_CONFIGURE_PROJECT_VERSION; - -std::vector infoLines = { - "This program is second step in MANDEYE process", - "", - "It refines trajectory (e.g with loop closure)", - "It refines trajectory with many approaches (e.g. Iterative Closest Point, Normal Distributions Transform)", - "It exports session as rigid point cloud to single LAZ file", - "LAZ files are the product of MANDEYE process (open them with Cloud Compare)", -}; - -// App specific shortcuts (Type and Shortcut are just for easy reference) -static const std::vector appShortcuts = { { "Normal keys", "A", "" }, - { "", "Ctrl+A", "point cloud Alignment" }, - { "", "B", "" }, - { "", "Ctrl+B", "" }, - { "", "C", "" }, - { "", "Ctrl+C", "Control points" }, - { "", "D", "" }, - { "", "Ctrl+D", "" }, - { "", "E", "" }, - { "", "Ctrl+E", "lio segments Editor" }, - { "", "F", "" }, - { "", "Ctrl+F", "" }, - { "", "G", "" }, - { "", "Ctrl+G", "Ground control points" }, - { "", "H", "" }, - { "", "Ctrl+H", "" }, - { "", "I", "" }, - { "", "Ctrl+I", "" }, - { "", "J", "" }, - { "", "Ctrl+K", "" }, - { "", "K", "" }, - { "", "Ctrl+K", "" }, - { "", "L", "" }, - { "", "Ctrl+L", "manual Loop closure" }, - { "", "M", "" }, - { "", "Ctrl+M", "" }, - { "", "N", "Next active edge (manual loop closure)" }, - { "", "Ctrl+N", "" }, - { "", "O", "" }, - { "", "Ctrl+O", "Open session" }, - { "", "P", "Previous active edge (manual loop closure)" }, - { "", "Ctrl+P", "Pose graph slam" }, - { "", "Q", "" }, - { "", "Ctrl+Q", "" }, - { "", "R", "" }, - { "", "Ctrl+R", "Random cloud colors" }, - { "", "Shift+R", "" }, - { "", "S", "" }, - { "", "Ctrl+S", "Save session" }, - { "", "Ctrl+Shift+S", "Save subsession" }, - { "", "T", "" }, - { "", "Ctrl+T", "Solid cloud color" }, - { "", "U", "" }, - { "", "Ctrl+U", "" }, - { "", "V", "" }, - { "", "Ctrl+V", "" }, - { "", "W", "" }, - { "", "Ctrl+W", "" }, - { "", "X", "" }, - { "", "Ctrl+X", "" }, - { "", "Y", "" }, - { "", "Ctrl+Y", "" }, - { "", "Z", "" }, - { "", "Ctrl+Z", "" }, - { "", "Shift+Z", "" }, - { "", "1-9", "" }, - { "Special keys", "Up arrow", "" }, - { "", "Shift + up arrow", "" }, - { "", "Ctrl + up arrow", "" }, - { "", "Down arrow", "" }, - { "", "Shift + down arrow", "" }, - { "", "Ctrl + down arrow", "" }, - { "", "Left arrow", "" }, - { "", "Shift + left arrow", "" }, - { "", "Ctrl + left arrow", "" }, - { "", "Right arrow", "" }, - { "", "Shift + right arrow", "" }, - { "", "Ctrl + right arrow", "" }, - { "", "Pg down", "" }, - { "", "Pg up", "" }, - { "", "- key", "" }, - { "", "+ key", "" }, - { "Mouse related", "Left click + drag", "" }, - { "", "Right click + drag", "n" }, - { "", "Scroll", "" }, - { "", "Shift + scroll", "" }, - { "", "Shift + drag", "" }, - { "", "Ctrl + left click", "" }, - { "", "Ctrl + right click", "" }, - { "", "Ctrl + middle click", "" } }; - -namespace fs = std::filesystem; - -static bool show_demo_window = true; -static bool show_another_window = false; - -bool gnssWithOffset = false; - -// radio button selectors -static int NDTnomSelection = 0; -static int NDTpeSelection = 0; -static int NDT3dSelection = 0; -static int ICPnomSelection = 0; -static int ICPpeSelection = 0; -static int ICP3dSelection = 0; -static int RPFnomSelection = 0; -static int RPFpeSelection = 0; -static int RPF3dSelection = 0; -static int PGSnomSelection = 0; -static int PGSpeSelection = 0; -static int PGS3dSelection = 0; -static int PGSpwmtSelection = 0; - -std::string session_file_name = ""; -int session_total_number_of_points = 0; -// bool dynamicSubsampling = true; -// static double lastAdjustTime = 0.0; // last time we changed subsampling -// const double cooldownSeconds = 1; // wait between auto adjustments -// static float fps_avg = 60.0f; - -bool is_pca_gui = false; -bool is_ndt_gui = true; -bool is_icp_gui = false; -bool is_rpf_gui = false; -bool is_pose_graph_slam = false; -bool is_manual_analisys = false; -bool is_loop_closure_gui = false; -bool is_lio_segments_gui = false; -bool is_settings_gui = true; -bool is_translate_gui = false; - -struct TranslateTool -{ - enum class Step - { - Idle, - PickOrigin, - PickXAxis, - PickYHint, - Ready - }; - Step step = Step::Idle; - Eigen::Vector3d origin = Eigen::Vector3d::Zero(); - Eigen::Vector3d x_point = Eigen::Vector3d::Zero(); - Eigen::Vector3d y_hint = Eigen::Vector3d::Zero(); - Eigen::Affine3d transform = Eigen::Affine3d::Identity(); - bool has_transform = false; - float plane_z = 0.0f; -}; -TranslateTool translate_tool; - -bool fillInSession = true; - -TLSRegistration tls_registration; -ObservationPicking observation_picking; -std::vector picked_points; - -bool new_loop_closure_index = false; -int num_edge_extended_before = 0; -int num_edge_extended_after = 0; -int index_loop_closure_source = 0; -int index_loop_closure_target = 0; -int index_begin = 0; -int index_end = 0; - -ColorScheme csPointCloud = CS_SOLID; -ColorScheme csTrajectory = CS_SOLID; - -float m_gizmo[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; - -bool manipulate_only_marked_gizmo = false; - -Session session; -PointClouds::PointCloudDimensions session_dims; -bool session_loaded = false; -std::vector geoids; -std::string selected_geoid_model; - -// these functions performs experiment from paper -//@article -//{BEDKOWSKI2023113199, -// title = {Benchmark of multi-view Terrestrial Laser Scanning Point Cloud data registration algorithms}, -// journal = {Measurement}, -// pages = {113199}, -// year = {2023}, -// issn = {0263-2241}, -// doi = {https://doi.org/10.1016/j.measurement.2023.113199}, -// url = {https://www.sciencedirect.com/science/article/pii/S0263224123007637}, -// author = {Janusz Będkowski}, -// keywords = {TLS, Point cloud, Open-source, Multi-view data registration, LiDAR data metrics, Robust loss function, Tait-bryan -// angles, Quaternions, Rodrigues’ formula, Lie algebra, Rotation matrix parameterization}, abstract = {This study addresses multi-view -// Terrestrial Laser Scanning Point Cloud data registration methods. Multiple rigid point cloud data registration is mandatory for -// aligning all scans into a common reference frame and it is still considered a challenge looking from a large-scale surveys point of -// view. The goal of this work is to support the development of cutting-edge registration methods in geoscience and mobile robotics -// domains. This work evaluates 3 data sets of total 20 scenes available in the literature. This paper provides a novel open-source -// framework for multi-view Terrestrial Laser Scanning Point Cloud data registration benchmarks. The goal was to verify experimentally -// which registration variant can improve the open-source data looking from the quantitative and qualitative points of view. In -// particular, the following scanners provided measurement data: Z+F TLS Imager 5006i, Z+F TLS Imager 5010C, Leica ScanStation C5, -// Leica ScanStation C10, Leica P40 and Riegl VZ-400. The benchmark shows an impact of the metric e.g. point to point, point to -// projection onto a plane, plane to plane etc..., rotation matrix parameterization (Tait-Bryan, quaternion, Rodrigues) and other -// implementation variations (e.g. multi-view Normal Distributions Transform, Pose Graph SLAM approach) onto the multi-view data -// registration accuracy and performance. An open-source project is created and it can be used for improving existing data sets -// reported in the literature, it is the added value of the presented research. The combination of metrics, rotation matrix -// parameterization and optimization algorithms creates hundreds of possible approaches. It is shown that chosen metric is a dominant -// factor in data registration. The rotation parameterization and other degrees of freedom of proposed variants are rather negligible -// compared with chosen metric. Most of the proposed approaches improve registered reference data provided by other researchers. Only -// for 2 from 20 scenes it was not possible to provide significant improvement. The largest improvements are evident for large-scale -// scenes. The project is available and maintained at https://github.com/MapsHD/HDMapping.} -// } - -void export_result_to_folder(std::string output_folder_name, ObservationPicking& observation_picking, Session& session); -void perform_experiment_on_windows( - Session& session, - ObservationPicking& observation_picking, - ICP& icp, - NDT& ndt, - RegistrationPlaneFeature& registration_plane_feature, - PoseGraphSLAM& pose_graph_slam); -void perform_experiment_on_linux( - Session& session, - ObservationPicking& observation_picking, - ICP& icp, - NDT& ndt, - RegistrationPlaneFeature& registration_plane_feature, - PoseGraphSLAM& pose_graph_slam); -double compute_rms(bool initial, Session& session, ObservationPicking& observation_picking); -void reset_poses(Session& session); -void translate_gui(); -void draw_translate_preview(); - -/////////////////////////////////////////////////////////////////////////////////// - -void ndt_gui() -{ - ImGui::InputFloat3("Bucket size (x,y,z) [m]", tls_registration.ndt.bucket_size); - if (tls_registration.ndt.bucket_size[0] < 0.01) - tls_registration.ndt.bucket_size[0] = 0.01f; - if (tls_registration.ndt.bucket_size[1] < 0.01) - tls_registration.ndt.bucket_size[1] = 0.01f; - if (tls_registration.ndt.bucket_size[2] < 0.01) - tls_registration.ndt.bucket_size[2] = 0.01f; - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Number of threads", &tls_registration.ndt.number_of_threads); - if (tls_registration.ndt.number_of_threads < 1) - tls_registration.ndt.number_of_threads = 1; - ImGui::SameLine(); - ImGui::InputInt("Number of iterations", &tls_registration.ndt.number_of_iterations); - if (tls_registration.ndt.number_of_iterations < 1) - tls_registration.ndt.number_of_iterations = 1; - ImGui::PopItemWidth(); - - ImGui::Checkbox("Fix first node (add I to first pose in Hessian)", &tls_registration.ndt.is_fix_first_node); - - ImGui::Text("Nonlinear optimization method:"); - ImGui::SameLine(); - ImGui::RadioButton("Gauss-Newton", &NDTnomSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Levenberg-Marguardt", &NDTnomSelection, 1); - - tls_registration.ndt.is_gauss_newton = (NDTnomSelection == 0); - tls_registration.ndt.is_levenberg_marguardt = (NDTnomSelection == 1); - - ImGui::Text("Poses expressed as:"); - ImGui::SameLine(); - ImGui::RadioButton("camera<-world (cw)", &NDTpeSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("camera->world (wc)", &NDTpeSelection, 1); - - tls_registration.ndt.is_cw = (NDTpeSelection == 0); - tls_registration.ndt.is_wc = (NDTpeSelection == 1); - - ImGui::Text("Parameterizations of 3D rotation:"); - ImGui::RadioButton("Tait-Bryan angles (om fi ka: RxRyRz)", &NDT3dSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Quaternion (q0 q1 q2 q3)", &NDT3dSelection, 1); - ImGui::SameLine(); - ImGui::RadioButton("Rodrigues (sx sy sz)", &NDT3dSelection, 2); - - tls_registration.ndt.is_tait_bryan_angles = (NDT3dSelection == 0); - tls_registration.ndt.is_quaternion = (NDT3dSelection == 1); - tls_registration.ndt.is_rodrigues = (NDT3dSelection == 2); - - if (ImGui::Button("Optimization")) - { - double rms_initial = 0.0; - double rms_final = 0.0; - double mui = 0.0; - // ndt.optimize(point_clouds_container.point_clouds, rms_initial, rms_final, mui); - // spdlog::info("mui: " << mui << " rms_initial: " << rms_initial << " rms_final: " << rms_final << std::endl; - tls_registration.ndt.optimize(session.point_clouds_container.point_clouds, false, tls_registration.compute_mean_and_cov_for_bucket); - } - - if (ImGui::Button("Compute mean Mahalanobis distance")) - { - double rms_initial = 0.0; - double rms_final = 0.0; - double mui = 0.0; - - tls_registration.ndt.optimize(session.point_clouds_container.point_clouds, true, tls_registration.compute_mean_and_cov_for_bucket); - } - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text( - "Average of all Mahalanobis distances between transformed source points\nand their corresponding Gaussian cells, where:"); - ImGui::Text( - "Mahalanobis distance measures how far a point is from the mean of a multivariate Gaussian distribution,\ntaking into " - "account the covariance (shape and orientation) of that distribution"); - ImGui::EndTooltip(); - } - - ImGui::Separator(); - - ImGui::Text("NDT optimization Lie algebra:"); - ImGui::SameLine(); - if (ImGui::Button("left Jacobian")) - { - tls_registration.ndt.optimize_lie_algebra_left_jacobian( - session.point_clouds_container.point_clouds, tls_registration.compute_mean_and_cov_for_bucket); - } - ImGui::SameLine(); - if (ImGui::Button("right Jacobian")) - { - tls_registration.ndt.optimize_lie_algebra_right_jacobian( - session.point_clouds_container.point_clouds, tls_registration.compute_mean_and_cov_for_bucket); - } - - ImGui::Separator(); - - ImGui::Checkbox("Generalized", &tls_registration.ndt.is_generalized); - ImGui::BeginDisabled(!tls_registration.ndt.is_generalized); - { - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("sigma_r", &tls_registration.ndt.sigma_r, 0.01, 0.01); - ImGui::InputDouble("sigma_polar_angle_rad", &tls_registration.ndt.sigma_polar_angle, 0.0001, 0.0001); - ImGui::InputDouble("sigma_azimuthal_angle_rad", &tls_registration.ndt.sigma_azimuthal_angle, 0.0001, 0.0001); - ImGui::InputInt("num_extended_points", &tls_registration.ndt.num_extended_points, 1, 1); - ImGui::PopItemWidth(); - - ImGui::Checkbox("compute_mean_and_cov_for_bucket", &tls_registration.compute_mean_and_cov_for_bucket); - } - ImGui::EndDisabled(); - - ImGui::Text("Set error presets:"); - ImGui::Text("Zoller+Fröhlich TLS Imager"); - ImGui::SameLine(); - if (ImGui::Button("5006i")) - tls_registration.set_zoller_frohlich_tls_imager_5006i_errors(); - ImGui::SameLine(); - if (ImGui::Button("5010C")) - tls_registration.set_zoller_frohlich_tls_imager_5010c_errors(); - ImGui::SameLine(); - if (ImGui::Button("5016")) - tls_registration.set_zoller_frohlich_tls_imager_5016_errors(); - - ImGui::Text("Leica"); - ImGui::SameLine(); - if (ImGui::Button("ScanStation C5 C10")) - tls_registration.set_leica_scanstation_c5_c10_errors(); - ImGui::SameLine(); - if (ImGui::Button("Leica HDS6100")) - tls_registration.set_leica_hds6100_errors(); - ImGui::SameLine(); - if (ImGui::Button("Leica P40")) - tls_registration.set_leica_p40_errors(); - - if (ImGui::Button("Faro Focus3D")) - tls_registration.set_faro_focus3d_errors(); - ImGui::SameLine(); - if (ImGui::Button("Riegl VZ400")) - tls_registration.set_riegl_vz400_errors(); - ImGui::SameLine(); - if (ImGui::Button("Livox mid360")) - tls_registration.set_livox_mid360_errors(); -} - -void icp_gui() -{ - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("Search radius", &tls_registration.icp.search_radius, 0.01f, 0.1f); - if (tls_registration.icp.search_radius < 0.01f) - tls_registration.icp.search_radius = 0.01f; - if (tls_registration.icp.search_radius > 2.0f) - tls_registration.icp.search_radius = 2.0f; - - ImGui::InputInt("Number of threads", &tls_registration.icp.number_of_threads); - if (tls_registration.icp.number_of_threads < 1) - tls_registration.icp.number_of_threads = 1; - ImGui::SameLine(); - ImGui::InputInt("Number of iterations", &tls_registration.icp.number_of_iterations); - if (tls_registration.icp.number_of_iterations < 1) - tls_registration.icp.number_of_iterations = 1; - ImGui::PopItemWidth(); - - ImGui::Checkbox("Adaptive robust kernel", &tls_registration.icp.is_adaptive_robust_kernel); - ImGui::SameLine(); - ImGui::Checkbox("Fix first node (add I to first pose in Hessian)", &tls_registration.icp.is_fix_first_node); - - ImGui::Text("Nonlinear optimization method:"); - ImGui::SameLine(); - ImGui::RadioButton("Gauss-Newton", &ICPnomSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Levenberg-Marguardt", &ICPnomSelection, 1); - - tls_registration.icp.is_gauss_newton = (ICPnomSelection == 0); - tls_registration.icp.is_levenberg_marguardt = (ICPnomSelection == 1); - - ImGui::Text("Poses expressed as:"); - ImGui::SameLine(); - ImGui::RadioButton("camera<-world (cw)", &ICPpeSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("camera->world (wc)", &ICPpeSelection, 1); - - tls_registration.icp.is_cw = (ICPpeSelection == 0); - tls_registration.icp.is_wc = (ICPpeSelection == 1); - - ImGui::Text("Parameterizations of 3D rotation:"); - ImGui::RadioButton("Tait-Bryan angles (om fi ka: RxRyRz)", &ICP3dSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Quaternion (q0 q1 q2 q3)", &ICP3dSelection, 1); - ImGui::SameLine(); - ImGui::RadioButton("Rodrigues (sx sy sz)", &ICP3dSelection, 2); - - tls_registration.icp.is_tait_bryan_angles = (ICP3dSelection == 0); - tls_registration.icp.is_quaternion = (ICP3dSelection == 1); - tls_registration.icp.is_rodrigues = (ICP3dSelection == 2); - - if (ImGui::Button("Optimization point to point source to target")) - tls_registration.icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - - ImGui::Separator(); - - ImGui::Text("Optimization source to target Lie-algebra:"); - ImGui::SameLine(); - if (ImGui::Button("left Jacobian")) - tls_registration.icp.optimize_source_to_target_lie_algebra_left_jacobian(session.point_clouds_container); - - ImGui::SameLine(); - if (ImGui::Button("right Jacobian")) - tls_registration.icp.optimize_source_to_target_lie_algebra_right_jacobian(session.point_clouds_container); - - ImGui::Separator(); - - if (ImGui::Button("Compute RMS (optimization_point_to_point_source_to_target)")) - { - double rms = 0.0; - tls_registration.icp.optimization_point_to_point_source_to_target_compute_rms(session.point_clouds_container, rms); - spdlog::info("RMS (optimization_point_to_point_source_to_target): {}", rms); - } -} - -void rpf_gui() -{ - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("Search radius", &tls_registration.registration_plane_feature.search_radius, 0.01, 2.0); - if (tls_registration.registration_plane_feature.search_radius < 0.01) - tls_registration.registration_plane_feature.search_radius = 0.01; - if (tls_registration.registration_plane_feature.search_radius > 2.0) - tls_registration.registration_plane_feature.search_radius = 2.0; - - ImGui::InputInt("Number of threads", &tls_registration.registration_plane_feature.number_of_threads); - if (tls_registration.registration_plane_feature.number_of_threads < 1) - tls_registration.registration_plane_feature.number_of_threads = 1; - ImGui::SameLine(); - ImGui::InputInt("Number of iterations", &tls_registration.registration_plane_feature.number_of_iterations); - if (tls_registration.registration_plane_feature.number_of_iterations < 1) - tls_registration.registration_plane_feature.number_of_iterations = 1; - ImGui::PopItemWidth(); - - ImGui::Checkbox("Adaptive robust kernel", &tls_registration.registration_plane_feature.is_adaptive_robust_kernel); - ImGui::SameLine(); - ImGui::Checkbox("Fix first node (add I to first pose in Hessian)", &tls_registration.registration_plane_feature.is_fix_first_node); - - ImGui::Text("Nonlinear optimization method:"); - ImGui::SameLine(); - ImGui::RadioButton("Gauss-Newton", &RPFnomSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Levenberg-Marguardt", &RPFnomSelection, 1); - - tls_registration.registration_plane_feature.is_gauss_newton = (RPFnomSelection == 0); - tls_registration.registration_plane_feature.is_levenberg_marguardt = (RPFnomSelection == 1); - - ImGui::Text("Poses expressed as:"); - ImGui::SameLine(); - ImGui::RadioButton("camera<-world (cw)", &RPFpeSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("camera->world (wc)", &RPFpeSelection, 1); - - tls_registration.registration_plane_feature.is_cw = (RPFpeSelection == 0); - tls_registration.registration_plane_feature.is_wc = (RPFpeSelection == 1); - - ImGui::Text("Parameterizations of 3D rotation:"); - ImGui::RadioButton("Tait-Bryan angles (om fi ka: RxRyRz)", &RPF3dSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Quaternion (q0 q1 q2 q3)", &RPF3dSelection, 1); - ImGui::SameLine(); - ImGui::RadioButton("Rodrigues (sx sy sz)", &RPF3dSelection, 2); - - tls_registration.registration_plane_feature.is_tait_bryan_angles = (RPF3dSelection == 0); - tls_registration.registration_plane_feature.is_quaternion = (RPF3dSelection == 1); - tls_registration.registration_plane_feature.is_rodrigues = (RPF3dSelection == 2); - - ImGui::Separator(); - ImGui::Text("Optimize point to projection onto plane source to target:"); - if (ImGui::Button("Basic Jacobian")) - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target( - session.point_clouds_container); - ImGui::SameLine(); - if (ImGui::Button("Lie-algebra left Jacobian")) - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian( - session.point_clouds_container); - ImGui::SameLine(); - if (ImGui::Button("Lie-algebra right Jacobian")) - tls_registration.registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian( - session.point_clouds_container); - - ImGui::Separator(); - - ImGui::Text("Optimize source to target:"); - if (ImGui::Button("point to plane (using dot product)")) - tls_registration.registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - ImGui::SameLine(); - if (ImGui::Button("distance point to plane")) - tls_registration.registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - ImGui::SameLine(); - if (ImGui::Button("plane to plane")) - tls_registration.registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); -} - -void pca_gui() -{ - ImGui::Begin("Point cloud alignment", &is_pca_gui, ImGuiWindowFlags_MenuBar); - { - if (ImGui::BeginMenuBar()) - { - bool justPushed = false; - - if (is_ndt_gui) - ImGui::PushStyleColor(ImGuiCol_Button, orangeBorder); - if (ImGui::Button("Normal Distributions Transform")) - { - if (!is_ndt_gui) - { - is_ndt_gui = true; - is_icp_gui = false; - is_rpf_gui = false; - justPushed = true; - } - } - if (is_ndt_gui && !justPushed) - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text( - "Probabilistic alternative to ICP that models one cloud (the target)\nas a set of Gaussian distributions " - "rather than raw points"); - ImGui::Text( - "Robust for rough initial poses but can converge to a local optimum\nif the initial misalignment is very large"); - ImGui::Text( - "Known for being faster and smoother in optimization because\nit replaces discrete point-point correspondences " - "with continuous probability density functions."); - ImGui::EndTooltip(); - } - - ImGui::SameLine(); - - if (is_icp_gui) - ImGui::PushStyleColor(ImGuiCol_Button, orangeBorder); - if (ImGui::Button("Iterative Closest Point")) - { - if (!is_icp_gui) - { - is_ndt_gui = false; - is_icp_gui = true; - is_rpf_gui = false; - justPushed = true; - } - } - if (is_icp_gui && !justPushed) - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text( - "Geometric registration algorithm that aligns two point clouds\nby minimizing the Euclidean distances between " - "corresponding points"); - ImGui::Text( - "Very precise at local refinement, especially point-to-plane ICP,\nbut it struggles if the starting alignment " - "is too far off"); - ImGui::EndTooltip(); - } - - ImGui::SameLine(); - - if (is_rpf_gui) - ImGui::PushStyleColor(ImGuiCol_Button, orangeBorder); - if (ImGui::Button("Registration Plane Feature")) - { - if (!is_rpf_gui) - { - is_ndt_gui = false; - is_icp_gui = false; - is_rpf_gui = true; - justPushed = true; - } - } - if (is_rpf_gui && !justPushed) - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text( - "Feature based registration technique that uses detected\nplanar surfaces in the environment (walls, floors, " - "ceilings, etc.) as constraints for alignment"); - ImGui::Text( - "Can be much more robust to noise and partial overlap,\nrequire far fewer correspondences (just a few planes " - "can define a full 6 DOF pose),\nhandle low texture regions better than ICP"); - ImGui::EndTooltip(); - } - - ImGui::EndMenuBar(); - } - - if (is_ndt_gui) - ndt_gui(); - if (is_icp_gui) - icp_gui(); - if (is_rpf_gui) - rpf_gui(); - } - - ImGui::End(); -} - -void pose_graph_slam_gui() -{ - ImGui::Begin("Pose Graph SLAM", &is_pose_graph_slam); - { - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("Search radius", &tls_registration.pose_graph_slam.search_radius, 0.01f, 2.0f); - if (tls_registration.pose_graph_slam.search_radius < 0.01f) - tls_registration.pose_graph_slam.search_radius = 0.01f; - - ImGui::InputInt("Number of threads", &tls_registration.pose_graph_slam.number_of_threads); - if (tls_registration.pose_graph_slam.number_of_threads < 1) - tls_registration.pose_graph_slam.number_of_threads = 1; - - ImGui::InputInt( - "Number of iterations (pair wise matching)", &tls_registration.pose_graph_slam.number_of_iterations_pair_wise_matching); - if (tls_registration.pose_graph_slam.number_of_iterations_pair_wise_matching < 1) - tls_registration.pose_graph_slam.number_of_iterations_pair_wise_matching = 1; - - ImGui::InputFloat("Overlap threshold", &tls_registration.pose_graph_slam.overlap_threshold, 0.1f, 0.8f); - if (tls_registration.pose_graph_slam.overlap_threshold < 0.1f) - tls_registration.pose_graph_slam.overlap_threshold = 0.1f; - ImGui::PopItemWidth(); - - // ImGui::Checkbox("pgslam adaptive_robust_kernel", &pose_graph_slam.icp.is_adaptive_robust_kernel); - - //-- - ImGui::Checkbox("Adaptive robust kernel", &tls_registration.pose_graph_slam.is_adaptive_robust_kernel); - ImGui::SameLine(); - ImGui::Checkbox("Fix first node (add I to first pose in Hessian)", &tls_registration.pose_graph_slam.is_fix_first_node); - - ImGui::Text("Nonlinear optimization method:"); - ImGui::SameLine(); - ImGui::RadioButton("Gauss-Newton", &PGSnomSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Levenberg-Marguardt", &PGSnomSelection, 1); - - tls_registration.pose_graph_slam.is_gauss_newton = (PGSnomSelection == 0); - tls_registration.pose_graph_slam.is_levenberg_marguardt = (PGSnomSelection == 1); - - ImGui::Text("Poses expressed as:"); - ImGui::SameLine(); - ImGui::RadioButton("camera<-world (cw)", &PGSpeSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("camera->world (wc)", &PGSpeSelection, 1); - - tls_registration.pose_graph_slam.is_cw = (PGSpeSelection == 0); - tls_registration.pose_graph_slam.is_wc = (PGSpeSelection == 1); - - ImGui::Text("Parameterizations of 3D rotation:"); - ImGui::RadioButton("Tait-Bryan angles (om fi ka: RxRyRz)", &PGS3dSelection, 0); - ImGui::SameLine(); - ImGui::RadioButton("Quaternion (q0 q1 q2 q3)", &PGS3dSelection, 1); - ImGui::SameLine(); - ImGui::RadioButton("Rodrigues (sx sy sz)", &PGS3dSelection, 2); - - tls_registration.pose_graph_slam.is_tait_bryan_angles = (PGS3dSelection == 0); - tls_registration.pose_graph_slam.is_quaternion = (PGS3dSelection == 1); - tls_registration.pose_graph_slam.is_rodrigues = (PGS3dSelection == 2); - - ImGui::Separator(); - - ImGui::Text("Method for pair wise matching (general):"); - ImGui::RadioButton("NDT", &PGSpwmtSelection, 0); - ImGui::RadioButton("Optimization_point_to_point_source_to_target", &PGSpwmtSelection, 1); - ImGui::RadioButton("Optimize_point_to_projection_onto_plane_source_to_target", &PGSpwmtSelection, 2); - ImGui::RadioButton("Optimize_point_to_plane_source_to_target", &PGSpwmtSelection, 3); - ImGui::RadioButton("Optimize_distance_point_to_plane_source_to_target", &PGSpwmtSelection, 4); - ImGui::RadioButton("Optimize_plane_to_plane_source_to_target", &PGSpwmtSelection, 5); - - ImGui::Separator(); - - ImGui::Text("Method for pair wise matching (with Lie-algebra):"); - ImGui::RadioButton("Optimize NDT (Lie-algebra left Jacobian)", &PGSpwmtSelection, 6); - ImGui::RadioButton("Optimize NDT (Lie-algebra right Jacobian)", &PGSpwmtSelection, 7); - ImGui::RadioButton("Optimize point to point source to target (Lie-algebra left Jacobian)", &PGSpwmtSelection, 8); - ImGui::RadioButton("Optimize point to point source to target (Lie-algebra right Jacobian)", &PGSpwmtSelection, 9); - ImGui::RadioButton("Optimize point to projection onto plane source to target (Lie-algebra left Jacobian)", &PGSpwmtSelection, 10); - ImGui::RadioButton("Optimize point to projection onto plane source to target (Lie-algebra right Jacobian)", &PGSpwmtSelection, 11); - -#ifdef WITH_PCL - ImGui::Separator(); - ImGui::Text("Method for pair wise matching (with PCL):"); - ImGui::RadioButton("Optimize with PCL (NDT based pair wise matching)", &PGSpwmtSelection, 12); - ImGui::RadioButton("Optimize with PCL (ICP based pair wise matching)", &PGSpwmtSelection, 13); -#endif - - // tls_registration.pose_graph_slam.set_all_to_false(); - tls_registration.pose_graph_slam.is_ndt = (PGSpwmtSelection == 0); - tls_registration.pose_graph_slam.is_optimization_point_to_point_source_to_target = (PGSpwmtSelection == 1); - tls_registration.pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target = (PGSpwmtSelection == 2); - tls_registration.pose_graph_slam.is_optimize_point_to_plane_source_to_target = (PGSpwmtSelection == 3); - tls_registration.pose_graph_slam.is_optimize_distance_point_to_plane_source_to_target = (PGSpwmtSelection == 4); - tls_registration.pose_graph_slam.is_optimize_plane_to_plane_source_to_target = (PGSpwmtSelection == 5); - - tls_registration.pose_graph_slam.is_ndt_lie_algebra_left_jacobian = (PGSpwmtSelection == 6); - tls_registration.pose_graph_slam.is_ndt_lie_algebra_right_jacobian = (PGSpwmtSelection == 7); - tls_registration.pose_graph_slam.is_optimize_point_to_point_source_to_target_lie_algebra_left_jacobian = (PGSpwmtSelection == 8); - tls_registration.pose_graph_slam.is_optimize_point_to_point_source_to_target_lie_algebra_right_jacobian = (PGSpwmtSelection == 9); - tls_registration.pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian = - (PGSpwmtSelection == 10); - tls_registration.pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian = - (PGSpwmtSelection == 11); - - tls_registration.pose_graph_slam.is_optimize_pcl_ndt = (PGSpwmtSelection == 12); - tls_registration.pose_graph_slam.is_optimize_pcl_icp = (PGSpwmtSelection == 13); - - if (PGSpwmtSelection >= 0 && PGSpwmtSelection <= 11) - tls_registration.pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - if (PGSpwmtSelection == 6) - tls_registration.pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_ndt; - if (PGSpwmtSelection == 7) - tls_registration.pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_icp; - - ImGui::Separator(); - if (ImGui::Button("Optimize")) - { - tls_registration.pose_graph_slam.ndt_bucket_size[0] = tls_registration.ndt.bucket_size[0]; - tls_registration.pose_graph_slam.ndt_bucket_size[1] = tls_registration.ndt.bucket_size[1]; - tls_registration.pose_graph_slam.ndt_bucket_size[2] = tls_registration.ndt.bucket_size[2]; - // double rms_initial = 0.0; - // double rms_final = 0.0; - // double mui = 0.0; - tls_registration.pose_graph_slam.optimize(session.point_clouds_container); - // pose_graph_slam.optimize(point_clouds_container, rms_initial, rms_final, mui); - // spdlog::info("mean uncertainty impact: " << mui << " rms_initial: " << rms_initial << " rms_final: " << rms_final << - // std::endl; - } - -#if WITH_GTSAM - if (ImGui::Button("Optimize with GTSAM")) - { - ImGui::Separator(); - ImGui::Text("With GTSAM:"); - tls_registration.pose_graph_slam.ndt_bucket_size[0] = tls_registration.ndt.bucket_size[0]; - tls_registration.pose_graph_slam.ndt_bucket_size[1] = tls_registration.ndt.bucket_size[1]; - tls_registration.pose_graph_slam.ndt_bucket_size[2] = tls_registration.ndt.bucket_size[2]; - double rms_initial = 0.0; - double rms_final = 0.0; - double mui = 0.0; - tls_registration.pose_graph_slam.optimize_with_GTSAM(session.point_clouds_container); - // spdlog::info("mean uncertainty impact: " << mui << " rms_initial: " << rms_initial << " rms_final: " << rms_final << - // std::endl; - } -#endif - -#if WITH_MANIF - ImGui::Separator(); - ImGui::Text("With MANIF:"); - if (ImGui::Button("Optimize with manif (a small header-only library for Lie theory)")) - { - tls_registration.pose_graph_slam.optimize_with_manif(session.point_clouds_container); - spdlog::info("Optimize with manif (a small header-only library for Lie theory) DONE" << std::endl; - } -#endif - } - - ImGui::End(); -} - -void observation_picking_gui() -{ - static std::string observations_file_name = ""; - - ImGui::Begin("Observations", &is_manual_analisys); - { - ImGui::Checkbox("Observation picking mode", &observation_picking.is_observation_picking_mode); - ImGui::BeginDisabled(!observation_picking.is_observation_picking_mode); - { - ImGui::Text("Grid [m]:"); - ImGui::Checkbox("10x10", &observation_picking.grid10x10m); - ImGui::SameLine(); - ImGui::Checkbox("1x1", &observation_picking.grid1x1m); - ImGui::SameLine(); - ImGui::Checkbox("0.1x0.1", &observation_picking.grid01x01m); - ImGui::SameLine(); - ImGui::Checkbox("0.01x0.01", &observation_picking.grid001x001m); - - ImGui::Text("Picking plane:"); - ImGui::PushItemWidth(ImGuiNumberWidth); - // ImGui::SliderFloat("picking_plane_height", &observation_picking.picking_plane_height, -20.0f, 20.0f); - ImGui::InputFloat("Height [m]", &observation_picking.picking_plane_height); - // ImGui::SliderFloat("picking_plane_threshold", &observation_picking.picking_plane_threshold, 0.01f, 200.0f); - ImGui::InputFloat("Threshold [m]", &observation_picking.picking_plane_threshold); - // ImGui::SliderFloat("picking_plane_max_xy", &observation_picking.max_xy, 10.0f, 1000.0f); - ImGui::InputFloat("Grid size [m]", &observation_picking.max_xy); - // ImGui::SliderInt("point_size", &observation_picking.point_size, 1, 10); - ImGui::InputInt("Point size", &observation_picking.point_size); - ImGui::PopItemWidth(); - if (observation_picking.point_size < 1) - observation_picking.point_size = 1; - if (observation_picking.point_size > 20) - observation_picking.point_size = 20; - - if (ImGui::Button("Accept current observation")) - { - std::vector m_poses; - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - m_poses.push_back(session.point_clouds_container.point_clouds[i].m_pose); - observation_picking.accept_current_observation(m_poses); - } - ImGui::SameLine(); - if (ImGui::Button("Clear current observation")) - observation_picking.current_observation.clear(); - - if (ImGui::Button("Reset view")) - { - new_rotation_center = rotation_center; - new_rotate_x = 0.0; - new_rotate_y = 0.0; - new_translate_x = translate_x; - new_translate_y = translate_y; - new_translate_z = translate_z; - camera_transition_active = true; - } - } - ImGui::EndDisabled(); - - ImGui::Text((std::string("Number of observations: ") + std::to_string(observation_picking.observations.size())).c_str()); - - if (ImGui::Button("Load observations")) - { - std::string input_file_name = ""; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load observations", {}); - - if (input_file_name.size() > 0) - { - observations_file_name = input_file_name; - observation_picking.import_observations(input_file_name); - - for (const auto& obs : observation_picking.observations) - { - for (const auto& [key, value] : obs) - { - if (session.point_clouds_container.show_with_initial_pose) - { - auto p = session.point_clouds_container.point_clouds[key].m_initial_pose * value; - observation_picking.add_intersection(p); - } - else - { - auto p = session.point_clouds_container.point_clouds[key].m_pose * value; - observation_picking.add_intersection(p); - } - break; - } - } - } - } - ImGui::SameLine(); - if (ImGui::Button("Save observations")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Save observations", {}, ".json"); - spdlog::info("JSON file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - observation_picking.export_observation(output_file_name); - } - - ImGui::Text((std::string("Loaded observations from file: '") + observations_file_name + std::string("'")).c_str()); - - if (ImGui::Button("Compute RMS (xy)")) - { - double rms = compute_rms(true, session, observation_picking); - spdlog::info("RMS (initial poses): {}", rms); - rms = compute_rms(false, session, observation_picking); - spdlog::info("RMS (current poses): {}", rms); - } - - ImGui::Separator(); - if (ImGui::Button("Add intersection")) - observation_picking.add_intersection(Eigen::Vector3d(0.0, 0.0, 0.0)); - - int index_intersection_to_remove = -1; - for (size_t i = 0; i < observation_picking.intersections.size(); i++) - { - ImGui::Separator(); - ImGui::SetWindowFontScale(1.25f); - ImGui::Text("Intersection %zu", i); - ImGui::SetWindowFontScale(1.0f); - ImGui::SameLine(); - ImGui::ColorEdit3( - std::string("Color##" + std::to_string(i)).c_str(), - observation_picking.intersections[i].color, - ImGuiColorEditFlags_NoInputs); - ImGui::SameLine(); - if (ImGui::Button(std::string("Remove##" + std::to_string(i)).c_str())) - index_intersection_to_remove = i; - - ImGui::InputFloat3( - std::string("Translation [m]##" + std::to_string(i)).c_str(), observation_picking.intersections[i].translation); - ImGui::InputFloat3(std::string("Rotation [deg]##" + std::to_string(i)).c_str(), observation_picking.intersections[i].rotation); - ImGui::InputFloat3( - std::string("Width length height [m]##" + std::to_string(i)).c_str(), - observation_picking.intersections[i].width_length_height); - } - - if (index_intersection_to_remove != -1) - { - std::vector intersections; - for (size_t i = 0; i < observation_picking.intersections.size(); i++) - { - if (i != index_intersection_to_remove) - intersections.push_back(observation_picking.intersections[i]); - } - observation_picking.intersections = intersections; - } - - ImGui::Separator(); - - ImGui::BeginDisabled(observation_picking.intersections.size() <= 0); - { - if (ImGui::Button("Export point clouds inside intersections, RMS and poses")) - { - std::string output_folder_name = ""; - output_folder_name = mandeye::fd::SelectFolder("Choose folder"); - spdlog::info("folder: '{}'", output_folder_name); - - if (output_folder_name.size() > 0) - export_result_to_folder(output_folder_name, observation_picking, session); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("in RESSO format to folder"); - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("Label distance [m]", &observation_picking.label_dist); - } - ImGui::EndDisabled(); - } - - ImGui::End(); -} - -void loop_closure_gui() -{ - ImGui::Begin("Manual Pose Graph Loop Closure", &is_loop_closure_gui); - { - const auto point_cloud_upper = session.point_clouds_container.point_clouds.size() - 1; - - ImGui::Checkbox("Render source as red target as blue", &session.pose_graph_loop_closure.render_source_as_red_target_as_blue); - - ImGui::Text("Num edge extended:"); - - ImGui::Text("before: "); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::SliderInt("##fs", &num_edge_extended_before, 0, point_cloud_upper); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - ImGui::SameLine(); - ImGui::InputInt("##fi", &num_edge_extended_before, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - if (num_edge_extended_before < 0) - num_edge_extended_before = 0; - if (num_edge_extended_before >= point_cloud_upper) - num_edge_extended_before = point_cloud_upper; - - ImGui::Text(" after: "); - ImGui::SameLine(); - - ImGui::SliderInt("##ts", &num_edge_extended_after, index_loop_closure_target, static_cast(point_cloud_upper)); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - ImGui::SameLine(); - ImGui::InputInt("##ti", &num_edge_extended_after, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("min 0; max %zu", point_cloud_upper); - if (num_edge_extended_after < 0) - num_edge_extended_after = 0; - if (num_edge_extended_after >= point_cloud_upper) - num_edge_extended_after = point_cloud_upper; - ImGui::PopItemWidth(); - - int prev_index_active_edge = session.pose_graph_loop_closure.index_active_edge; - session.pose_graph_loop_closure.Gui( - session.point_clouds_container, - index_loop_closure_source, - index_loop_closure_target, - m_gizmo, - tls_registration.gnss, - tls_registration.tum, - session.ground_control_points, - session.control_points, - num_edge_extended_before, - num_edge_extended_after); - - new_loop_closure_index = (prev_index_active_edge != session.pose_graph_loop_closure.index_active_edge); - } - - ImGui::End(); -} - -void lio_segments_gui() -{ - ImGui::Begin("LIO segments editor", &is_lio_segments_gui); - { - ImGui::Text("index from: "); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::SliderInt("##fs", &index_begin, 0, index_end); - ImGui::SameLine(); - ImGui::InputInt("##fi", &index_begin, 1, 5); - if (index_begin < 0) - index_begin = 0; - if (index_begin >= index_end) - index_begin = index_end; - - ImGui::SameLine(); - ImGui::Text(" to: "); - ImGui::SameLine(); - - ImGui::SliderInt("##ts", &index_end, index_begin, static_cast(session.point_clouds_container.point_clouds.size() - 1)); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("max %zu", session.point_clouds_container.point_clouds.size() - 1); - ImGui::SameLine(); - ImGui::InputInt("##ti", &index_end, 1, 5); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("max %zu", session.point_clouds_container.point_clouds.size() - 1); - if (index_end < index_begin) - index_end = index_begin; - if (index_end >= session.point_clouds_container.point_clouds.size() - 1) - index_end = session.point_clouds_container.point_clouds.size() - 1; - ImGui::PopItemWidth(); - - ImGui::Text("Selection: "); - ImGui::SameLine(); - if (ImGui::Button("show ")) - session.point_clouds_container.show_all_from_range(index_begin, index_end); - ImGui::SameLine(); - if (ImGui::Button("shift -")) - { - int step = index_end - index_begin; - index_begin -= step; - index_end -= step; - - if (index_begin < 0) - index_begin = 0; - if (index_end < 0) - index_end = 0; - - rotation_center.x() = session.point_clouds_container.point_clouds[index_begin].m_pose(0, 3); - rotation_center.y() = session.point_clouds_container.point_clouds[index_begin].m_pose(1, 3); - rotation_center.z() = session.point_clouds_container.point_clouds[index_begin].m_pose(2, 3); - session.point_clouds_container.show_all_from_range(index_begin, index_end); - } - ImGui::SameLine(); - if (ImGui::Button("shift +")) - { - int step = index_end - index_begin; - index_begin += step; - index_end += step; - - if (index_begin > session.point_clouds_container.point_clouds.size() - 1) - index_begin = session.point_clouds_container.point_clouds.size() - 1; - if (index_end > session.point_clouds_container.point_clouds.size() - 1) - index_end = session.point_clouds_container.point_clouds.size() - 1; - - rotation_center.x() = session.point_clouds_container.point_clouds[index_begin].m_pose(0, 3); - rotation_center.y() = session.point_clouds_container.point_clouds[index_begin].m_pose(1, 3); - rotation_center.z() = session.point_clouds_container.point_clouds[index_begin].m_pose(2, 3); - session.point_clouds_container.show_all_from_range(index_begin, index_end); - } - ImGui::SameLine(); - if (ImGui::Button("Show all")) - session.point_clouds_container.show_all(); - ImGui::SameLine(); - if (ImGui::Button("Hide all")) - session.point_clouds_container.hide_all(); - ImGui::SameLine(); - if (ImGui::Button("Reset poses")) - reset_poses(session); - - ImGui::Checkbox("Show with initial pose", &session.point_clouds_container.show_with_initial_pose); - ImGui::SameLine(); - ImGui::Checkbox("Manipulate only marked gizmo", &manipulate_only_marked_gizmo); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("false: move also succesive nodes"); - - ImGui::SameLine(); - - if (ImGui::Button("Set fuse IMU inclination for picked trajectory node")) - { - if (index_loop_closure_target >= 0 && index_loop_closure_target < session.point_clouds_container.point_clouds.size()) - { - session.point_clouds_container.point_clouds[index_loop_closure_target].fuse_inclination_from_IMU = true; - } - - // picked_index - /*int tmp = -1; - getClosestTrajectoryPoint(session, x, y, false, tmp); - - if (io.KeyCtrl) - { - if (tmp != -1) - index_loop_closure_target = tmp; - } - else if (io.KeyShift) - { - if (tmp != -1) - index_loop_closure_source = tmp; - } - - januszjanusz*/ - } - - ImGui::Text("Fuse IMU inclination: "); - ImGui::SameLine(); - - static double angle_diff = 5.0; - - if (ImGui::Button("Set those that satisfy acceptable angle")) - { - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - double om = session.point_clouds_container.point_clouds[i].local_trajectory[0].imu_om_fi_ka.x() * RAD_TO_DEG; - double fi = session.point_clouds_container.point_clouds[i].local_trajectory[0].imu_om_fi_ka.y() * RAD_TO_DEG; - - spdlog::info("om: {}, fi {}", om, fi); - if (fabs(om) > angle_diff || fabs(fi) > angle_diff) - { - } - else - session.point_clouds_container.point_clouds[i].fuse_inclination_from_IMU = true; - } - } - ImGui::SameLine(); - if (ImGui::Button("unset all")) - { - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - session.point_clouds_container.point_clouds[i].fuse_inclination_from_IMU = false; - } - - ImGui::SameLine(); - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("acceptable angle [deg]", &angle_diff); - - ImGui::Separator(); - // ImGui::Text("motion model"); - - // session.pose_graph_loop_closure.edges. - - // ImGui::InputDouble("motion_model_w_px_1_sigma_m", &session.pose_graph_loop_closure.motion_model_w_px_1_sigma_m); - // ImGui::InputDouble("motion_model_w_py_1_sigma_m", &session.pose_graph_loop_closure.motion_model_w_py_1_sigma_m); - // ImGui::InputDouble("motion_model_w_pz_1_sigma_m", &session.pose_graph_loop_closure.motion_model_w_pz_1_sigma_m); - // ImGui::InputDouble("motion_model_w_om_1_sigma_deg", &session.pose_graph_loop_closure.motion_model_w_om_1_sigma_deg); - // ImGui::InputDouble("motion_model_w_fi_1_sigma_deg", &session.pose_graph_loop_closure.motion_model_w_fi_1_sigma_deg); - // ImGui::InputDouble("motion_model_w_ka_1_sigma_deg", &session.pose_graph_loop_closure.motion_model_w_ka_1_sigma_deg); - - // ImGui::Separator(); - - ImGui::BeginChild("LIO segments", ImVec2(0, 0), true); - { - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (i > 0) - ImGui::Separator(); - ImGui::SetWindowFontScale(1.25f); - ImGui::Checkbox( - std::filesystem::path(session.point_clouds_container.point_clouds[i].file_name).filename().string().c_str(), - &session.point_clouds_container.point_clouds[i].visible); - ImGui::SetWindowFontScale(1.0f); - ImGui::SameLine(); - ImGui::Checkbox(("gizmo##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].gizmo); - -#if 0 - ImGui::SameLine(); - ImGui::Checkbox(("fixed##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed); - ImGui::SameLine(); - ImGui::PushButtonRepeat(true); - float spacing = ImGui::GetStyle().ItemInnerSpacing.x; - if (ImGui::ArrowButton(("left##" + std::to_string(i)).c_str(), ImGuiDir_Left)) - { - (session.point_clouds_container.point_clouds[i].point_size)--; - } - ImGui::SameLine(0.0f, spacing); - if (ImGui::ArrowButton(("right##" + std::to_string(i)).c_str(), ImGuiDir_Right)) - { - (session.point_clouds_container.point_clouds[i].point_size)++; - } - ImGui::PopButtonRepeat(); - ImGui::SameLine(); - ImGui::Text("point size %d", session.point_clouds_container.point_clouds[i].point_size); - if (session.point_clouds_container.point_clouds[i].point_size < 1) - { - session.point_clouds_container.point_clouds[i].point_size = 1; - } - - ImGui::SameLine(); - if (ImGui::Button(std::string("#" + std::to_string(i) + " save scan(global reference frame)").c_str())) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Choose folder", {}); - spdlog::info("Scan file to save: '" << output_file_name << "'" << std::endl; - if (output_file_name.size() > 0) - { - session.point_clouds_container.point_clouds[i].save_as_global(output_file_name); - } - } - ImGui::SameLine(); - if (ImGui::Button(std::string("#" + std::to_string(i) + " shift points to center").c_str())) - { - session.point_clouds_container.point_clouds[i].shift_to_center(); - } -#endif - if (session.point_clouds_container.point_clouds[i].gizmo) - { - for (size_t j = 0; j < session.point_clouds_container.point_clouds.size(); j++) - { - if (i != j) - { - session.point_clouds_container.point_clouds[j].gizmo = false; - } - } - m_gizmo[0] = (float)session.point_clouds_container.point_clouds[i].m_pose(0, 0); - m_gizmo[1] = (float)session.point_clouds_container.point_clouds[i].m_pose(1, 0); - m_gizmo[2] = (float)session.point_clouds_container.point_clouds[i].m_pose(2, 0); - m_gizmo[3] = (float)session.point_clouds_container.point_clouds[i].m_pose(3, 0); - m_gizmo[4] = (float)session.point_clouds_container.point_clouds[i].m_pose(0, 1); - m_gizmo[5] = (float)session.point_clouds_container.point_clouds[i].m_pose(1, 1); - m_gizmo[6] = (float)session.point_clouds_container.point_clouds[i].m_pose(2, 1); - m_gizmo[7] = (float)session.point_clouds_container.point_clouds[i].m_pose(3, 1); - m_gizmo[8] = (float)session.point_clouds_container.point_clouds[i].m_pose(0, 2); - m_gizmo[9] = (float)session.point_clouds_container.point_clouds[i].m_pose(1, 2); - m_gizmo[10] = (float)session.point_clouds_container.point_clouds[i].m_pose(2, 2); - m_gizmo[11] = (float)session.point_clouds_container.point_clouds[i].m_pose(3, 2); - m_gizmo[12] = (float)session.point_clouds_container.point_clouds[i].m_pose(0, 3); - m_gizmo[13] = (float)session.point_clouds_container.point_clouds[i].m_pose(1, 3); - m_gizmo[14] = (float)session.point_clouds_container.point_clouds[i].m_pose(2, 3); - m_gizmo[15] = (float)session.point_clouds_container.point_clouds[i].m_pose(3, 3); - } - - if (session.point_clouds_container.point_clouds[i].visible) - { - ImGui::SameLine(); - ImGui::ColorEdit3( - ("color##" + std::to_string(i)).c_str(), - session.point_clouds_container.point_clouds[i].render_color, - ImGuiColorEditFlags_NoInputs); - -#if 0 - ImGui::SameLine(); - if (ImGui::Button(std::string(("ICP##" + std::to_string(i)).c_str()) - { - size_t index_target = i; - PointClouds pcs; - for (size_t k = 0; k < index_target; k++) - { - if (session.point_clouds_container.point_clouds[k].visible) - { - pcs.point_clouds.push_back(session.point_clouds_container.point_clouds[k]); - } - } - - if (pcs.point_clouds.size() > 0) - { - for (size_t k = 0; k < pcs.point_clouds.size(); k++) - { - pcs.point_clouds[k].fixed = true; - } - } - pcs.point_clouds.push_back(session.point_clouds_container.point_clouds[index_target]); - pcs.point_clouds[pcs.point_clouds.size() - 1].fixed = false; - - ICP icp; - icp.search_radious = 0.3; // ToDo move to params - for (auto& pc : pcs.point_clouds) - { - pc.rgd_params.resolution_X = icp.search_radious; - pc.rgd_params.resolution_Y = icp.search_radious; - pc.rgd_params.resolution_Z = icp.search_radious; - - pc.build_rgd(); - pc.cout_rgd(); - pc.compute_normal_vectors(0.5); - } - - icp.number_of_threads = std::thread::hardware_concurrency(); - - icp.number_of_iterations = 10; - icp.is_adaptive_robust_kernel = false; - - icp.is_ballanced_horizontal_vs_vertical = false; - icp.is_fix_first_node = false; - icp.is_gauss_newton = true; - icp.is_levenberg_marguardt = false; - icp.is_cw = false; - icp.is_wc = true; - icp.is_tait_bryan_angles = true; - icp.is_quaternion = false; - icp.is_rodrigues = false; - spdlog::info("optimization_point_to_point_source_to_target" << std::endl; - - icp.optimization_point_to_point_source_to_target(pcs); - - spdlog::info("pose before: " << session.point_clouds_container.point_clouds[index_target].m_pose.matrix() << std::endl; - - std::vector all_m_poses; - for (size_t j = 0; j < session.point_clouds_container.point_clouds.size(); j++) - { - all_m_poses.push_back(session.point_clouds_container.point_clouds[j].m_pose); - } - - session.point_clouds_container.point_clouds[index_target].m_pose = pcs.point_clouds[pcs.point_clouds.size() - 1].m_pose; - - spdlog::info("pose after ICP: " << session.point_clouds_container.point_clouds[index_target].m_pose.matrix() << std::endl; - - // like gizmo - if (!manipulate_only_marked_gizmo) - { - spdlog::info("Update all poses after current pose" << std::endl; - - Eigen::Affine3d curr_m_pose = session.point_clouds_container.point_clouds[index_target].m_pose; - for (size_t j = index_target + 1; j < session.point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose = curr_m_pose * (all_m_poses[j - 1].inverse() * all_m_poses[j]); - session.point_clouds_container.point_clouds[j].m_pose = curr_m_pose; - } - } - } -#endif - - ImGui::SameLine(); - ImGui::Checkbox( - ("fuse IMU inclination##" + std::to_string(i)).c_str(), - &session.point_clouds_container.point_clouds[i].fuse_inclination_from_IMU); - - ImGui::SameLine(); - ImGui::Checkbox(("show IMU##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].show_IMU); - - ImGui::SameLine(); - ImGui::Checkbox(("show pose##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].show_pose); - - /*ImGui::SameLine(); - if (ImGui::Button(("set IMU inclination##" + std::to_string(i)).c_str())) - { - //session.point_clouds_container.point_clouds[i].m_initial_pose - //session.point_clouds_container.point_clouds[i].m_pose - //session.point_clouds_container.point_clouds[i].m_pose_temp - - TaitBryanPose target_pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[i].m_pose); - - target_pose.om = session.point_clouds_container.point_clouds[i].local_trajectory[0].imu_om_fi_ka.x(); - target_pose.fi = session.point_clouds_container.point_clouds[i].local_trajectory[0].imu_om_fi_ka.y(); - - Eigen::Affine3d m_pose = affine_matrix_from_pose_tait_bryan(target_pose); - - session.point_clouds_container.point_clouds[i].m_initial_pose = m_pose; - session.point_clouds_container.point_clouds[i].m_pose = m_pose; - session.point_clouds_container.point_clouds[i].m_pose_temp = m_pose; - - //session.point_clouds_container.point_clouds[i].m_pose = m_pose; - //session.point_clouds_container.point_clouds[i].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[i].m_pose); - //session.point_clouds_container.point_clouds[i].gui_translation[0] = - session.point_clouds_container.point_clouds[i].pose.px; - //session.point_clouds_container.point_clouds[i].gui_translation[1] = - session.point_clouds_container.point_clouds[i].pose.py; - //session.point_clouds_container.point_clouds[i].gui_translation[2] = - session.point_clouds_container.point_clouds[i].pose.pz; - //session.point_clouds_container.point_clouds[i].gui_rotation[0] = - rad2deg(session.point_clouds_container.point_clouds[i].pose.om); - //session.point_clouds_container.point_clouds[i].gui_rotation[1] = - rad2deg(session.point_clouds_container.point_clouds[i].pose.fi); - //session.point_clouds_container.point_clouds[i].gui_rotation[2] = - rad2deg(session.point_clouds_container.point_clouds[i].pose.ka); - }*/ - - ImGui::Text("fixed: "); - - ImGui::SameLine(); - ImGui::Checkbox(("X##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_x); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - - ImGui::SameLine(); - ImGui::Checkbox(("Y##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_y); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - - ImGui::SameLine(); - ImGui::Checkbox(("Z##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_z); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - - ImGui::SameLine(); - ImGui::Checkbox(("om##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_om); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(omText); - - ImGui::SameLine(); - ImGui::Checkbox(("fi##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_fi); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(fiText); - - ImGui::SameLine(); - ImGui::Checkbox(("ka##" + std::to_string(i)).c_str(), &session.point_clouds_container.point_clouds[i].fixed_ka); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(kaText); - } -#if 0 - ImGui::SameLine(); - if (ImGui::Button(std::string("#" + std::to_string(i) + " print frame to console").c_str())) - { - spdlog::info(session.point_clouds_container.point_clouds[i].m_pose.matrix() << std::endl; - } -#endif - } - } - ImGui::EndChild(); - } - - ImGui::End(); -} - -void loadSession(const std::string& session_file_name) -{ - spdlog::info("Session file: '{}'", session_file_name); - - if (session.load( - fs::path(session_file_name).string(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - tls_registration.calculate_offset)) - { - session_loaded = true; - index_begin = 0; - index_end = session.point_clouds_container.point_clouds.size() - 1; - - std::string newTitle = winTitle + " - " + truncPath(session_file_name); - glutSetWindowTitle(newTitle.c_str()); - - for (const auto& pc : session.point_clouds_container.point_clouds) - session_total_number_of_points += pc.points_local.size(); - - session_dims = session.point_clouds_container.compute_point_cloud_dimension(); - } -} - -void openSession() -{ - session_file_name = mandeye::fd::OpenFileDialogOneFile("Open session", mandeye::fd::Session_filter); - - if (session_file_name.size() > 0) - { - loadSession(session_file_name); - } -} - -std::string saveSession() -{ - const std::string output_file_name = - mandeye::fd::SaveFileDialog("Save session as", mandeye::fd::Session_filter, ".mjs", session_file_name); - - if (output_file_name.size() > 0) - { - spdlog::info("Session file to save: '{}'", output_file_name); - - // creating filenames proposal based on current selection - std::filesystem::path path(output_file_name); - // Extract parts - const auto dir = path.parent_path(); - const auto stem = path.stem().string(); - - // Build new names - std::string initial_poses_file_name = (dir / (stem + "_ini_poses.mri")).string(); - std::string poses_file_name = (dir / (stem + "_poses.mrp")).string(); - - if (session.point_clouds_container.initial_poses_file_name.empty()) - { - spdlog::info("Please assign initial_poses_file_name to session"); - spdlog::warn("Session is not saved!"); - - [[maybe_unused]] pfd::message message( - "Please assign initial_poses_file_name to session", - "Session is not saved. Please assign initial_poses_file_name to session. " - "Follow guidlines available here : " - "https://github.com/MapsHD/HDMapping/tree/main/doc/, " - "You can do this using button 'update initial poses from RESSO file'", - pfd::choice::ok, - pfd::icon::error); - message.result(); - - initial_poses_file_name = - mandeye::fd::SaveFileDialog("Initial poses file name", mandeye::fd::IniPoses_filter, initial_poses_file_name); - spdlog::info("Resso file to save: '{}'", initial_poses_file_name); - - if (initial_poses_file_name.size() > 0) - { - spdlog::info("Saving initial poses to: '{}'", initial_poses_file_name); - session.point_clouds_container.save_poses(initial_poses_file_name, false); - } - } - - if (session.point_clouds_container.poses_file_name.empty()) - { - spdlog::info("Please assign poses_file_name to session"); - spdlog::warn("Session is not saved!"); - - [[maybe_unused]] pfd::message message( - "Please assign poses_file_name to session", - "Session is not saved. Please assign poses_file_name to session. " - "Follow guidlines available here : " - "https://github.com/MapsHD/HDMapping/tree/main/doc/," - "You can do this using button 'update poses from RESSO file'", - pfd::choice::ok, - pfd::icon::error); - message.result(); - - poses_file_name = mandeye::fd::SaveFileDialog("Poses file name", mandeye::fd::Poses_filter, poses_file_name); - spdlog::info("Resso file to save: '{}'", poses_file_name); - if (poses_file_name.size() > 0) - { - spdlog::info("Saving poses to: '{}'", poses_file_name); - session.point_clouds_container.save_poses(poses_file_name, false); - } - } - - session.save(output_file_name, poses_file_name, initial_poses_file_name, false); - spdlog::info("Saving result to: '{}'", poses_file_name); - session.point_clouds_container.save_poses(poses_file_name, false); - - try - { - fs::copy_file(poses_file_name, initial_poses_file_name, fs::copy_options::overwrite_existing); - } catch (const fs::filesystem_error& e) - { - spdlog::error("Error copying poses file: {}", e.what()); - } - - return output_file_name; - } - else - { - spdlog::info("Saving canceled"); - - return ""; - } -} - -void openLaz(bool fillInSession) -{ - session.point_clouds_container.point_clouds.clear(); - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load las/laz files", mandeye::fd::LAS_LAZ_filter, true); - if (input_file_names.size() > 0) - { - session.working_directory = fs::path(input_file_names[0]).parent_path().string(); - - spdlog::info("Creating session from las/laz files:"); - for (size_t i = 0; i < input_file_names.size(); i++) - spdlog::info("{}", input_file_names[i]); - - if (!session.point_clouds_container.load_whu_tls( - input_file_names, - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - tls_registration.calculate_offset, - session.load_cache_mode)) - spdlog::error("Error loading session! Check input files laz/las"); - else - spdlog::info("Loaded: {} point_clouds", session.point_clouds_container.point_clouds.size()); - - session_loaded = true; - index_begin = 0; - index_end = session.point_clouds_container.point_clouds.size() - 1; - - std::string newTitle = winTitle + " - " + fs::path(input_file_names[0]).parent_path().string(); - glutSetWindowTitle(newTitle.c_str()); - - for (const auto& pc : session.point_clouds_container.point_clouds) - session_total_number_of_points += pc.points_local.size(); - - session_dims = session.point_clouds_container.compute_point_cloud_dimension(); - - if (fillInSession) - { - int counter = 1; - Eigen::Vector3d mean(session.point_clouds_container.point_clouds[0].points_local[0]); - for (auto& pc : session.point_clouds_container.point_clouds) - { - if (pc.points_local.size() > 100) - { - // spdlog::info("mean " << mean << std::endl; - for (size_t i = 100; i < pc.points_local.size(); i += 100) - { - mean += pc.points_local[i]; - counter++; - } - } - } - mean /= counter; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - Eigen::Affine3d m = Eigen::Affine3d::Identity(); - if (pc.points_local.size() > 100) - { - // int counter = 1; - - // spdlog::info("mean " << mean << std::endl; - // for (size_t i = 100; i < pc.points_local.size(); i += 100) - //{ - // mean += pc.points_local[i]; - // counter++; - //} - - // mean /= counter; - m.translation() = mean; - - PointCloud::LocalTrajectoryNode node; - node.imu_diff_angle_om_fi_ka_deg = { 0, 0, 0 }; - node.imu_om_fi_ka = { 0, 0, 0 }; - node.m_pose = Eigen::Affine3d::Identity(); - node.timestamps = { 0, 0 }; - - pc.local_trajectory.push_back(node); - - for (auto& p : pc.points_local) - { - p -= mean; - } - } - - pc.m_initial_pose = m; - pc.m_pose = m; - pc.m_pose_temp = m; - - pc.pose = pose_tait_bryan_from_affine_matrix(m); - } - - std::string session_fn = get_next_result_path(session.working_directory).string(); - std::filesystem::create_directory(session_fn); - - session_file_name = (fs::path(session_fn) / "newSession.mjs").string(); - session.point_clouds_container.initial_poses_file_name = - "dummy"; // non empty file names signal poses present, new file names will be created on save - session.point_clouds_container.poses_file_name = - "dummy"; // non empty file names signal poses present, new file names will be created on save - - std::string output_file_name = saveSession(); - - if (output_file_name.size() > 0) - { - // creating filenames proposal based on current selection - std::filesystem::path path(output_file_name); - // Extract parts - const auto dir = path.parent_path(); - const auto stem = path.stem().string(); - - // save to folder - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - auto pc = session.point_clouds_container.point_clouds[i]; - auto fpath = dir / fs::path(pc.file_name).filename(); - - session.point_clouds_container.point_clouds[i].file_name = fpath.string(); - exportLaz(fpath.string(), pc.points_local, pc.intensities, pc.timestamps); - - // saving terajectory file - auto pathtrj = dir / ("trajectory_lio_" + std::to_string(i) + ".csv"); - spdlog::info("Saving trajectory: '{}'", pathtrj); - - std::ofstream outfile; - outfile.open(pathtrj); - if (!outfile.good()) - { - spdlog::error("Error saving file: '{}'", pathtrj); - return; - } - - outfile << "timestamp_nanoseconds pose00 pose01 pose02 pose03 pose10 pose11 pose12 pose13 pose20 pose21 pose22 pose23 " - "timestampUnix_nanoseconds om_rad fi_rad ka_rad" - << std::endl; - for (int j = 0; j < 1; j++) - { - auto pose = Eigen::Affine3d::Identity(); - - outfile << std::setprecision(20) << 0.0 << " " << std::setprecision(10) << pose(0, 0) << " " << pose(0, 1) << " " - << pose(0, 2) << " " << pose(0, 3) << " " << pose(1, 0) << " " << pose(1, 1) << " " << pose(1, 2) << " " - << pose(1, 3) << " " << pose(2, 0) << " " << pose(2, 1) << " " << pose(2, 2) << " " << pose(2, 3) << " " - << std::setprecision(20) << 0.0 << " " << 0.0 << " " << 0.0 << " " << 0.0 << " " << std::endl; - } - outfile.close(); - } - } - - [[maybe_unused]] pfd::message message( - "Information", - "If you can not see point cloud --> 1. Change 'Points render subsampling', 2. Check console 'min max coordinates " - "should be " - "small numbers to see points in our local coordinate system'. 3. Set checkbox 'calculate_offset for WHU-TLS'. 4. Later " - "on " - "You can change offset directly in session json file.", - pfd::choice::ok, - pfd::icon::info); - message.result(); - - // std::string mes = "Session saved to folder '" + path_ground_truth_session_folder.string() + "'"; - //[[maybe_unused]] pfd::message message( - // "Ground truth session info", mes, - // pfd::choice::ok, pfd::icon::info); - // message.result(); - } - } -} - -void saveSubsession() -{ - int inx_begin = 0; - int inx_end = 0; - - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (session.point_clouds_container.point_clouds[i].visible) - { - inx_begin = i; - break; - } - } - - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - if (session.point_clouds_container.point_clouds[i].visible) - inx_end = i; - - // creating filename proposal based on current selection - fs::path path(session_file_name); - // Extract parts - fs::path dir = path.parent_path(); - std::string stem = path.stem().string(); - const auto ext = ".mjs"; // forcing new extension even if original session was .json - const std::string indexpart = " " + std::to_string(inx_begin) + "-" + std::to_string(inx_end); - - // Build new name - std::string indexed_file_name = (dir / (stem + indexpart + ext)).string(); - - const auto output_file_name = mandeye::fd::SaveFileDialog("Save subsession", mandeye::fd::Session_filter, ".mjs", indexed_file_name); - - if (output_file_name.size() > 0) - { - spdlog::info("Subsession file to save: '{}'", output_file_name); - - path = fs::path(output_file_name); - dir = path.parent_path(); - stem = path.stem().string(); - - const auto initial_poses_file_name = (dir / (stem + "_ini_poses" + ".mri")).string(); - const auto poses_file_name = (dir / (stem + "_poses" + ".mrp")).string(); - - session.save(fs::path(output_file_name).string(), poses_file_name, initial_poses_file_name, true); - spdlog::info("Saving poses to: '{}'", poses_file_name); - session.point_clouds_container.save_poses(fs::path(poses_file_name).string(), true); - - try - { - fs::copy_file(poses_file_name, initial_poses_file_name, fs::copy_options::overwrite_existing); - } catch (const fs::filesystem_error& e) - { - spdlog::error("Error copying poses file: {}", e.what()); - } - } - else - spdlog::info("Saving canceled"); -} - -void settings_gui() -{ - ImGui::Begin("Settings", &is_settings_gui); - { - std::string wd = "Working directory: '" + session.working_directory + "'"; - ImGui::Text(wd.c_str()); - - ImGui::NewLine(); - - ImGui::InputFloat("camera_x", &new_rotation_center.x()); - ImGui::InputFloat("camera_y", &new_rotation_center.y()); - ImGui::InputFloat("camera_z", &new_rotation_center.z()); - - if (ImGui::Button("set camera")) - { - // new_rotate_x = rotate_x; - // new_rotate_y = rotate_y; - // new_translate_x = -new_rotation_center.x(); - // new_translate_y = -new_rotation_center.y(); - // new_translate_z = -new_rotation_center.z(); - camera_transition_active = true; - } - - if (ImGui::Button("Set initial pose to Identity and update other poses")) - initial_pose_to_identity(session); - - ImGui::NewLine(); - - ImGui::Checkbox("Downsample during load", &tls_registration.is_decimate); - ImGui::Checkbox("Loading Point Cloud Cache Mode", &session.load_cache_mode); - - ImGui::Text("Bucket [m]:"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("X##b", &tls_registration.bucket_x, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("Y##b", &tls_registration.bucket_y, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("Z##b", &tls_registration.bucket_z, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::PopItemWidth(); - - ImGui::Separator(); - // common_data - // manual_pose_graph_loop_closure_mode - - if (ImGui::Button("Load RESSO file (transformation_GroundTruth.reg)")) - { - std::string input_file_name = ""; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load RESSO", mandeye::fd::Resso_filter); - spdlog::info("RESSO file: '{}'", input_file_name); - - if (input_file_name.size() > 0) - { - session.working_directory = fs::path(input_file_name).parent_path().string(); - - if (!session.point_clouds_container.load( - session.working_directory.c_str(), - input_file_name.c_str(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z, - session.load_cache_mode)) - { - spdlog::error("Error loading file!"); - return; - } - else - spdlog::info("Loaded: {} point_clouds", session.point_clouds_container.point_clouds.size()); - } - } - ImGui::SameLine(); - if (ImGui::Button("Save RESSO file")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Save RESSO file", mandeye::fd::Resso_filter); - spdlog::info("RESSO file to save: '{}'", output_file_name); - if (output_file_name.size() > 0) - session.point_clouds_container.save_poses(fs::path(output_file_name).string(), false); - } - ImGui::Text("RESSO dataset: "); - ImGui::SameLine(); - ImGuiHyperlink("https://3d.bk.tudelft.nl/liangliang/publications/2019/plade/resso.html"); - - ImGui::NewLine(); - - if (ImGui::Button("Load ETH file (pairs.txt)")) - { - std::string input_file_name = ""; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load ETH file", {}); - if (input_file_name.size() > 0) - { - session.working_directory = fs::path(input_file_name).parent_path().string(); - - if (!session.point_clouds_container.load_eth( - session.working_directory.c_str(), - input_file_name.c_str(), - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z)) - { - spdlog::error("Error loading file!"); - return; - } - else - spdlog::info("Loaded: {} point_clouds", session.point_clouds_container.point_clouds.size()); - } - } - ImGui::Text("ETH dataset: "); - ImGui::SameLine(); - ImGuiHyperlink("https://prs.igp.ethz.ch/research/completed_projects/automatic_registration_of_point_clouds.html"); - - ImGui::NewLine(); - - if (ImGui::Button("Load 3DTK files (select all *.txt files)")) - { - session.point_clouds_container.point_clouds.clear(); - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load txt files", {}, true); - - if (input_file_names.size() > 0) - { - session.working_directory = fs::path(input_file_names[0]).parent_path().string(); - - spdlog::info("TXT files:"); - for (size_t i = 0; i < input_file_names.size(); i++) - spdlog::info("{}", input_file_names[i]); - - if (!session.point_clouds_container.load_3DTK_tls( - input_file_names, - tls_registration.is_decimate, - tls_registration.bucket_x, - tls_registration.bucket_y, - tls_registration.bucket_z)) - { - spdlog::error("Error loading file!"); - return; - } - else - spdlog::info("Loaded: {} point_clouds", session.point_clouds_container.point_clouds.size()); - } - } - ImGui::Text("3DTK dataset (18: the campus of the Jacobs University Bremen)"); - ImGui::SameLine(); - ImGuiHyperlink("http://kos.informatik.uni-osnabrueck.de/3Dscans/"); - - ImGui::NewLine(); - - if (ImGui::Button("Update initial poses from RESSO file")) - { - std::string input_file_name; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load RESSO file", {}); - if (input_file_name.size() > 0) - { - session.working_directory = fs::path(input_file_name).parent_path().string(); - - if (!session.point_clouds_container.update_initial_poses_from_RESSO( - session.working_directory.c_str(), input_file_name.c_str())) - { - spdlog::error("Error loading file!"); - return; - } - else - { - session.point_clouds_container.initial_poses_file_name = input_file_name; - spdlog::info("Updated: {} point_clouds", session.point_clouds_container.point_clouds.size()); - } - } - } - ImGui::SameLine(); - ImGui::Text(session.point_clouds_container.initial_poses_file_name.c_str()); - - if (ImGui::Button("Update poses from RESSO file")) - { - std::string input_file_name; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load RESSO file", {}); - - if (input_file_name.size() > 0) - { - session.working_directory = fs::path(input_file_name).parent_path().string(); - - if (!session.point_clouds_container.update_poses_from_RESSO(session.working_directory.c_str(), input_file_name.c_str())) - { - spdlog::error("Error loading file!"); - return; - } - else - { - spdlog::info("Updated: {} point_clouds", session.point_clouds_container.point_clouds.size()); - session.point_clouds_container.poses_file_name = input_file_name; - } - } - } - ImGui::SameLine(); - - if (ImGui::Button("Update poses from RESSO file (inverse)")) - { - std::string input_file_name; - input_file_name = mandeye::fd::OpenFileDialogOneFile("Load RESSO file", {}); - - if (input_file_name.size() > 0) - { - session.working_directory = fs::path(input_file_name).parent_path().string(); - - if (!session.point_clouds_container.update_poses_from_RESSO_inverse( - session.working_directory.c_str(), input_file_name.c_str())) - { - spdlog::error("Error loading file!"); - return; - } - else - { - spdlog::info("Updated: {} point_clouds", session.point_clouds_container.point_clouds.size()); - session.point_clouds_container.poses_file_name = input_file_name; - } - } - } - ImGui::SameLine(); - ImGui::Text(session.point_clouds_container.poses_file_name.c_str()); - - ImGui::Separator(); - - if (!is_loop_closure_gui) - { - static double x_origin = 0.0; - static double y_origin = 0.0; - static double z_origin = 0.0; - - ImGui::Text("Origin [m]: "); - ImGui::SameLine(); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("X##o", &x_origin, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("Y##o", &y_origin, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("Z##o", &z_origin, 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::PopItemWidth(); - ImGui::SameLine(); - if (ImGui::Button("Set XYZ origin")) - { - if (session.point_clouds_container.point_clouds.size() != 0) - { - std::vector all_m_poses2; - for (size_t j = 0; j < session.point_clouds_container.point_clouds.size(); j++) - { - all_m_poses2.push_back(session.point_clouds_container.point_clouds[j].m_pose); - } - - session.point_clouds_container.point_clouds[0].m_pose(0, 3) = x_origin; - session.point_clouds_container.point_clouds[0].m_pose(1, 3) = y_origin; - session.point_clouds_container.point_clouds[0].m_pose(2, 3) = z_origin; - - session.point_clouds_container.point_clouds[0].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[0].m_pose); - - session.point_clouds_container.point_clouds[0].gui_translation[0] = - (float)session.point_clouds_container.point_clouds[0].pose.px; - session.point_clouds_container.point_clouds[0].gui_translation[1] = - (float)session.point_clouds_container.point_clouds[0].pose.py; - session.point_clouds_container.point_clouds[0].gui_translation[2] = - (float)session.point_clouds_container.point_clouds[0].pose.pz; - - session.point_clouds_container.point_clouds[0].gui_rotation[0] = - (float)(session.point_clouds_container.point_clouds[0].pose.om * RAD_TO_DEG); - session.point_clouds_container.point_clouds[0].gui_rotation[1] = - (float)(session.point_clouds_container.point_clouds[0].pose.fi * RAD_TO_DEG); - session.point_clouds_container.point_clouds[0].gui_rotation[2] = - (float)(session.point_clouds_container.point_clouds[0].pose.ka * RAD_TO_DEG); - - Eigen::Affine3d curr_m_pose2 = session.point_clouds_container.point_clouds[0].m_pose; - for (size_t j = 1; j < session.point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose2 = curr_m_pose2 * (all_m_poses2[j - 1].inverse() * all_m_poses2[j]); - - // spdlog::info(curr_m_pose2.matrix() << std::endl; - session.point_clouds_container.point_clouds[j].m_pose = curr_m_pose2; - session.point_clouds_container.point_clouds[j].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[j].m_pose); - - session.point_clouds_container.point_clouds[j].gui_translation[0] = - (float)session.point_clouds_container.point_clouds[j].pose.px; - session.point_clouds_container.point_clouds[j].gui_translation[1] = - (float)session.point_clouds_container.point_clouds[j].pose.py; - session.point_clouds_container.point_clouds[j].gui_translation[2] = - (float)session.point_clouds_container.point_clouds[j].pose.pz; - - session.point_clouds_container.point_clouds[j].gui_rotation[0] = - (float)(session.point_clouds_container.point_clouds[j].pose.om * RAD_TO_DEG); - session.point_clouds_container.point_clouds[j].gui_rotation[1] = - (float)(session.point_clouds_container.point_clouds[j].pose.fi * RAD_TO_DEG); - session.point_clouds_container.point_clouds[j].gui_rotation[2] = - (float)(session.point_clouds_container.point_clouds[j].pose.ka * RAD_TO_DEG); - } - } - } - - ImGui::Separator(); - - ImGui::Text("Set offsets to export point cloud in global coordinate system [m]:"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("each local coordinate of the point += offset"); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("X##t", &session.point_clouds_container.offset.x(), 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(xText); - ImGui::SameLine(); - ImGui::InputDouble("Y##t", &session.point_clouds_container.offset.y(), 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(yText); - ImGui::SameLine(); - ImGui::InputDouble("Z##t", &session.point_clouds_container.offset.z(), 0.0, 0.0, "%.3f"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip(zText); - ImGui::PopItemWidth(); - - if (ImGui::Button("Set offset_to_apply --> from session (X, Y, Z)")) - session.point_clouds_container.offset = session.point_clouds_container.offset_to_apply; - /* - ImGui::NewLine(); - ImGui::NewLine(); - ImGui::NewLine(); - ImGui::NewLine(); - ImGui::NewLine(); - ImGui::NewLine(); - ImGui::Separator(); - ImGui::Text("Perform experiment on:"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Experiments to compare methods and approaches for multi-view TLS registration"); - ImGui::SameLine(); - if (ImGui::Button("WINDOWS")) - perform_experiment_on_windows(session, observation_picking, tls_registration.icp, tls_registration.ndt, - tls_registration.registration_plane_feature, tls_registration.pose_graph_slam); ImGui::SameLine(); if (ImGui::Button("LINUX")) - perform_experiment_on_linux(session, observation_picking, tls_registration.icp, tls_registration.ndt, - tls_registration.registration_plane_feature, tls_registration.pose_graph_slam); - */ - } - } - - ImGui::End(); -} - -void display() -{ - ImGuiIO& io = ImGui::GetIO(); - glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - glClearColor(bg_color.x * bg_color.w, bg_color.y * bg_color.w, bg_color.z * bg_color.w, bg_color.w); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - float ratio = float(io.DisplaySize.x) / float(io.DisplaySize.y); - - updateCameraTransition(); - - viewLocal = Eigen::Affine3f::Identity(); - - if (!is_ortho) - { - reshape((GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - - // janusz - if (is_loop_closure_gui) - { - if (new_loop_closure_index) - { - // if (index_loop_closure_source < session.point_clouds_container.point_clouds.size()) - //{ - // new_rotation_center.x() = - // session.point_clouds_container.point_clouds[index_loop_closure_source].m_pose.translation().x(); - // new_rotation_center.y() = - // session.point_clouds_container.point_clouds[index_loop_closure_source].m_pose.translation().y(); - // new_rotation_center.z() = - // session.point_clouds_container.point_clouds[index_loop_closure_source].m_pose.translation().z(); - // - // new_translate_x = -new_rotation_center.x(); - // new_translate_y = -new_rotation_center.y(); - // camera_transition_active = true; - //} - - if (session.pose_graph_loop_closure.manipulate_active_edge) - { - if (session.pose_graph_loop_closure.edges.size() > 0) - { - if (session.pose_graph_loop_closure.index_active_edge < session.pose_graph_loop_closure.edges.size()) - { - new_rotation_center.x() = - session.point_clouds_container - .point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge] - .index_from] - .m_pose.translation() - .x(); - new_rotation_center.y() = - session.point_clouds_container - .point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge] - .index_from] - .m_pose.translation() - .y(); - new_rotation_center.z() = - session.point_clouds_container - .point_clouds[session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge] - .index_from] - .m_pose.translation() - .z(); - } - } - - new_rotate_x = rotate_x; - new_rotate_y = rotate_y; - new_translate_x = -new_rotation_center.x(); - new_translate_y = -new_rotation_center.y(); - new_translate_z = translate_z; - camera_transition_active = true; - } - - new_loop_closure_index = false; - } - } - - viewLocal.translate(rotation_center); - - viewLocal.translate(Eigen::Vector3f(translate_x, translate_y, translate_z)); - if (!lock_z) - viewLocal.rotate(Eigen::AngleAxisf(rotate_x * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - else - viewLocal.rotate(Eigen::AngleAxisf(-90.0 * DEG_TO_RAD, Eigen::Vector3f::UnitX())); - viewLocal.rotate(Eigen::AngleAxisf(rotate_y * DEG_TO_RAD, Eigen::Vector3f::UnitZ())); - - viewLocal.translate(-rotation_center); - - glLoadMatrixf(viewLocal.matrix().data()); - } - else - updateOrthoView(); - - showAxes(); - - if (session.control_points.is_imgui) - session.control_points.render(session.point_clouds_container, true); - else - { - if (is_loop_closure_gui) - session.pose_graph_loop_closure.Render( - session.point_clouds_container, - index_loop_closure_source, - index_loop_closure_target, - num_edge_extended_before, - num_edge_extended_after); - - tls_registration.gnss.render(session.point_clouds_container); - session.ground_control_points.render(session.point_clouds_container); - session.control_points.render(session.point_clouds_container, false); - } - - int prev_index_pose = session.control_points.index_pose; - - if (prev_index_pose != session.control_points.index_pose) - { - session.control_points.index_picked_point = -1; // reset picked point when pose changes - - new_rotation_center.x() = session.point_clouds_container.point_clouds[session.control_points.index_pose].m_pose.translation().x(); - new_rotation_center.y() = session.point_clouds_container.point_clouds[session.control_points.index_pose].m_pose.translation().y(); - new_rotation_center.z() = session.point_clouds_container.point_clouds[session.control_points.index_pose].m_pose.translation().z(); - - new_rotate_x = rotate_x; - new_rotate_y = rotate_y; - if (session.control_points.track_pose_with_camera) - { - new_translate_x = -new_rotation_center.x(); - new_translate_y = -new_rotation_center.y(); - } - else - { - new_translate_x = translate_x; - new_translate_y = translate_y; - } - new_translate_z = translate_z; - camera_transition_active = true; - } - - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGLUT_NewFrame(); - ImGui::NewFrame(); - - ShowMainDockSpace(); - - if (session.control_points.is_imgui) - session.control_points.imgui(session.point_clouds_container, rotation_center); - - if (session.ground_control_points.is_imgui) - session.ground_control_points.imgui(session.point_clouds_container); - - if (!session.control_points.is_imgui) - { - if (!is_loop_closure_gui) - { - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (session.point_clouds_container.point_clouds[i].gizmo) - { - std::vector all_m_poses; - for (size_t j = 0; j < session.point_clouds_container.point_clouds.size(); j++) - { - all_m_poses.push_back(session.point_clouds_container.point_clouds[j].m_pose); - } - - ImGuiIO& io = ImGui::GetIO(); - // ImGuizmo ----------------------------------------------- - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - &modelview[0], - &projection[0], - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - } - else - ImGuizmo::Manipulate( - m_ortho_gizmo_view, - m_ortho_projection, - ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | ImGuizmo::ROTATE_Z, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - session.point_clouds_container.point_clouds[i].m_pose(0, 0) = m_gizmo[0]; - session.point_clouds_container.point_clouds[i].m_pose(1, 0) = m_gizmo[1]; - session.point_clouds_container.point_clouds[i].m_pose(2, 0) = m_gizmo[2]; - session.point_clouds_container.point_clouds[i].m_pose(3, 0) = m_gizmo[3]; - session.point_clouds_container.point_clouds[i].m_pose(0, 1) = m_gizmo[4]; - session.point_clouds_container.point_clouds[i].m_pose(1, 1) = m_gizmo[5]; - session.point_clouds_container.point_clouds[i].m_pose(2, 1) = m_gizmo[6]; - session.point_clouds_container.point_clouds[i].m_pose(3, 1) = m_gizmo[7]; - session.point_clouds_container.point_clouds[i].m_pose(0, 2) = m_gizmo[8]; - session.point_clouds_container.point_clouds[i].m_pose(1, 2) = m_gizmo[9]; - session.point_clouds_container.point_clouds[i].m_pose(2, 2) = m_gizmo[10]; - session.point_clouds_container.point_clouds[i].m_pose(3, 2) = m_gizmo[11]; - session.point_clouds_container.point_clouds[i].m_pose(0, 3) = m_gizmo[12]; - session.point_clouds_container.point_clouds[i].m_pose(1, 3) = m_gizmo[13]; - session.point_clouds_container.point_clouds[i].m_pose(2, 3) = m_gizmo[14]; - session.point_clouds_container.point_clouds[i].m_pose(3, 3) = m_gizmo[15]; - session.point_clouds_container.point_clouds[i].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[i].m_pose); - - session.point_clouds_container.point_clouds[i].gui_translation[0] = - (float)session.point_clouds_container.point_clouds[i].pose.px; - session.point_clouds_container.point_clouds[i].gui_translation[1] = - (float)session.point_clouds_container.point_clouds[i].pose.py; - session.point_clouds_container.point_clouds[i].gui_translation[2] = - (float)session.point_clouds_container.point_clouds[i].pose.pz; - - session.point_clouds_container.point_clouds[i].gui_rotation[0] = - (float)(session.point_clouds_container.point_clouds[i].pose.om * RAD_TO_DEG); - session.point_clouds_container.point_clouds[i].gui_rotation[1] = - (float)(session.point_clouds_container.point_clouds[i].pose.fi * RAD_TO_DEG); - session.point_clouds_container.point_clouds[i].gui_rotation[2] = - (float)(session.point_clouds_container.point_clouds[i].pose.ka * RAD_TO_DEG); - - if (!manipulate_only_marked_gizmo) - { - Eigen::Affine3d curr_m_pose = session.point_clouds_container.point_clouds[i].m_pose; - for (size_t j = i + 1; j < session.point_clouds_container.point_clouds.size(); j++) - { - curr_m_pose = curr_m_pose * (all_m_poses[j - 1].inverse() * all_m_poses[j]); - session.point_clouds_container.point_clouds[j].m_pose = curr_m_pose; - session.point_clouds_container.point_clouds[j].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[j].m_pose); - - session.point_clouds_container.point_clouds[j].gui_translation[0] = - (float)session.point_clouds_container.point_clouds[j].pose.px; - session.point_clouds_container.point_clouds[j].gui_translation[1] = - (float)session.point_clouds_container.point_clouds[j].pose.py; - session.point_clouds_container.point_clouds[j].gui_translation[2] = - (float)session.point_clouds_container.point_clouds[j].pose.pz; - - session.point_clouds_container.point_clouds[j].gui_rotation[0] = - (float)(session.point_clouds_container.point_clouds[j].pose.om * RAD_TO_DEG); - session.point_clouds_container.point_clouds[j].gui_rotation[1] = - (float)(session.point_clouds_container.point_clouds[j].pose.fi * RAD_TO_DEG); - session.point_clouds_container.point_clouds[j].gui_rotation[2] = - (float)(session.point_clouds_container.point_clouds[j].pose.ka * RAD_TO_DEG); - } - } - } - } - - session.point_clouds_container.render(observation_picking, viewer_decimate_point_cloud, 1, session_dims); - - // spdlog::info("session.point_clouds_container.xy_grid_10x10 " << (int)session.point_clouds_container.xy_grid_10x10 << - // std::endl; - - observation_picking.render(); - - glPushAttrib(GL_ALL_ATTRIB_BITS); - glPointSize(5); - for (const auto& obs : observation_picking.observations) - { - for (const auto& [key1, value1] : obs) - { - for (const auto& [key2, value2] : obs) - { - if (key1 != key2) - { - Eigen::Vector3d p1, p2; - if (session.point_clouds_container.show_with_initial_pose) - { - p1 = session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_initial_pose * value2; - } - else - { - p1 = session.point_clouds_container.point_clouds[key1].m_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_pose * value2; - } - glColor3f(0, 1, 0); - glBegin(GL_POINTS); - glVertex3f(p1.x(), p1.y(), p1.z()); - glVertex3f(p2.x(), p2.y(), p2.z()); - glEnd(); - glColor3f(1, 0, 0); - glBegin(GL_LINES); - glVertex3f(p1.x(), p1.y(), p1.z()); - glVertex3f(p2.x(), p2.y(), p2.z()); - glEnd(); - } - } - } - } - glPopAttrib(); - - for (const auto& obs : observation_picking.observations) - { - Eigen::Vector3d mean(0, 0, 0); - int counter = 0; - for (const auto& [key1, value1] : obs) - { - mean += session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - counter++; - } - if (counter > 0) - { - mean /= counter; - - glColor3f(1, 0, 0); - glBegin(GL_LINE_STRIP); - glVertex3f(mean.x() - 1, mean.y() - 1, mean.z()); - glVertex3f(mean.x() + 1, mean.y() - 1, mean.z()); - glVertex3f(mean.x() + 1, mean.y() + 1, mean.z()); - glVertex3f(mean.x() - 1, mean.y() + 1, mean.z()); - glVertex3f(mean.x() - 1, mean.y() - 1, mean.z()); - glEnd(); - } - } - - glColor3f(1, 0, 1); - glBegin(GL_POINTS); - for (auto p : picked_points) - { - glVertex3f(p.x(), p.y(), p.z()); - } - glEnd(); - } - else - { - // ImGuizmo ----------------------------------------------- - if (session.pose_graph_loop_closure.gizmo && session.pose_graph_loop_closure.edges.size() > 0) - { - ImGuizmo::BeginFrame(); - ImGuizmo::Enable(true); - ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); - - if (!is_ortho) - { - GLfloat projection[16]; - glGetFloatv(GL_PROJECTION_MATRIX, projection); - - GLfloat modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - ImGuizmo::Manipulate( - &modelview[0], - &projection[0], - ImGuizmo::TRANSLATE | ImGuizmo::ROTATE_Z | ImGuizmo::ROTATE_X | ImGuizmo::ROTATE_Y, - ImGuizmo::WORLD, - m_gizmo, - NULL); - } - else - ImGuizmo::Manipulate( - m_ortho_gizmo_view, - m_ortho_projection, - ImGuizmo::TRANSLATE_X | ImGuizmo::TRANSLATE_Y | ImGuizmo::ROTATE_Z, - ImGuizmo::WORLD, - m_gizmo, - NULL); - - Eigen::Affine3d m_g = Eigen::Affine3d::Identity(); - - m_g(0, 0) = m_gizmo[0]; - m_g(1, 0) = m_gizmo[1]; - m_g(2, 0) = m_gizmo[2]; - m_g(3, 0) = m_gizmo[3]; - m_g(0, 1) = m_gizmo[4]; - m_g(1, 1) = m_gizmo[5]; - m_g(2, 1) = m_gizmo[6]; - m_g(3, 1) = m_gizmo[7]; - m_g(0, 2) = m_gizmo[8]; - m_g(1, 2) = m_gizmo[9]; - m_g(2, 2) = m_gizmo[10]; - m_g(3, 2) = m_gizmo[11]; - m_g(0, 3) = m_gizmo[12]; - m_g(1, 3) = m_gizmo[13]; - m_g(2, 3) = m_gizmo[14]; - m_g(3, 3) = m_gizmo[15]; - - const int& index_src = session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge].index_from; - - const Eigen::Affine3d& m_src = session.point_clouds_container.point_clouds.at(index_src).m_pose; - session.pose_graph_loop_closure.edges[session.pose_graph_loop_closure.index_active_edge].relative_pose_tb = - pose_tait_bryan_from_affine_matrix(m_src.inverse() * m_g); - } - } - } - - view_kbd_shortcuts(); - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_A, false)) - { - is_pca_gui = !is_pca_gui; - - // workaround - io.AddKeyEvent(ImGuiKey_A, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_C, false)) - { - session.control_points.is_imgui = !session.control_points.is_imgui; - - // workaround - io.AddKeyEvent(ImGuiKey_C, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_E, false)) - { - is_lio_segments_gui = !is_lio_segments_gui; - - // workaround - io.AddKeyEvent(ImGuiKey_E, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_G, false)) - { - session.ground_control_points.is_imgui = !session.ground_control_points.is_imgui; - - // workaround - io.AddKeyEvent(ImGuiKey_G, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_L, false)) - { - is_loop_closure_gui = !is_loop_closure_gui; - - // workaround - io.AddKeyEvent(ImGuiKey_L, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_O, false)) - { - openSession(); - - // workaround - io.AddKeyEvent(ImGuiKey_O, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_P, false)) - { - is_pose_graph_slam = !is_pose_graph_slam; - - // workaround - io.AddKeyEvent(ImGuiKey_P, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_R)) // random colors - { - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.render_color[0] = float(rand() % 255) / 255.0f; - pc.render_color[1] = float(rand() % 255) / 255.0f; - pc.render_color[2] = float(rand() % 255) / 255.0f; - - if (csTrajectory == CS_FOLLOW) - { - pc.traj_color[0] = pc.render_color[0]; - pc.traj_color[1] = pc.render_color[1]; - pc.traj_color[2] = pc.render_color[2]; - } - } - - // workaround - io.AddKeyEvent(ImGuiKey_R, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_S, false)) - { - if (io.KeyShift) - saveSubsession(); - else - saveSession(); - - // workaround - io.AddKeyEvent(ImGuiKey_S, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_T)) // solid colors - { - csPointCloud = CS_SOLID; - - float color[3]; - if (session_loaded) - { - color[0] = session.point_clouds_container.point_clouds[0].render_color[0]; - color[1] = session.point_clouds_container.point_clouds[0].render_color[1]; - color[2] = session.point_clouds_container.point_clouds[0].render_color[2]; - } - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.render_color[0] = color[0]; - pc.render_color[1] = color[1]; - pc.render_color[2] = color[2]; - - if (csTrajectory == CS_FOLLOW) - { - pc.traj_color[0] = pc.render_color[0]; - pc.traj_color[1] = pc.render_color[1]; - pc.traj_color[2] = pc.render_color[2]; - } - } - - // workaround - io.AddKeyEvent(ImGuiKey_T, false); - io.AddKeyEvent(ImGuiMod_Ctrl, false); - } - - if (ImGui::BeginMainMenuBar()) - { - if (!session_loaded) - { - if (ImGui::Button("Open session")) - openSession(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Select session to open (Ctrl+O)"); - - ImGui::SameLine(); - - if (ImGui::ArrowButton("##menuArrow", ImGuiDir_Down)) - ImGui::OpenPopup("OpenMenu"); - - if (ImGui::BeginPopup("OpenMenu")) - { - ImGui::MenuItem("Calculate_offset", nullptr, &tls_registration.calculate_offset); - ImGui::MenuItem("Fill in session", nullptr, &fillInSession); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Fill in data for trajectory and pose to create complete session"); - - if (ImGui::MenuItem("Open las/laz")) - openLaz(fillInSession); - - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Create session from las/laz file(s)"); - - ImGui::EndPopup(); - } - - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - } - else - { - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Save session as", "Ctrl+S")) - saveSession(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Save changes of full session with posibility to change filename"); - - // ImGui::BeginDisabled(!((index_begin > 0) || (index_end < - // static_cast(session.point_clouds_container.point_clouds.size() - 1)))); - //{ - if (ImGui::MenuItem("Save subsession", "Ctrl+Shift+S")) - saveSubsession(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Save session according to selections from 'LIO segments editor' window"); - //} - // ImGui::EndDisabled(); - - ImGui::Separator(); - if (ImGui::BeginMenu("Save all marked scans")) - { - static bool skip_ts_0 = true; - ImGui::Checkbox("Skip points with zero ts", &skip_ts_0); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Invalid points with zero timestamp will be skipped during export"); - - if (ImGui::MenuItem("Local scan")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_all_to_las(session, output_file_name, true, skip_ts_0); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("As one local scan transformed via inverse pose of first scan"); - - if (ImGui::MenuItem("Global scan")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_all_to_las(session, output_file_name, false, skip_ts_0); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip( - "To export in full resolution, close the program and open again and unmark 'downsample during " - "load' before loading session"); - ImGui::Separator(); - if (ImGui::MenuItem("Separate global scans (laz)")) - { - std::string output_folder_name_separately = ""; - output_folder_name_separately = mandeye::fd::SelectFolder("Choose folder"); - save_separately_to_las(session, output_folder_name_separately, ".laz"); - } - - if (ImGui::MenuItem("Separate global scans (las)")) - { - std::string output_folder_name_separately = ""; - output_folder_name_separately = mandeye::fd::SelectFolder("Choose folder"); - save_separately_to_las(session, output_folder_name_separately, ".las"); - } - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Save all marked scans as las/laz files"); - - if (ImGui::BeginMenu("Save all marked trajectories")) - { - ImGui::MenuItem("is_trajectory_export_downsampling", nullptr, &tls_registration.is_trajectory_export_downsampling); - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("curve_consecutive_distance [m]", &tls_registration.curve_consecutive_distance_meters); - ImGui::InputFloat("not_curve_consecutive_distance [m]", &tls_registration.not_curve_consecutive_distance_meters); - ImGui::PopItemWidth(); - - if (ImGui::MenuItem("Save all as las/laz files")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - if (output_file_name.size() > 0) - save_trajectories_to_laz( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("As one global scan"); - - ImGui::Separator(); - - ImGui::Text("(x,y,z,r00,r01,r02,r10,r11,r12,r20,r21,r22)"); - if (ImGui::MenuItem("Save all as csv (timestamp Lidar)##1")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - true, - false, - false, - false); - } - if (ImGui::MenuItem("Save all as csv (timestamp Unix)##1")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - false, - true, - false, - false); - } - if (ImGui::MenuItem("Save all as csv (timestamp Lidar, Unix)##1")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - true, - true, - false, - false); - } - - ImGui::Separator(); - ImGui::Text("(x,y,z,qx,qy,qz,qw)"); - - if (ImGui::MenuItem("Save all as csv (timestamp Lidar)##2")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - true, - false, - true, - false); - } - if (ImGui::MenuItem("Save all as csv (timestamp Unix)##2")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - false, - true, - true, - false); - } - if (ImGui::MenuItem("Save all as csv (timestamp Lidar, Unix)##2")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::Csv_filter, ".csv"); - spdlog::info("csv file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - true, - true, - true, - false); - } - - ImGui::Separator(); - - if (ImGui::MenuItem("Save all as dxf as polyline")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog("Ouput file name", mandeye::fd::Dxf_filter, ".dxf"); - spdlog::info("dxf file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_trajectories( - session, - output_file_name, - tls_registration.curve_consecutive_distance_meters, - tls_registration.not_curve_consecutive_distance_meters, - tls_registration.is_trajectory_export_downsampling, - false, - false, - false, - true); - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Save scale board")) - { - ImGui::Text("For all marked trajectories as one global scan to laz"); - - if (ImGui::MenuItem("> dec 0.1")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 0.1); - } - - if (ImGui::MenuItem("> dec 1.0")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 1.0); - } - - if (ImGui::MenuItem("> dec 10.0")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 10.0); - } - - ImGui::Separator(); - ImGui::Text("10km x 10km to laz"); - - if (ImGui::MenuItem("> 10m")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 10.0, 10000.0); - } - - if (ImGui::MenuItem("> 100m")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 100.0, 10000.0); - } - - if (ImGui::MenuItem("> 1000m")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - save_scale_board_to_laz(session, output_file_name, 1000.0, 10000.0); - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("GNSS")) - { - ImGui::MenuItem("Load with offset -> move to (0,0,0)", nullptr, &gnssWithOffset); - - if (ImGui::MenuItem("Load GNSS files and convert WGS84 to PUWG92")) - { - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load gnss files", mandeye::fd::Gnss_filter, true); - - if (input_file_names.size() > 0) - { - Eigen::Vector3d out_offset(0.0, 0.0, 0.0); - if (!tls_registration.gnss.load_data_from_gnss_and_convert_to_92(input_file_names, out_offset, gnssWithOffset)) - { - spdlog::error("Error loading GNSS files!"); - } - else - { - session.point_clouds_container.offset_to_apply = out_offset; - } - } - } - - ImGui::MenuItem("Set WGS84 reference from 1st pose", nullptr, &tls_registration.gnss.setWGS84ReferenceFromFirstPose); - - ImGui::Text("Load & convert WGS84 to Cartesian by Mercator projection"); - - if (ImGui::MenuItem("Load GNSS (deprecated)")) - { - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load gnss files", mandeye::fd::Gnss_filter, true); - - if (input_file_names.size() > 0) - { - if (!tls_registration.gnss.load_raw_data_from_gnss(input_file_names)) - { - spdlog::error("Error loading GNSS files!"); - } - if (!tls_registration.gnss.project_to_mercator_projection()) - { - spdlog::error("Error converting WGS84 to Mercator projection!"); - } - } - } - if (ImGui::MenuItem("Load GNSS")) - { - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load gnss files", mandeye::fd::Gnss_filter, true); - - if (input_file_names.size() > 0) - { - if (!tls_registration.gnss.load_raw_data_from_gnss(input_file_names)) - { - spdlog::error("Error loading GNSS files!"); - } - if (!tls_registration.gnss.project_using_proj()) - { - spdlog::error("Error converting WGS84 to PROJ projection!"); - } - } - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Load structured GNSS dataset and decode it into coordinates, using PROJ library"); - - if (ImGui::MenuItem("Load NMEA (deprecated)")) - { - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load nmea files", mandeye::fd::Nmea_filter, true); - - if (input_file_names.size() > 0) - { - if (!tls_registration.gnss.load_raw_data_from_nmea(input_file_names)) - spdlog::error("Error loading NMEA files!"); - } - if (!tls_registration.gnss.project_to_mercator_projection()) - { - spdlog::error("Error converting WGS84 to Mercator projection!"); - } - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Load raw GNSS serial output and decode it into coordinates"); - if (ImGui::MenuItem("Load NMEA")) - { - std::vector input_file_names; - input_file_names = mandeye::fd::OpenFileDialog("Load nmea files", mandeye::fd::Nmea_filter, true); - - if (input_file_names.size() > 0) - { - if (!tls_registration.gnss.load_raw_data_from_nmea(input_file_names)) - spdlog::error("Error loading NMEA files!"); - } - if (!tls_registration.gnss.project_using_proj()) - { - spdlog::error("Error converting WGS84 to PROJ projection!"); - } - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Load raw GNSS serial output and decode it into coordinates, using PROJ library"); - - ImGui::Separator(); - - if (ImGui::MenuItem("Save GNSS data to las/laz file")) - { - const auto output_file_name = - mandeye::fd::SaveFileDialog("Save las or laz file", mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("las or laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - tls_registration.gnss.save_to_laz( - output_file_name, - session.point_clouds_container.offset.x(), - session.point_clouds_container.offset.y(), - session.point_clouds_container.offset.z()); - } - const auto prepareVisibleData = [&]() - { - std::vector pointcloud; - std::vector intensity; - std::vector timestamps; - - for (auto& p : session.point_clouds_container.point_clouds) - { - if (p.visible) - { - for (size_t i = 0; i < p.points_local.size(); i++) - { - const auto& pp = p.points_local[i]; - Eigen::Vector3d vp; - vp = p.m_pose * pp; - - pointcloud.push_back(vp); - if (i < p.intensities.size()) - intensity.push_back(p.intensities[i]); - else - intensity.push_back(0); - if (i < p.timestamps.size()) - timestamps.push_back(p.timestamps[i]); - } - } - } - return std::tuple(pointcloud, intensity, timestamps); - }; - - if (ImGui::MenuItem("Save metascan points in PUWG92(dep!)")) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - const auto [pointcloud, intensity, timestamps] = prepareVisibleData(); - - const auto lat = tls_registration.gnss.WGS84ReferenceLatitude; - const auto lon = tls_registration.gnss.WGS84ReferenceLongitude; - const auto alt = tls_registration.gnss.gnss_poses[0].alt; - - double Xpuwg92 = 0.0; - double Ypuwg92 = 0.0; - wgs84_do_puwg92(lat, lon, &Xpuwg92, &Ypuwg92); - Eigen::Vector3d offset(Ypuwg92, Xpuwg92, alt); - exportLaz(output_file_name, pointcloud, intensity, timestamps, offset.x(), offset.y(), offset.z()); - } - ImGui::Separator(); - for (const auto& geoid : geoids) - { - if (ImGui::MenuItem(std::string("Set geoid to " + geoid).c_str(), nullptr, selected_geoid_model == geoid)) - { - selected_geoid_model = geoid; - } - } - ImGui::Separator(); - - for (const auto& crtName : CRTs::SupportedCRTs) - { - std::string itemName = "Save metascan points in " + crtName + " (PROJ)"; - if (ImGui::MenuItem(itemName.c_str())) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - - const auto [pointcloud, intensity, timestamps] = prepareVisibleData(); - const auto lla_points = tls_registration.gnss.unproject_using_proj(pointcloud); - auto crt_points = tls_registration.gnss.CRTConvert(lla_points, crtName, selected_geoid_model); - Eigen::Vector3d offset = crt_points.front(); - for (auto& p : crt_points) - { - p = p - offset; - } - exportLaz(output_file_name, crt_points, intensity, timestamps, offset.x(), offset.y(), offset.z()); - } - } - - for (const auto& crtName : CRTs::SupportedCRTs) - { - std::string itemName = "Save GNSS data to las/laz in " + crtName + " (PROJ)"; - if (ImGui::MenuItem(itemName.c_str())) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - - std::vector lla_points; - std::vector intensity; - std::vector timestamps; - for (const auto& gnss : tls_registration.gnss.gnss_poses) - { - lla_points.emplace_back(gnss.lat, gnss.lon, gnss.h_wgs84); - intensity.push_back(gnss.hdop); - timestamps.push_back(gnss.timestamp); - } - - auto crt_points = tls_registration.gnss.CRTConvert(lla_points, crtName, selected_geoid_model); - Eigen::Vector3d offset = crt_points.front(); - for (auto& p : crt_points) - { - p = p - offset; - } - exportLaz(output_file_name, crt_points, intensity, timestamps, offset.x(), offset.y(), offset.z()); - } - } - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("GNSS (GPS, etc.) related open/save commands"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Loaded session:"); - ImGui::Text(std::string(session.session_file_name).c_str()); - ImGui::Separator(); - ImGui::Text("Total number of points: %zu", session_total_number_of_points); - - if (ImGui::BeginTable("Dimensions", 4)) - { - ImGui::TableSetupColumn("Coord [m]"); - ImGui::TableSetupColumn("min"); - ImGui::TableSetupColumn("max"); - ImGui::TableSetupColumn("size"); - ImGui::TableHeadersRow(); - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - - std::string text = "X"; - float centered = ImGui::GetColumnWidth() - ImGui::CalcTextSize(text.c_str()).x; - // Set cursor so text is centered - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + centered * 0.5f); - - ImGui::Text("X"); - - ImGui::TableSetColumnIndex(1); - ImGui::Text("%.3f", session_dims.x_min); - ImGui::TableSetColumnIndex(2); - ImGui::Text("%.3f", session_dims.x_max); - ImGui::TableSetColumnIndex(3); - ImGui::Text("%.3f", session_dims.length); - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + centered * 0.5f); - ImGui::Text("Y"); - - ImGui::TableSetColumnIndex(1); - ImGui::Text("%.3f", session_dims.y_min); - ImGui::TableSetColumnIndex(2); - ImGui::Text("%.3f", session_dims.y_max); - ImGui::TableSetColumnIndex(3); - ImGui::Text("%.3f", session_dims.width); - - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + centered * 0.5f); - ImGui::Text("Z"); - - ImGui::TableSetColumnIndex(1); - ImGui::Text("%.3f", session_dims.z_min); - ImGui::TableSetColumnIndex(2); - ImGui::Text("%.3f", session_dims.z_max); - ImGui::TableSetColumnIndex(3); - ImGui::Text("%.3f", session_dims.height); - - ImGui::EndTable(); - } - - ImGui::EndTooltip(); - } - - if (ImGui::BeginMenu("Tools")) - { - ImGui::MenuItem("Point Cloud Alignment", "Ctrl+A", &is_pca_gui); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Point cloud alignment (registration) algorithms:"); - ImGui::Text( - "(aligning two 3D point sets from LiDAR scans, by estimating\nthe relative pose(translation and rotation) " - "between them)"); - ImGui::Text("- Normal Distributions Transform"); - ImGui::Text("- Iterative Closest Point"); - ImGui::Text("- Registration Plane Feature"); - ImGui::EndTooltip(); - } - ImGui::Separator(); - ImGui::MenuItem("Pose Graph SLAM", "Ctrl+P", &is_pose_graph_slam); - ImGui::MenuItem("Observations", nullptr, &is_manual_analisys); - - ImGui::Separator(); - - ImGui::MenuItem("Control Points", "Ctrl+C", &session.control_points.is_imgui, !session.ground_control_points.is_imgui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Known reference points used to align or verify the scan"); - - ImGui::MenuItem( - "Ground Control Points", "Ctrl+G", &session.ground_control_points.is_imgui, !session.control_points.is_imgui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Accurate real-world points used to georeference the scan"); - - ImGui::MenuItem("Manual Loop Closure", "Ctrl+L", &is_loop_closure_gui, !is_lio_segments_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Manually connect overlapping scan sections"); - - ImGui::Separator(); - ImGui::MenuItem("LIO segments editor", "Ctrl+E", &is_lio_segments_gui, !is_loop_closure_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Manually adjust or review Lidar Inertial Odometry trajectory segments"); - - ImGui::Separator(); - ImGui::MenuItem("Translate", nullptr, &is_translate_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Define new coordinate frame from 3 picked points and transform all clouds"); - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Intersections")) - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputDouble("Intersection width [m]", &session.point_clouds_container.intersection_width, 0.0, 0.0, "%.2f"); - if (session.point_clouds_container.intersection_width < 0.001) - session.point_clouds_container.intersection_width = 0.001; - - ImGui::Separator(); - - ImGui::MenuItem("xz_intersection", nullptr, &session.point_clouds_container.xz_intersection); - ImGui::MenuItem("10m grid##xz", nullptr, &session.point_clouds_container.xz_grid_10x10); - ImGui::MenuItem("1m grid##xz", nullptr, &session.point_clouds_container.xz_grid_1x1); - ImGui::MenuItem("0.1m grid##xz", nullptr, &session.point_clouds_container.xz_grid_01x01); - - if (ImGui::MenuItem("Export xz intersection", nullptr, false, session.point_clouds_container.xz_intersection)) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - { - save_intersection( - session, - output_file_name, - /*xz_intersection=*/true, - /*yz_intersection=*/false, - /*xy_intersection=*/false, - session.point_clouds_container.intersection_width); - } - } - - ImGui::Separator(); - - ImGui::MenuItem("yz_intersection", nullptr, &session.point_clouds_container.yz_intersection); - ImGui::MenuItem("10m grid##yz", nullptr, &session.point_clouds_container.yz_grid_10x10); - ImGui::MenuItem("1m grid##yz", nullptr, &session.point_clouds_container.yz_grid_1x1); - ImGui::MenuItem("0.1m grid##yz", nullptr, &session.point_clouds_container.yz_grid_01x01); - - if (ImGui::MenuItem("Export yz intersection", nullptr, false, session.point_clouds_container.yz_intersection)) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - { - save_intersection( - session, - output_file_name, - /*xz_intersection=*/false, - /*yz_intersection=*/true, - /*xy_intersection=*/false, - session.point_clouds_container.intersection_width); - } - } - - ImGui::Separator(); - - ImGui::MenuItem("xy_intersection", nullptr, &session.point_clouds_container.xy_intersection); - ImGui::MenuItem("10m grid##xy", nullptr, &session.point_clouds_container.xy_grid_10x10); - ImGui::MenuItem("1m grid##xy", nullptr, &session.point_clouds_container.xy_grid_1x1); - ImGui::MenuItem("0.1m grid##xy", nullptr, &session.point_clouds_container.xy_grid_01x01); - - if (ImGui::MenuItem("Export xy intersection", nullptr, false, session.point_clouds_container.xy_intersection)) - { - const auto output_file_name = mandeye::fd::SaveFileDialog(out_fn.c_str(), mandeye::fd::LAS_LAZ_filter, ".laz"); - spdlog::info("laz file to save: '{}'", output_file_name); - - if (output_file_name.size() > 0) - { - save_intersection( - session, - output_file_name, - /*xz_intersection=*/false, - /*yz_intersection=*/false, - /*xy_intersection=*/true, - session.point_clouds_container.intersection_width); - } - } - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Intersection menu"); - } - - if (ImGui::BeginMenu("View")) - { - ImGui::BeginDisabled(!session_loaded); - { - if (ImGui::BeginMenu("Point cloud")) - { - auto tmp = point_size; - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points size", &point_size); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("keyboard 1-9 keys"); - if (point_size < 1) - point_size = 1; - else if (point_size > 10) - point_size = 10; - - if (tmp != point_size) - for (auto& point_cloud : session.point_clouds_container.point_clouds) - point_cloud.point_size = point_size; - - ImGui::Separator(); - - ImGui::Text("Color:"); - - float color[3]; - if (session_loaded) - { - color[0] = session.point_clouds_container.point_clouds[0].render_color[0]; - color[1] = session.point_clouds_container.point_clouds[0].render_color[1]; - color[2] = session.point_clouds_container.point_clouds[0].render_color[2]; - } - - if (ImGui::ColorEdit3("", (float*)&color, ImGuiColorEditFlags_NoInputs)) - { - csPointCloud = CS_SOLID; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.render_color[0] = color[0]; - pc.render_color[1] = color[1]; - pc.render_color[2] = color[2]; - - if (csTrajectory == CS_FOLLOW) - { - pc.traj_color[0] = pc.render_color[0]; - pc.traj_color[1] = pc.render_color[1]; - pc.traj_color[2] = pc.render_color[2]; - } - } - } - ImGui::SameLine(); - if (ImGui::MenuItem("> Solid", nullptr, (csPointCloud == CS_SOLID))) - csPointCloud = CS_SOLID; - - if (ImGui::MenuItem("> Random per segment", "Ctrl+R", (csPointCloud == CS_RANDOM))) - { - csPointCloud = CS_RANDOM; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.render_color[0] = float(rand() % 255) / 255.0f; - pc.render_color[1] = float(rand() % 255) / 255.0f; - pc.render_color[2] = float(rand() % 255) / 255.0f; - - if (csTrajectory == CS_FOLLOW) - { - pc.traj_color[0] = pc.render_color[0]; - pc.traj_color[1] = pc.render_color[1]; - pc.traj_color[2] = pc.render_color[2]; - } - } - } - - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Trajectory")) - { - if (session_loaded) - { - auto tmp = session.point_clouds_container.point_clouds[0].line_width; - - ImGui::BeginDisabled(!glLineWidthSupport); - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Line width", &tmp); - } - ImGui::EndDisabled(); - - if (tmp < 0) - tmp = 0; - else if (tmp > 5) - tmp = 5; - - if (tmp != session.point_clouds_container.point_clouds[0].line_width) - for (auto& point_cloud : session.point_clouds_container.point_clouds) - point_cloud.line_width = tmp; - } - - ImGui::MenuItem("Show IMU to LIO difference", nullptr, &session.point_clouds_container.show_imu_to_lio_diff); - if (session.point_clouds_container.show_imu_to_lio_diff) - { - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputFloat( - "IMU to LIO diff scale", &session.point_clouds_container.imu_to_lio_diff_scale, 1.0f, 10.0f, "%.1f"); - if (session.point_clouds_container.imu_to_lio_diff_scale < 0.0f) - session.point_clouds_container.imu_to_lio_diff_scale = 0.0f; - } - - ImGui::Separator(); - - ImGui::Text("Color:"); - - float color[3]; - if (session_loaded) - { - color[0] = session.point_clouds_container.point_clouds[0].traj_color[0]; - color[1] = session.point_clouds_container.point_clouds[0].traj_color[1]; - color[2] = session.point_clouds_container.point_clouds[0].traj_color[2]; - } - - if (ImGui::ColorEdit3("", (float*)&color, ImGuiColorEditFlags_NoInputs)) - { - csTrajectory = CS_SOLID; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.traj_color[0] = color[0]; - pc.traj_color[1] = color[1]; - pc.traj_color[2] = color[2]; - } - } - ImGui::SameLine(); - if (ImGui::MenuItem("> Solid", nullptr, (csTrajectory == CS_SOLID))) - csTrajectory = CS_SOLID; - - if (ImGui::MenuItem("> Random per segment", nullptr, (csTrajectory == CS_RANDOM))) - { - csTrajectory = CS_RANDOM; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.traj_color[0] = float(rand() % 255) / 255.0f; - pc.traj_color[1] = float(rand() % 255) / 255.0f; - pc.traj_color[2] = float(rand() % 255) / 255.0f; - } - } - - if (ImGui::MenuItem("> Follow cloud color", nullptr, (csTrajectory == CS_FOLLOW))) - { - csTrajectory = CS_FOLLOW; - - for (auto& pc : session.point_clouds_container.point_clouds) - { - pc.traj_color[0] = pc.render_color[0]; - pc.traj_color[1] = pc.render_color[1]; - pc.traj_color[2] = pc.render_color[2]; - } - } - - ImGui::EndMenu(); - } - - ImGui::ColorEdit3("Background color", (float*)&bg_color, ImGuiColorEditFlags_NoInputs); - - ImGui::BeginDisabled(tls_registration.gnss.gnss_poses.size() <= 0); - { - ImGui::MenuItem("Show GNSS correspondences", nullptr, &tls_registration.gnss.show_correspondences); - } - ImGui::EndDisabled(); - - ImGui::Separator(); - } - ImGui::EndDisabled(); - - if (ImGui::MenuItem("Orthographic", "key O", &is_ortho)) - { - if (is_ortho) - { - new_rotation_center = rotation_center; - new_rotate_x = 0.0; - new_rotate_y = 0.0; - new_translate_x = translate_x; - new_translate_y = translate_y; - new_translate_z = translate_z; - camera_transition_active = true; - } - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Switch between perspective view (3D) and orthographic view (2D/flat)"); - - ImGui::MenuItem("Show axes", "key X", &show_axes); - ImGui::MenuItem("Show compass/ruler", "key C", &compass_ruler); - - ImGui::MenuItem("Lock Z", "Shift + Z", &lock_z, !is_ortho); - - ImGui::Separator(); - - ImGui::MenuItem("Settings", nullptr, &is_settings_gui); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Show power user settings window with more parameters"); - - if (ImGui::BeginMenu("Console")) - { -#ifdef _WIN32 - if (ImGui::MenuItem("Use Windows console", nullptr, &consWin)) - { - if (consWin) - { - AllocConsole(); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); - freopen("CONIN$", "r", stdin); - } - else - FreeConsole(); - } - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("!!! If not used.. !!!"); - ImGui::Text("- old console output is lost"); - ImGui::Text("- new console output can only be seen in subwindow"); - ImGui::Text("- app might run faster"); - ImGui::EndTooltip(); - } -#endif - // ImGui::MenuItem("Subwindow", nullptr, &consImGui); - // if (ImGui::IsItemHovered()) - // ImGui::SetTooltip("Show/hide console output as GUI window"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Control console output"); - - ImGui::EndMenu(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Scene view relevant parameters"); - - camMenu(); - - ImGui::BeginDisabled(session.point_clouds_container.point_clouds.size() <= 0); - { - ImGui::SameLine(); - ImGui::Dummy(ImVec2(20, 0)); - ImGui::SameLine(); - - ImGui::SetNextItemWidth(ImGuiNumberWidth); - ImGui::InputInt("Points render downsampling", &viewer_decimate_point_cloud, 10, 100); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("increase for better performance, decrease for rendering more points"); - ImGui::SameLine(); - - // fps_avg = fps_avg * 0.7f + ImGui::GetIO().Framerate * 0.3f; // exponential smoothing - - // double now = ImGui::GetTime(); // ImGui’s built-in timer (in seconds) - - // ImGui::Checkbox("dynamic", &dynamicSubsampling); - // if (ImGui::IsItemHovered()) - // ImGui::SetTooltip("automatically control subsampling vs FPS: increase bellow 10, decrease above 60"); - // if (dynamicSubsampling && (fps_avg < 15) && (now - lastAdjustTime > cooldownSeconds)) - //{ - // viewer_decimate_point_cloud += 1; - // lastAdjustTime = now; - //} - // ImGui::SameLine(); - // ImGui::Text("(avg %.1f)", fps_avg); - - if (viewer_decimate_point_cloud < 1) - viewer_decimate_point_cloud = 1; - - ImGui::SameLine(); - ImGui::Text("(%.1f FPS)", ImGui::GetIO().Framerate); - } - ImGui::EndDisabled(); - - ImGui::SameLine( - ImGui::GetWindowWidth() - ImGui::CalcTextSize("Info").x - ImGui::GetStyle().ItemSpacing.x * 2 - - ImGui::GetStyle().FramePadding.x * 2); - - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_Header)); - - if (ImGui::SmallButton("Info")) - info_gui = !info_gui; - - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(3); - - ImGui::EndMainMenuBar(); - } - - if (is_settings_gui) - settings_gui(); - - // my_display_code(); - - if (is_pca_gui) - pca_gui(); - - if (is_pose_graph_slam) - pose_graph_slam_gui(); - - if (is_manual_analisys) - observation_picking_gui(); - - if (is_loop_closure_gui) - loop_closure_gui(); - - if (is_lio_segments_gui) - lio_segments_gui(); - - if (is_translate_gui) - { - translate_gui(); - } - else if (translate_tool.step != TranslateTool::Step::Idle) - { - translate_tool.step = TranslateTool::Step::Idle; - translate_tool.has_transform = false; - translate_tool.transform = Eigen::Affine3d::Identity(); - glutSetCursor(GLUT_CURSOR_INHERIT); - } - - cor_window(); - - info_window(infoLines, appShortcuts); - - draw_translate_preview(); - - if (compass_ruler) - drawMiniCompassWithRuler(); - - ImGui::Render(); - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -void draw_translate_preview() -{ - if (translate_tool.step != TranslateTool::Step::PickXAxis && translate_tool.step != TranslateTool::Step::PickYHint) - return; - - ImGuiIO& io = ImGui::GetIO(); - if (io.WantCaptureMouse) - return; - - const auto laser_beam = GetLaserBeam((int)io.MousePos.x, (int)io.MousePos.y); - RegistrationPlaneFeature::Plane pl; - pl.a = 0; - pl.b = 0; - pl.c = 1; - pl.d = -translate_tool.plane_z; - Eigen::Vector3d cursor_world = rayIntersection(laser_beam, pl); - - const Eigen::Vector3d O = translate_tool.origin; - - Eigen::Vector3d x_dir; - if (translate_tool.step == TranslateTool::Step::PickXAxis) - x_dir = cursor_world - O; - else - x_dir = translate_tool.x_point - O; - x_dir.z() = 0.0; - if (x_dir.norm() < 1e-9) - return; - double x_len = x_dir.norm(); - Eigen::Vector3d x_n = x_dir / x_len; - Eigen::Vector3d y_n(-x_n.y(), x_n.x(), 0.0); - - if (translate_tool.step == TranslateTool::Step::PickYHint) - { - Eigen::Vector3d v = cursor_world - O; - if (v.dot(y_n) < 0.0) - y_n = -y_n; - } - - double y_len = x_len * 0.5; - double z_len = x_len * 0.25; - - glLineWidth(3.0f); - glBegin(GL_LINES); - glColor3f(1.0f, 0.0f, 0.0f); - glVertex3d(O.x(), O.y(), O.z()); - glVertex3d(O.x() + x_n.x() * x_len, O.y() + x_n.y() * x_len, O.z()); - - glColor3f(0.0f, 1.0f, 0.0f); - glVertex3d(O.x(), O.y(), O.z()); - glVertex3d(O.x() + y_n.x() * y_len, O.y() + y_n.y() * y_len, O.z()); - - glColor3f(0.0f, 0.0f, 1.0f); - glVertex3d(O.x(), O.y(), O.z()); - glVertex3d(O.x(), O.y(), O.z() + z_len); - glEnd(); - glLineWidth(1.0f); -} - -Eigen::Affine3d compute_translate_matrix(const Eigen::Vector3d& O, const Eigen::Vector3d& X, const Eigen::Vector3d& Y_hint) -{ - Eigen::Vector3d dx = X - O; - dx.z() = 0.0; - if (dx.norm() < 1e-9) - return Eigen::Affine3d::Identity(); - dx.normalize(); - - double theta = -std::atan2(dx.y(), dx.x()); - - Eigen::Affine3d T = Eigen::Affine3d::Identity(); - T.prerotate(Eigen::AngleAxisd(theta, Eigen::Vector3d::UnitZ())); - T.pretranslate(-(T.linear() * O)); - - Eigen::Vector3d y_h_new = T * Y_hint; - if (y_h_new.y() < 0.0) - { - Eigen::Affine3d flip = Eigen::Affine3d::Identity(); - Eigen::Matrix3d R; - R << 1, 0, 0, 0, -1, 0, 0, 0, -1; - flip.linear() = R; - T = flip * T; - } - return T; -} - -void translate_gui() -{ - ImGui::Begin("Translate", &is_translate_gui); - - ImGui::PushItemWidth(ImGuiNumberWidth); - ImGui::InputFloat("Plane Z [m]", &translate_tool.plane_z); - ImGui::PopItemWidth(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Height of the horizontal pick plane used to project mouse clicks into 3D"); - - if (ImGui::Button("Start picking")) - { - translate_tool.step = TranslateTool::Step::PickOrigin; - translate_tool.has_transform = false; - translate_tool.transform = Eigen::Affine3d::Identity(); - - is_ortho = true; - new_rotation_center = rotation_center; - new_rotate_x = 0.0; - new_rotate_y = 0.0; - new_translate_x = translate_x; - new_translate_y = translate_y; - new_translate_z = translate_z; - camera_transition_active = true; - - glutSetCursor(GLUT_CURSOR_CROSSHAIR); - } - ImGui::SameLine(); - if (ImGui::Button("Reset")) - { - translate_tool.step = TranslateTool::Step::Idle; - translate_tool.has_transform = false; - translate_tool.transform = Eigen::Affine3d::Identity(); - glutSetCursor(GLUT_CURSOR_INHERIT); - } - - const char* step_text = "Idle"; - switch (translate_tool.step) - { - case TranslateTool::Step::PickOrigin: - step_text = "Pick origin (new 0,0)"; - break; - case TranslateTool::Step::PickXAxis: - step_text = "Pick point on +X axis"; - break; - case TranslateTool::Step::PickYHint: - step_text = "Pick point on +Y side"; - break; - case TranslateTool::Step::Ready: - step_text = "Ready - press Translate"; - break; - default: - break; - } - ImGui::Text("Step: %s", step_text); - - ImGui::Text("Origin : %.3f %.3f %.3f", translate_tool.origin.x(), translate_tool.origin.y(), translate_tool.origin.z()); - ImGui::Text("X point: %.3f %.3f %.3f", translate_tool.x_point.x(), translate_tool.x_point.y(), translate_tool.x_point.z()); - ImGui::Text("Y hint : %.3f %.3f %.3f", translate_tool.y_hint.x(), translate_tool.y_hint.y(), translate_tool.y_hint.z()); - - if (translate_tool.has_transform) - { - ImGui::Separator(); - ImGui::Text("Transformation matrix:"); - const Eigen::Matrix4d M = translate_tool.transform.matrix(); - for (int r = 0; r < 4; r++) - ImGui::Text("%8.4f %8.4f %8.4f %8.4f", M(r, 0), M(r, 1), M(r, 2), M(r, 3)); - } - - ImGui::Separator(); - ImGui::BeginDisabled(!translate_tool.has_transform); - { - if (ImGui::Button("Translate")) - { - for (auto& pc : session.point_clouds_container.point_clouds) - pc.m_pose = translate_tool.transform * pc.m_pose; - - for (auto& cp : session.control_points.cps) - { - Eigen::Vector3d g(cp.x_target_global, cp.y_target_global, cp.z_target_global); - g = translate_tool.transform * g; - cp.x_target_global = g.x(); - cp.y_target_global = g.y(); - cp.z_target_global = g.z(); - } - - translate_tool.step = TranslateTool::Step::Idle; - translate_tool.has_transform = false; - translate_tool.transform = Eigen::Affine3d::Identity(); - glutSetCursor(GLUT_CURSOR_INHERIT); - } - } - ImGui::EndDisabled(); - - ImGui::End(); -} - -Eigen::Vector3d GLWidgetGetOGLPos(int x, int y, const ObservationPicking& observation_picking) -{ - const auto laser_beam = GetLaserBeam(x, y); - - RegistrationPlaneFeature::Plane pl; - - pl.a = 0; - pl.b = 0; - pl.c = 1; - pl.d = -observation_picking.picking_plane_height; - - Eigen::Vector3d pos = rayIntersection(laser_beam, pl); - - spdlog::info("intersection: {}, {}, {}", pos.x(), pos.y(), pos.z()); - - return pos; -} - -void mouse(int glut_button, int state, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - - int button = -1; - if (glut_button == GLUT_LEFT_BUTTON) - button = 0; - if (glut_button == GLUT_RIGHT_BUTTON) - button = 1; - if (glut_button == GLUT_MIDDLE_BUTTON) - button = 2; - if (button != -1 && state == GLUT_DOWN) - io.MouseDown[button] = true; - if (button != -1 && state == GLUT_UP) - io.MouseDown[button] = false; - - static int glutMajorVersion = glutGet(GLUT_VERSION) / 10000; - if (state == GLUT_DOWN && (glut_button == 3 || glut_button == 4) && glutMajorVersion < 3) - wheel(glut_button, glut_button == 3 ? 1 : -1, x, y); - - if (!io.WantCaptureMouse) - { - if (glut_button == GLUT_LEFT_BUTTON && state == GLUT_DOWN && !io.KeyCtrl && !io.KeyShift && - translate_tool.step != TranslateTool::Step::Idle && translate_tool.step != TranslateTool::Step::Ready) - { - const auto laser_beam = GetLaserBeam(x, y); - RegistrationPlaneFeature::Plane pl; - pl.a = 0; - pl.b = 0; - pl.c = 1; - pl.d = -translate_tool.plane_z; - Eigen::Vector3d p = rayIntersection(laser_beam, pl); - - switch (translate_tool.step) - { - case TranslateTool::Step::PickOrigin: - translate_tool.origin = p; - translate_tool.step = TranslateTool::Step::PickXAxis; - break; - case TranslateTool::Step::PickXAxis: - translate_tool.x_point = p; - translate_tool.step = TranslateTool::Step::PickYHint; - break; - case TranslateTool::Step::PickYHint: - translate_tool.y_hint = p; - translate_tool.transform = compute_translate_matrix(translate_tool.origin, translate_tool.x_point, translate_tool.y_hint); - translate_tool.has_transform = true; - translate_tool.step = TranslateTool::Step::Ready; - break; - default: - break; - } - - mouse_old_x = x; - mouse_old_y = y; - return; - } - - if ((glut_button == GLUT_MIDDLE_BUTTON || glut_button == GLUT_LEFT_BUTTON) && state == GLUT_DOWN && (io.KeyCtrl || io.KeyShift)) - { - if (session.ground_control_points.is_imgui) - { - spdlog::info("GCP picking"); - int tmp; - getClosestTrajectoryPoint(session, x, y, true, tmp); - } - else if (session.control_points.is_imgui) - { - spdlog::info("Control point picking"); - const auto laser_beam = GetLaserBeam(x, y); - double min_distance = std::numeric_limits::max(); - - session.control_points.index_picked_point = -1; - - int i = session.control_points.index_pose; - if (session.control_points.index_pose >= 0 && - session.control_points.index_pose < session.point_clouds_container.point_clouds.size()) - { - for (size_t j = 0; j < session.point_clouds_container.point_clouds[i].points_local.size(); j++) - { - const auto& p = session.point_clouds_container.point_clouds[i].points_local[j]; - Eigen::Vector3d vp = session.point_clouds_container.point_clouds[i].m_pose * p; - - double dist = distance_point_to_line(vp, laser_beam); - - if (dist < min_distance && dist < 0.1) - { - min_distance = dist; - - new_rotation_center.x() = vp.x(); - new_rotation_center.y() = vp.y(); - new_rotation_center.z() = vp.z(); - - session.control_points.index_picked_point = j; - } - } - - new_rotate_x = rotate_x; - new_rotate_y = rotate_y; - new_translate_x = -new_rotation_center.x(); - new_translate_y = -new_rotation_center.y(); - new_translate_z = translate_z; - camera_transition_active = true; - } - } - else - { - if (glut_button == GLUT_MIDDLE_BUTTON) - if (session_loaded) - { - int tmp = -1; - getClosestTrajectoryPoint(session, x, y, false, tmp); - - if (io.KeyCtrl) - { - if (tmp != -1) - index_loop_closure_target = tmp; - } - else if (io.KeyShift) - { - if (tmp != -1) - index_loop_closure_source = tmp; - } - } - else - setNewRotationCenter(x, y); - } - } - - if (glut_button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN && io.KeyCtrl) - { - int tmp; - if (session_loaded) - getClosestTrajectoryPoint(session, x, y, false, tmp); - else - setNewRotationCenter(x, y); - } - - if (state == GLUT_DOWN) - { - mouse_buttons |= 1 << glut_button; - - if (observation_picking.is_observation_picking_mode) - { - Eigen::Vector3d p = GLWidgetGetOGLPos(x, y, observation_picking); - int number_active_pcs = 0; - int index_picked = -1; - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - if (session.point_clouds_container.point_clouds[i].visible) - { - number_active_pcs++; - index_picked = i; - } - } - if (number_active_pcs == 1) - observation_picking.add_picked_to_current_observation(index_picked, p); - } - } - else if (state == GLUT_UP) - mouse_buttons = 0; - - mouse_old_x = x; - mouse_old_y = y; - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (checkClHelp(argc, argv)) - { - std::cout << winTitle << "\n\n" - << "USAGE:\n" - << std::filesystem::path(argv[0]).stem().string() << " /?\n\n" - << "where\n" - << " Path to Mandeye JSON Session file (*.mjs)\n" - << " -h, /h, --help, /? Show this help and exit\n\n"; - - return 0; - } - - // search for available geoid models in the system and populate the menu - geoids = GNSS::get_available_geoids(); - - initGL(&argc, argv, winTitle, display, mouse); - - if (argc > 1) - { - for (int i = 1; i < argc; i++) - { - std::string ext = fs::path(argv[i]).extension().string(); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - - if (ext == ".mjs" || ext == ".json") - { - loadSession(argv[i]); - - break; - } - } - } - - glutMainLoop(); - - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGLUT_Shutdown(); - ImGui::DestroyContext(); - } catch (const std::bad_alloc& e) - { - spdlog::error("System is out of memory : {}", e.what()); - mandeye::fd::OutOfMemMessage(); - } catch (const std::exception& e) - { - spdlog::error(e.what()); - } catch (...) - { - spdlog::error("Unknown fatal error occurred!"); - } - - return 0; -} \ No newline at end of file diff --git a/apps/multi_view_tls_registration_legacy/perform_experiment.cpp b/apps/multi_view_tls_registration_legacy/perform_experiment.cpp deleted file mode 100644 index 3d09d8047..000000000 --- a/apps/multi_view_tls_registration_legacy/perform_experiment.cpp +++ /dev/null @@ -1,2428 +0,0 @@ -#include -#include -#include -#include - -// clang-format off -#include -#include -// clang-format on - -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -namespace fs = std::filesystem; - -void export_result_to_folder(std::string output_folder_name, ObservationPicking& observation_picking, Session& session) -{ - fs::path path(output_folder_name); - std::string file_name_rms = "rms.csv"; - auto path_rms = path; - path_rms /= file_name_rms; - std::cout << "exporting to file: '" << path_rms.string() << "'" << std::endl; - std::ofstream outfile_rms; - outfile_rms.open(path_rms, std::ios_base::app); - outfile_rms << "index_roi, rms_initial, rms_result" << std::endl; - - for (int i = 0; i < observation_picking.intersections.size(); i++) - { - std::string file_name_initial = "intersection_" + std::to_string(i) + "_initial.csv"; - std::string file_name_result = "intersection_" + std::to_string(i) + "_result.csv"; - - auto path_initial = path; - auto path_result = path; - - path_initial /= file_name_initial; - path_result /= file_name_result; - - std::cout << "exporting to file: '" << path_initial.string() << "'" << std::endl; - std::cout << "exporting to file: '" << path_result.string() << "'" << std::endl; - - std::ofstream outfile_initial; - std::ofstream outfile_result; - - outfile_initial.open(path_initial, std::ios_base::app); - outfile_result.open(path_result, std::ios_base::app); - - const auto& intersection = observation_picking.intersections[i]; - TaitBryanPose pose; - pose.px = intersection.translation[0]; - pose.py = intersection.translation[1]; - pose.pz = intersection.translation[2]; - pose.om = intersection.rotation[0]; - pose.fi = intersection.rotation[1]; - pose.ka = intersection.rotation[2]; - Eigen::Affine3d m_pose_inv = affine_matrix_from_pose_tait_bryan(pose).inverse(); - - double w = intersection.width_length_height[0] * 0.5; - double l = intersection.width_length_height[1] * 0.5; - double h = intersection.width_length_height[2] * 0.5; - - outfile_initial << "x;y;z;pc_index;is_initial;index_intersection;file" << std::endl; - outfile_result << "x;y;z;pc_index;is_initial;index_intersection;file" << std::endl; - - for (int pc_index = 0; pc_index < session.point_clouds_container.point_clouds.size(); pc_index++) - { - const auto& pc = session.point_clouds_container.point_clouds[pc_index]; - for (const auto& p : pc.points_local) - { - Eigen::Vector3d vpi = pc.m_initial_pose * p; - Eigen::Vector3d vpr = pc.m_pose * p; - - Eigen::Vector3d vpit = m_pose_inv * vpi; - Eigen::Vector3d vprt = m_pose_inv * vpr; - - if (fabs(vpit.x()) < w) - { - if (fabs(vpit.y()) < l) - { - if (fabs(vpit.z()) < h) - { - outfile_initial << vpit.x() << ";" << vpit.y() << ";" << vpit.z() << ";" << pc_index << ";1;" << i << ";" - << pc.file_name << std::endl; - } - } - } - if (fabs(vprt.x()) < w) - { - if (fabs(vprt.y()) < l) - { - if (fabs(vprt.z()) < h) - { - outfile_result << vprt.x() << ";" << vprt.y() << ";" << vprt.z() << ";" << pc_index << ";0;" << i << ";" - << pc.file_name << std::endl; - } - } - } - } - } - outfile_initial.close(); - outfile_result.close(); - - const auto& obs = observation_picking.observations[i]; - double rms_initial = 0.0; - int sum = 0; - double rms_result = 0.0; - - for (const auto& [key1, value1] : obs) - { - for (const auto& [key2, value2] : obs) - { - if (key1 != key2) - { - Eigen::Vector3d p1, p2; - p1 = session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_initial_pose * value2; - rms_initial += (p2.x() - p1.x()) * (p2.x() - p1.x()); - rms_initial += (p2.y() - p1.y()) * (p2.y() - p1.y()); - - p1 = session.point_clouds_container.point_clouds[key1].m_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_pose * value2; - rms_result += (p2.x() - p1.x()) * (p2.x() - p1.x()); - rms_result += (p2.y() - p1.y()) * (p2.y() - p1.y()); - - sum += 2; - } - } - } - std::cout << "sum: " << sum << std::endl; - if (sum > 0) - { - rms_initial = sqrt(rms_initial / sum); - rms_result = sqrt(rms_result / sum); - outfile_rms << i << ";" << rms_initial << ";" << rms_result << std::endl; - } - } - outfile_rms.close(); - - std::string file_name_poses = "poses_RESSO.reg"; - auto path_poses = path; - path_poses /= file_name_poses; - std::cout << "saving poses to: " << path_poses << std::endl; - session.point_clouds_container.save_poses(path_poses.string(), false); -} - -void export_result_to_folder(std::string output_folder_name, int method_id, ObservationPicking& observation_picking, Session& session) -{ - fs::path path(output_folder_name); - path /= std::to_string(method_id); - create_directory(path); - export_result_to_folder(path.string(), observation_picking, session); -} - -template -void append_to_result_file( - std::string file_name, std::string method, const T& t, float rms, int id_method, std::chrono::milliseconds elapsed) -{ - std::ofstream outfile; - outfile.open(file_name, std::ios_base::app); - outfile << method << ";" << id_method << ";" << int(t.is_gauss_newton) << ";" << int(t.is_levenberg_marguardt) << ";" << int(t.is_wc) - << ";" << int(t.is_cw) << ";" << int(t.is_tait_bryan_angles) << ";" << int(t.is_quaternion) << ";" << int(t.is_rodrigues) << ";" - << int(t.is_lie_algebra_left_jacobian) << ";" << int(t.is_lie_algebra_right_jacobian) << ";" << rms << ";" << elapsed.count() - << std::endl; - outfile.close(); -} - -void create_header(std::string file_name) -{ - std::ofstream outfile; - outfile.open(file_name); - outfile << "method;id_method;gauss_newton;levenberg_marguardt;wc;cw;tait_bryan_angles;quaternion;rodrigues;Lie_algebra_left_jacobian;" - "Lie_algebra_right_jacobian;rms;elapsed_time_miliseconds" - << std::endl; - outfile.close(); -} - -void add_initial_rms_to_file(std::string file_name, float rms) -{ - std::ofstream outfile; - outfile.open(file_name, std::ios_base::app); - // outfile << - // "method;is_gauss_newton;is_levenberg_marguardt;is_wc;is_cw;is_tait_bryan_angles;is_quaternion;is_rodrigues;is_Lie_algebra_left;Lie_algebra_right;rms;elapsed_time_miliseconds" - // << std::endl; - outfile << "initial_rms;0;0;0;0;0;0;0;0;0;0;" << rms << ";0" << std::endl; - outfile.close(); -} - -void reset_poses(Session& session) -{ - for (size_t i = 0; i < session.point_clouds_container.point_clouds.size(); i++) - { - session.point_clouds_container.point_clouds[i].m_pose = session.point_clouds_container.point_clouds[i].m_initial_pose; - session.point_clouds_container.point_clouds[i].pose = - pose_tait_bryan_from_affine_matrix(session.point_clouds_container.point_clouds[i].m_pose); - session.point_clouds_container.point_clouds[i].gui_translation[0] = (float)session.point_clouds_container.point_clouds[i].pose.px; - session.point_clouds_container.point_clouds[i].gui_translation[1] = (float)session.point_clouds_container.point_clouds[i].pose.py; - session.point_clouds_container.point_clouds[i].gui_translation[2] = (float)session.point_clouds_container.point_clouds[i].pose.pz; - session.point_clouds_container.point_clouds[i].gui_rotation[0] = - (float)rad2deg(session.point_clouds_container.point_clouds[i].pose.om); - session.point_clouds_container.point_clouds[i].gui_rotation[1] = - (float)rad2deg(session.point_clouds_container.point_clouds[i].pose.fi); - session.point_clouds_container.point_clouds[i].gui_rotation[2] = - (float)rad2deg(session.point_clouds_container.point_clouds[i].pose.ka); - } -} - -double compute_rms(bool initial, Session& session, ObservationPicking& observation_picking) -{ - double rms = 0.0; - int sum = 0; - for (const auto& obs : observation_picking.observations) - { - for (const auto& [key1, value1] : obs) - { - for (const auto& [key2, value2] : obs) - { - if (key1 != key2) - { - Eigen::Vector3d p1, p2; - if (initial) - { - p1 = session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_initial_pose * value2; - } - else - { - p1 = session.point_clouds_container.point_clouds[key1].m_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_pose * value2; - } - rms += (p2.x() - p1.x()) * (p2.x() - p1.x()); - sum++; - rms += (p2.y() - p1.y()) * (p2.y() - p1.y()); - sum++; - } - } - } - } - if (sum == 0) - { - std::cout << "sum == 0" << std::endl; - return -1; - } - else - { - rms = sqrt(rms / sum); - return rms; - } -} - -void perform_experiment_on_windows( - Session& session, - ObservationPicking& observation_picking, - ICP& icp, - NDT& ndt, - RegistrationPlaneFeature& registration_plane_feature, - PoseGraphSLAM& pose_graph_slam) -{ - bool compute_mean_and_cov_for_bucket = false; - session.point_clouds_container.show_with_initial_pose = false; - auto temp_data = session.point_clouds_container; - reset_poses(session); - double rms = 0.0f; - std::string result_file = session.working_directory + "/result_win.csv"; - float search_radius = 0.1f; - int number_of_threads = 16; - int number_of_iterations = 6; - int id_method = 0; - - create_header(result_file); - double initial_rms = compute_rms(false, session, observation_picking); - std::cout << "initial rms: " << initial_rms << std::endl; - add_initial_rms_to_file(result_file, initial_rms); - - // void export_result_to_folder(std::string output_folder_name, int method_id) { - // fs::path path(output_folder_name); - // path /= std::to_string(method_id); - // create_directory(path); - // export_result_to_folder(path.string()); - // } - - fs::path path_result(session.working_directory); - path_result /= "results_win"; - create_directory(path_result); - - //--0-- - icp.is_adaptive_robust_kernel = false; - icp.is_fix_first_node = false; - icp.search_radius = search_radius; - icp.number_of_threads = number_of_threads; - icp.number_of_iterations = number_of_iterations; - icp.is_adaptive_robust_kernel = false; - - icp.is_gauss_newton = true; - icp.is_levenberg_marguardt = false; - - icp.is_wc = true; - icp.is_cw = false; - - icp.is_tait_bryan_angles = true; - icp.is_quaternion = false; - icp.is_rodrigues = false; - icp.is_lie_algebra_left_jacobian = false; - icp.is_lie_algebra_right_jacobian = false; - - auto start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - auto end = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - std::cout << "final RMS: " << rms << std::endl; - - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - id_method++; - - //--1-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = true; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 1; - - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - // id_method++; - //--2-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = false; - icp.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 2; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--3-- - icp.is_wc = false; - icp.is_cw = true; - - icp.is_tait_bryan_angles = true; - icp.is_quaternion = false; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 3; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--4-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = true; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 4; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--5-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = false; - icp.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 5; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--6-- - icp.is_gauss_newton = false; - icp.is_levenberg_marguardt = true; - - icp.is_wc = true; - icp.is_cw = false; - - icp.is_tait_bryan_angles = true; - icp.is_quaternion = false; - icp.is_rodrigues = false; - icp.is_lie_algebra_left_jacobian = false; - icp.is_lie_algebra_right_jacobian = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 6; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--7-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = true; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 7; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--8-- - icp.is_tait_bryan_angles = false; - icp.is_quaternion = false; - icp.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 8; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--9-- - icp.is_wc = false; - icp.is_cw = true; - - icp.is_tait_bryan_angles = true; - icp.is_quaternion = false; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 9; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--10-- - icp.is_wc = false; - icp.is_cw = true; - - icp.is_tait_bryan_angles = false; - icp.is_quaternion = true; - icp.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 10; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--11-- - icp.is_wc = false; - icp.is_cw = true; - - icp.is_tait_bryan_angles = false; - icp.is_quaternion = false; - icp.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - icp.optimization_point_to_point_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 11; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--12-- - icp.is_gauss_newton = true; - icp.is_levenberg_marguardt = false; - - icp.is_wc = true; - icp.is_cw = false; - - icp.is_tait_bryan_angles = false; - icp.is_quaternion = false; - icp.is_rodrigues = true; - - icp.is_lie_algebra_left_jacobian = true; - icp.is_lie_algebra_right_jacobian = false; - - start = std::chrono::system_clock::now(); - icp.optimize_source_to_target_lie_algebra_left_jacobian(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 12; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--13-- - icp.is_lie_algebra_left_jacobian = false; - icp.is_lie_algebra_right_jacobian = true; - start = std::chrono::system_clock::now(); - icp.optimize_source_to_target_lie_algebra_right_jacobian(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 13; - append_to_result_file(result_file, "point_to_point", icp, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //---NDT--- - //--14-- - // - ndt.is_fix_first_node = false; - ndt.bucket_size[0] = 0.5; - ndt.bucket_size[1] = 0.5; - ndt.bucket_size[2] = 0.5; - ndt.number_of_threads = number_of_threads; - ndt.number_of_iterations = number_of_iterations; - - ndt.is_gauss_newton = true; - ndt.is_levenberg_marguardt = false; - - ndt.is_wc = true; - ndt.is_cw = false; - - ndt.is_tait_bryan_angles = true; - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - ndt.is_lie_algebra_left_jacobian = false; - ndt.is_lie_algebra_right_jacobian = false; - - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - std::cout << "final rms: " << rms << std::endl; - - id_method = 14; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--15-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 15; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - session.point_clouds_container = temp_data; - - //--16-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - ndt.is_rodrigues = true; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 16; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--17-- - ndt.is_wc = false; - ndt.is_cw = true; - - ndt.is_tait_bryan_angles = true; - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 17; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--18-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 18; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--19-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - ndt.is_rodrigues = true; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 19; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--20-- - ndt.is_gauss_newton = false; - ndt.is_levenberg_marguardt = true; - - ndt.is_wc = true; - ndt.is_cw = false; - - ndt.is_tait_bryan_angles = true; - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 20; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--21-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 21; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--22-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - ndt.is_rodrigues = true; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 22; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--23-- - ndt.is_wc = false; - ndt.is_cw = true; - - ndt.is_tait_bryan_angles = true; - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 23; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--24-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 24; - - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--25-- - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - ndt.is_rodrigues = true; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 25; - - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--26-- - ndt.is_gauss_newton = true; - ndt.is_levenberg_marguardt = false; - - ndt.is_wc = true; - ndt.is_cw = false; - - ndt.is_tait_bryan_angles = false; - ndt.is_quaternion = false; - ndt.is_rodrigues = false; - - ndt.is_lie_algebra_left_jacobian = true; - ndt.is_lie_algebra_right_jacobian = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 26; - - ndt.is_rodrigues = true; - - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--27-- - ndt.is_gauss_newton = false; - ndt.is_levenberg_marguardt = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 27; - ndt.is_rodrigues = true; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--28-- - ndt.is_lie_algebra_left_jacobian = false; - ndt.is_lie_algebra_right_jacobian = true; - ndt.is_rodrigues = false; - - ndt.is_gauss_newton = true; - ndt.is_levenberg_marguardt = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 28; - ndt.is_rodrigues = true; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--29-- - ndt.is_gauss_newton = false; - ndt.is_levenberg_marguardt = true; - ndt.is_rodrigues = false; - start = std::chrono::system_clock::now(); - ndt.optimize(session.point_clouds_container.point_clouds, true, compute_mean_and_cov_for_bucket); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - - id_method = 29; - ndt.is_rodrigues = true; - append_to_result_file(result_file, "normal_distributions_transform", ndt, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //---------------------------------------------------------------------------- - - registration_plane_feature.search_radius = search_radius; - registration_plane_feature.number_of_threads = number_of_threads; - registration_plane_feature.number_of_iterations = number_of_iterations; - registration_plane_feature.is_adaptive_robust_kernel = false; - registration_plane_feature.is_fix_first_node = false; - - //--30-- - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 30; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--31-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 31; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--32-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 32; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--33-- - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 33; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--34-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 34; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--35-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 35; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //------------------------------------------------------ - //--36-- - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 36; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--37-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 37; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--38-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 38; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--39-- - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 39; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--40-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 40; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--41-- - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 41; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--42-- Lie - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - registration_plane_feature.is_lie_algebra_left_jacobian = true; - registration_plane_feature.is_lie_algebra_right_jacobian = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian( - session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 42; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--43-- - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian( - session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 43; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--44-- - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - registration_plane_feature.is_lie_algebra_left_jacobian = false; - registration_plane_feature.is_lie_algebra_right_jacobian = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian( - session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 44; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--45-- - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian( - session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 45; - append_to_result_file(result_file, "point_to_projection_onto_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--46--using dot product - registration_plane_feature.is_lie_algebra_left_jacobian = false; - registration_plane_feature.is_lie_algebra_right_jacobian = false; - - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 46; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--47 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 47; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--48 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 48; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--49 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 49; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--50 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 50; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--51 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 51; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--52 - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 52; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--53 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 53; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--54 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 54; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--55 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 55; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--56 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 56; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--57 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 57; - append_to_result_file(result_file, "point_to_plane_using_dot_product", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--58 optimize_distance_point_to_plane_source_to_target - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 58; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--59 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 59; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--60 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 60; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--61 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 61; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--62 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 62; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--63 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 63; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--64 - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 64; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--65 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 65; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--66 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 66; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--67 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 67; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--68 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 68; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--69 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_distance_point_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 69; - append_to_result_file(result_file, "distance_point_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--70 optimize_plane_to_plane_source_to_target - registration_plane_feature.is_adaptive_robust_kernel = true; - - registration_plane_feature.is_gauss_newton = true; - registration_plane_feature.is_levenberg_marguardt = false; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 70; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--71 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 71; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--72 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 72; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--73 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 73; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--74 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 74; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--75 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 75; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--76 - registration_plane_feature.is_gauss_newton = false; - registration_plane_feature.is_levenberg_marguardt = true; - - registration_plane_feature.is_wc = true; - registration_plane_feature.is_cw = false; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 76; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--77 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 77; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--78 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 78; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--79 - registration_plane_feature.is_wc = false; - registration_plane_feature.is_cw = true; - - registration_plane_feature.is_tait_bryan_angles = true; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 79; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--80 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = true; - registration_plane_feature.is_rodrigues = false; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 80; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--81 - registration_plane_feature.is_tait_bryan_angles = false; - registration_plane_feature.is_quaternion = false; - registration_plane_feature.is_rodrigues = true; - - start = std::chrono::system_clock::now(); - registration_plane_feature.optimize_plane_to_plane_source_to_target(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 81; - append_to_result_file(result_file, "plane_to_plane", registration_plane_feature, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - // pose graph slam - //--82-- - pose_graph_slam.overlap_threshold = 0.3; - pose_graph_slam.iterations = 6; - - pose_graph_slam.search_radius = search_radius; - pose_graph_slam.number_of_threads = number_of_threads; - pose_graph_slam.number_of_iterations_pair_wise_matching = number_of_iterations; - - //-- - pose_graph_slam.is_adaptive_robust_kernel = false; - pose_graph_slam.is_fix_first_node = true; - pose_graph_slam.is_gauss_newton = true; - pose_graph_slam.is_levenberg_marguardt = false; - pose_graph_slam.is_cw = false; - pose_graph_slam.is_wc = true; - pose_graph_slam.is_tait_bryan_angles = true; - pose_graph_slam.is_quaternion = false; - pose_graph_slam.is_rodrigues = false; - - session.point_clouds_container = temp_data; - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_ndt = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - pose_graph_slam.ndt_bucket_size[0] = ndt.bucket_size[0]; - pose_graph_slam.ndt_bucket_size[1] = ndt.bucket_size[1]; - pose_graph_slam.ndt_bucket_size[2] = ndt.bucket_size[2]; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 82; - append_to_result_file(result_file, "pose_graph_slam (normal_distributions_transform)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--83 - session.point_clouds_container = temp_data; - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimization_point_to_point_source_to_target = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 83; - append_to_result_file(result_file, "pose_graph_slam (point_to_point)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--84 - session.point_clouds_container = temp_data; - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 84; - append_to_result_file(result_file, "pose_graph_slam (point_to_projection_onto_plane)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--85 - session.point_clouds_container = temp_data; - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_point_to_plane_source_to_target = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 85; - append_to_result_file(result_file, "pose_graph_slam (point_to_plane_using_dot_product)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--86 - session.point_clouds_container = temp_data; - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_distance_point_to_plane_source_to_target = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 86; - append_to_result_file(result_file, "pose_graph_slam (distance_point_to_plane)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--87 - pose_graph_slam.is_adaptive_robust_kernel = true; - - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_plane_to_plane_source_to_target = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 87; - append_to_result_file(result_file, "pose_graph_slam (plane_to_plane)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--88 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_adaptive_robust_kernel = false; - pose_graph_slam.is_ndt_lie_algebra_left_jacobian = true; - pose_graph_slam.is_lie_algebra_left_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 88; - append_to_result_file(result_file, "pose_graph_slam (ndt_lie_algebra_left_jacobian)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--89 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_ndt_lie_algebra_right_jacobian = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 89; - append_to_result_file(result_file, "pose_graph_slam (ndt_lie_algebra_right_jacobian)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--90 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_optimize_point_to_point_source_to_target_lie_algebra_left_jacobian = true; - pose_graph_slam.is_lie_algebra_left_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 90; - append_to_result_file( - result_file, "pose_graph_slam (point_to_point_lie_algebra_left_jacobian)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--91 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_optimize_point_to_point_source_to_target_lie_algebra_right_jacobian = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 91; - append_to_result_file( - result_file, "pose_graph_slam (point_to_point_lie_algebra_right_jacobian)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--92 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_left_jacobian = true; - pose_graph_slam.is_lie_algebra_left_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 92; - append_to_result_file( - result_file, - "pose_graph_slam (point_to_projection_onto_plane_lie_algebra_left_jacobian)", - pose_graph_slam, - rms, - id_method, - elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - - //--93 - pose_graph_slam.set_all_to_false(); - session.point_clouds_container = temp_data; - pose_graph_slam.is_optimize_point_to_projection_onto_plane_source_to_target_lie_algebra_right_jacobian = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 93; - append_to_result_file( - result_file, - "pose_graph_slam (point_to_projection_onto_plane_lie_algebra_right_jacobian)", - pose_graph_slam, - rms, - id_method, - elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); -} - -void perform_experiment_on_linux( - Session& session, - ObservationPicking& observation_picking, - ICP& icp, - NDT& ndt, - RegistrationPlaneFeature& registration_plane_feature, - PoseGraphSLAM& pose_graph_slam) -{ - fs::path path_result(session.working_directory); - path_result /= "results_linux"; - create_directory(path_result); - - session.point_clouds_container.show_with_initial_pose = false; - auto temp_data = session.point_clouds_container; - // reset_poses(); - float rms = 0.0f; - std::string result_file = session.working_directory + "/result_linux.csv"; - create_header(result_file); - double initial_rms = compute_rms(false, session, observation_picking); - std::cout << "initial rms: " << initial_rms << std::endl; - add_initial_rms_to_file(result_file, initial_rms); - - float search_radius = 0.1f; - int number_of_threads = 16; - int number_of_iterations = 6; - int id_method = 0; - - // pose graph slam - //--94-- - pose_graph_slam.overlap_threshold = 0.3; - pose_graph_slam.iterations = 6; - - pose_graph_slam.search_radius = search_radius; - pose_graph_slam.number_of_threads = number_of_threads; - pose_graph_slam.number_of_iterations_pair_wise_matching = number_of_iterations; - - //-- - pose_graph_slam.is_adaptive_robust_kernel = false; - pose_graph_slam.is_fix_first_node = true; - pose_graph_slam.is_gauss_newton = true; - pose_graph_slam.is_levenberg_marguardt = false; - pose_graph_slam.is_cw = false; - pose_graph_slam.is_wc = true; - pose_graph_slam.is_tait_bryan_angles = false; - pose_graph_slam.is_quaternion = false; - pose_graph_slam.is_rodrigues = true; - - session.point_clouds_container = temp_data; - - // pose_graph_slam.is_ndt = true; - // pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::general; - // pose_graph_slam.ndt_bucket_size[0] = ndt.bucket_size[0]; - // pose_graph_slam.ndt_bucket_size[1] = ndt.bucket_size[1]; - // pose_graph_slam.ndt_bucket_size[2] = ndt.bucket_size[2]; - // pose_graph_slam.optimize(point_clouds_container); - // rms = compute_rms(); - // id_method = 94; - // append_to_result_file(result_file, "pose_graph_slam (normal_distributions_transform)", pose_graph_slam, rms, id_method); - -#ifdef WITH_PCL - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_ndt = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_ndt; - - auto start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - auto end = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(end - start); - - rms = compute_rms(false, session, observation_picking); - id_method = 94; - append_to_result_file(result_file, "pose_graph_slam (pcl_ndt)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--95-- - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_icp = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_icp; - - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - - rms = compute_rms(false, session, observation_picking); - id_method = 95; - append_to_result_file(result_file, "pose_graph_slam (pcl_icp)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; -#endif - -#if WITH_GTSAM - //--96-- - try - { - pose_graph_slam.ndt_bucket_size[0] = ndt.bucket_size[0]; - pose_graph_slam.ndt_bucket_size[1] = ndt.bucket_size[1]; - pose_graph_slam.ndt_bucket_size[2] = ndt.bucket_size[2]; - - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_ndt = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_ndt; - - auto start = std::chrono::system_clock::now(); - pose_graph_slam.optimize_with_GTSAM(session.point_clouds_container); - auto end = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(end - start); - rms = compute_rms(false, session, observation_picking); - id_method = 96; - append_to_result_file(result_file, "pose_graph_slam (GTSAM pcl_ndt)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - } catch (std::exception& e) - { - std::cout << e.what() << std::endl; - rms = compute_rms(false, session, observation_picking); - // append_to_result_file(result_file, "pose_graph_slam (GTSAM pcl_ndt)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - } - //--97-- - try - { - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_icp = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_icp; - - auto start = std::chrono::system_clock::now(); - pose_graph_slam.optimize_with_GTSAM(session.point_clouds_container); - auto end = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(end - start); - - rms = compute_rms(false, session, observation_picking); - id_method = 97; - append_to_result_file(result_file, "pose_graph_slam (GTSAM pcl_icp)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - } catch (std::exception& e) - { - std::cout << e.what() << std::endl; - rms = compute_rms(false, session, observation_picking); - // append_to_result_file(result_file, "pose_graph_slam (GTSAM pcl_icp)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - } -#endif -#if WITH_MANIF - //--98-- - { - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_ndt = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_ndt; - - auto start = std::chrono::system_clock::now(); - pose_graph_slam.optimize_with_manif(session.point_clouds_container); - auto end = std::chrono::system_clock::now(); - auto elapsed = std::chrono::duration_cast(end - start); - - rms = compute_rms(false, session, observation_picking); - id_method = 98; - append_to_result_file(result_file, "pose_graph_slam (manif pcl_ndt)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - - //--99-- - pose_graph_slam.set_all_to_false(); - pose_graph_slam.is_optimize_pcl_icp = true; - pose_graph_slam.is_lie_algebra_right_jacobian = true; - pose_graph_slam.pair_wise_matching_type = PoseGraphSLAM::PairWiseMatchingType::pcl_icp; - - start = std::chrono::system_clock::now(); - pose_graph_slam.optimize_with_manif(session.point_clouds_container); - end = std::chrono::system_clock::now(); - elapsed = std::chrono::duration_cast(end - start); - - rms = compute_rms(false, session, observation_picking); - id_method = 99; - append_to_result_file(result_file, "pose_graph_slam (manif pcl_icp)", pose_graph_slam, rms, id_method, elapsed); - export_result_to_folder(path_result.string(), id_method, observation_picking, session); - session.point_clouds_container = temp_data; - } -#endif -} - -#if 0 -bool exportLaz(const std::string &filename, - const std::vector &pointcloud, - const std::vector &intensity, double offset_x, double offset_y, double offset_alt) -{ - - constexpr float scale = 0.0001f; // one tenth of milimeter - // find max - Eigen::Vector3d max(std::numeric_limits::lowest(), std::numeric_limits::lowest(), std::numeric_limits::lowest()); - Eigen::Vector3d min(std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()); - for (auto &p : pointcloud) - { - max.x() = std::max(max.x(), p.x()); - max.y() = std::max(max.y(), p.y()); - max.z() = std::max(max.z(), p.z()); - - min.x() = std::min(min.x(), p.x()); - min.y() = std::min(min.y(), p.y()); - min.z() = std::min(min.z(), p.z()); - } - - std::cout << "exportLaz to file: '" << filename << "'" << std::endl; - std::cout << std::setprecision(20) << "min.x " << min.x() << " " << max.x() << std::endl; - std::cout << "min.y " << min.y() << " " << max.y() << std::endl; - std::cout << "min.z " << min.z() << " " << max.z() << std::endl; - - // create the writer - laszip_POINTER laszip_writer; - if (laszip_create(&laszip_writer)) - { - spdlog::error("DLL ERROR: creating laszip writer"); - return false; - } - - // get a pointer to the header of the writer so we can populate it - - laszip_header *header; - - if (laszip_get_header_pointer(laszip_writer, &header)) - { - spdlog::error("DLL ERROR: getting header pointer from laszip writer"); - return false; - } - - // populate the header - - header->file_source_ID = 4711; - header->global_encoding = (1 << 0); // see LAS specification for details - header->version_major = 1; - header->version_minor = 2; - // header->file_creation_day = 120; - // header->file_creation_year = 2013; - header->point_data_format = 1; - header->point_data_record_length = 0; - header->number_of_point_records = pointcloud.size(); - header->number_of_points_by_return[0] = pointcloud.size(); - header->number_of_points_by_return[1] = 0; - header->point_data_record_length = 28; - header->x_scale_factor = scale; - header->y_scale_factor = scale; - header->z_scale_factor = scale; - - header->max_x = max.x() + offset_x; - header->min_x = min.x() + offset_x; - header->max_y = max.y() + offset_y; - header->min_y = min.y() + offset_y; - header->max_z = max.z() + offset_alt; - header->min_z = min.z() + offset_alt; - - header->x_offset = offset_x; - header->y_offset = offset_y; - header->z_offset = offset_alt; - - // optional: use the bounding box and the scale factor to create a "good" offset - // open the writer - laszip_BOOL compress = (strstr(filename.c_str(), ".laz") != 0); - - if (laszip_open_writer(laszip_writer, filename.c_str(), compress)) - { - spdlog::error("DLL ERROR: opening laszip writer for '{}'", filename ); - return false; - } - - spdlog::info("writing file '{}' {}compressed", filename, (compress ? "" : "un")); - - // get a pointer to the point of the writer that we will populate and write - - laszip_point *point; - if (laszip_get_point_pointer(laszip_writer, &point)) - { - spdlog::error("DLL ERROR: getting point pointer from laszip writer"); - return false; - } - - laszip_I64 p_count = 0; - laszip_F64 coordinates[3]; - - for (int i = 0; i < pointcloud.size(); i++) - { - point->intensity = intensity[i]; - - const auto &p = pointcloud[i]; - p_count++; - coordinates[0] = p.x();// + offset_x; - coordinates[1] = p.y();// + offset_y; - coordinates[2] = p.z();// + offset_alt; - if (laszip_set_coordinates(laszip_writer, coordinates)) - { - spdlog::error("DLL ERROR: setting coordinates for point {}", p_count); - return false; - } - - // p.SetIntensity(pp.intensity); - - // if (i < intensity.size()) { - // point->intensity = intensity[i]; - // } - // laszip_set_point - - if (laszip_write_point(laszip_writer)) - { - spdlog::error("DLL ERROR: writing point {}", p_count); - return false; - } - } - - if (laszip_get_point_count(laszip_writer, &p_count)) - { - spdlog::error("DLL ERROR: getting point count"); - return false; - } - - spdlog::info("successfully written {} points", p_count); - - // close the writer - - if (laszip_close_writer(laszip_writer)) - { - spdlog::error("DLL ERROR: closing laszip writer"); - return false; - } - - // destroy the writer - - if (laszip_destroy(laszip_writer)) - { - spdlog::error("DLL ERROR: destroying laszip writer"); - return false; - } - - std::cout << "exportLaz DONE" << std::endl; - return true; -} -#endif - -#if 0 -//void export_result_to_folder(std::string output_folder_name, ObservationPicking &observation_picking, Session &session); -void export_result_to_folder(std::string output_folder_name, ObservationPicking &observation_picking, Session &session) -{ - fs::path path(output_folder_name); - std::string file_name_rms = "rms.csv"; - auto path_rms = path; - path_rms /= file_name_rms; - std::cout << "exporting to file: '" << path_rms.string() << "'" << std::endl; - std::ofstream outfile_rms; - outfile_rms.open(path_rms, std::ios_base::app); - outfile_rms << "index_roi, rms_initial, rms_result" << std::endl; - - for (int i = 0; i < observation_picking.intersections.size(); i++) - { - std::string file_name_initial = "intersection_" + std::to_string(i) + "_initial.csv"; - std::string file_name_result = "intersection_" + std::to_string(i) + "_result.csv"; - - auto path_initial = path; - auto path_result = path; - - path_initial /= file_name_initial; - path_result /= file_name_result; - - std::cout << "exporting to file: '" << path_initial.string() << "'" << std::endl; - std::cout << "exporting to file: '" << path_result.string() << "'" << std::endl; - - std::ofstream outfile_initial; - std::ofstream outfile_result; - - outfile_initial.open(path_initial, std::ios_base::app); - outfile_result.open(path_result, std::ios_base::app); - - const auto &intersection = observation_picking.intersections[i]; - TaitBryanPose pose; - pose.px = intersection.translation[0]; - pose.py = intersection.translation[1]; - pose.pz = intersection.translation[2]; - pose.om = intersection.rotation[0]; - pose.fi = intersection.rotation[1]; - pose.ka = intersection.rotation[2]; - Eigen::Affine3d m_pose_inv = affine_matrix_from_pose_tait_bryan(pose).inverse(); - - double w = intersection.width_length_height[0] * 0.5; - double l = intersection.width_length_height[1] * 0.5; - double h = intersection.width_length_height[2] * 0.5; - - outfile_initial << "x;y;z;pc_index;is_initial;index_intersection;file" << std::endl; - outfile_result << "x;y;z;pc_index;is_initial;index_intersection;file" << std::endl; - - for (int pc_index = 0; pc_index < session.point_clouds_container.point_clouds.size(); pc_index++) - { - const auto &pc = session.point_clouds_container.point_clouds[pc_index]; - for (const auto &p : pc.points_local) - { - Eigen::Vector3d vpi = pc.m_initial_pose * p; - Eigen::Vector3d vpr = pc.m_pose * p; - - Eigen::Vector3d vpit = m_pose_inv * vpi; - Eigen::Vector3d vprt = m_pose_inv * vpr; - - if (fabs(vpit.x()) < w) - { - if (fabs(vpit.y()) < l) - { - if (fabs(vpit.z()) < h) - { - outfile_initial << vpit.x() << ";" << vpit.y() << ";" << vpit.z() << ";" << pc_index << ";1;" << i << ";" << pc.file_name << std::endl; - } - } - } - if (fabs(vprt.x()) < w) - { - if (fabs(vprt.y()) < l) - { - if (fabs(vprt.z()) < h) - { - outfile_result << vprt.x() << ";" << vprt.y() << ";" << vprt.z() << ";" << pc_index << ";0;" << i << ";" << pc.file_name << std::endl; - } - } - } - } - } - outfile_initial.close(); - outfile_result.close(); - - const auto &obs = observation_picking.observations[i]; - double rms_initial = 0.0; - int sum = 0; - double rms_result = 0.0; - - for (const auto &[key1, value1] : obs) - { - for (const auto &[key2, value2] : obs) - { - if (key1 != key2) - { - Eigen::Vector3d p1, p2; - p1 = session.point_clouds_container.point_clouds[key1].m_initial_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_initial_pose * value2; - rms_initial += (p2.x() - p1.x()) * (p2.x() - p1.x()); - rms_initial += (p2.y() - p1.y()) * (p2.y() - p1.y()); - - p1 = session.point_clouds_container.point_clouds[key1].m_pose * value1; - p2 = session.point_clouds_container.point_clouds[key2].m_pose * value2; - rms_result += (p2.x() - p1.x()) * (p2.x() - p1.x()); - rms_result += (p2.y() - p1.y()) * (p2.y() - p1.y()); - - sum += 2; - } - } - } - std::cout << "sum: " << sum << std::endl; - if (sum > 0) - { - rms_initial = sqrt(rms_initial / sum); - rms_result = sqrt(rms_result / sum); - outfile_rms << i << ";" << rms_initial << ";" << rms_result << std::endl; - } - } - outfile_rms.close(); - - std::string file_name_poses = "poses_RESSO.reg"; - auto path_poses = path; - path_poses /= file_name_poses; - std::cout << "saving poses to: " << path_poses << std::endl; - session.point_clouds_container.save_poses(path_poses.string(), false); -} - - -//void export_result_to_folder(std::string output_folder_name, ObservationPicking &observation_picking, Session &session) -void export_result_to_folder(std::string output_folder_name, int method_id, ObservationPicking &observation_picking) -{ - fs::path path(output_folder_name); - path /= std::to_string(method_id); - create_directory(path); - export_result_to_folder(path.string(), observation_picking); -} - -#endif \ No newline at end of file diff --git a/apps/multi_view_tls_registration_legacy/resource.h b/apps/multi_view_tls_registration_legacy/resource.h deleted file mode 100644 index 4f3204cae..000000000 --- a/apps/multi_view_tls_registration_legacy/resource.h +++ /dev/null @@ -1,17 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDI_ICON1 101 // application icon -#define VS_VERSION_INFO 1 // version info - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 106 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/apps/multi_view_tls_registration_legacy/resource.rc b/apps/multi_view_tls_registration_legacy/resource.rc deleted file mode 100644 index 77dce10d1..000000000 --- a/apps/multi_view_tls_registration_legacy/resource.rc +++ /dev/null @@ -1,49 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 0, 0, 100, 1 -PRODUCTVERSION 0, 0, 100, 1 -FILEFLAGSMASK 0x3fL -FILEOS 0x40004 -FILETYPE 0x1 -BEGIN -BLOCK "StringFileInfo" -BEGIN -BLOCK "040904B0" -BEGIN -VALUE "CompanyName", "Mandeye\0" -VALUE "FileDescription", "HDMapping Step 2\0" -VALUE "FileVersion", "0.100.1\0" -VALUE "InternalName", "Multi view TLS registration\0" -VALUE "LegalCopyright", "(c) 2026 github.com/MapsHD/HDMapping\0" -VALUE "OriginalFilename", "multi_view_tls_registration_step_2.exe\0" -VALUE "ProductVersion", "0.100.1\0" -VALUE "ProgramID", "github.com/MapsHD/HDMapping\0" -VALUE "ProductName", "HDMapping\0" -END -END -BLOCK "VarFileInfo" -BEGIN -VALUE "Translation", 0x409, 0x04B0 -END -END -///////////////////////////////////////////////////////////////////////////// \ No newline at end of file From 38e2be65cc4ecd1d8ad12dbe92b22f8b70a22ddc Mon Sep 17 00:00:00 2001 From: mwlasiuk Date: Fri, 27 Nov 2026 17:42:15 +0100 Subject: [PATCH 2/4] Remove legacy applications entries from cmake and deployment scripts --- CMakeLists.txt | 4 ---- deploy_mandeye.bat | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7995d7dd..afe6564a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,14 +142,10 @@ endif() # Applications for typical workflow - see images/workflow.png add_subdirectory(apps/mandeye_raw_data_viewer) -add_subdirectory(apps/mandeye_raw_data_viewer_legacy) add_subdirectory(apps/lidar_odometry_step_1) -add_subdirectory(apps/lidar_odometry_step_1_legacy) add_subdirectory(apps/mandeye_single_session_viewer) add_subdirectory(apps/multi_view_tls_registration) -add_subdirectory(apps/multi_view_tls_registration_legacy) add_subdirectory(apps/multi_session_registration) -add_subdirectory(apps/multi_session_registration_legacy) add_subdirectory(apps/session_uncertainty_calculation) add_subdirectory(apps/session_to_session_rigid_registration) add_subdirectory(apps/camera_lidar_trajectory_viewer) diff --git a/deploy_mandeye.bat b/deploy_mandeye.bat index dd2106c32..71db3e374 100644 --- a/deploy_mandeye.bat +++ b/deploy_mandeye.bat @@ -60,7 +60,7 @@ rem This list has to be kept in sync by hand with the hdmapping_install_app() rem calls in apps/*/CMakeLists.txt. hd_mapper is deliberately absent: it is rem gated behind BUILD_WITH_HD_MAPPER_APPLICATION, which defaults to OFF, so rem listing it would warn on every normal build. -set "EXPECTED=camera_lidar_calibration.exe camera_lidar_intrinsics_calib.exe camera_lidar_trajectory_viewer.exe concatenate_multi_livox.exe drag_folder_with_mandeye_data_and_drop_here-precision_forestry.exe laz_to_mcap.exe laz_to_pcd.exe laz_to_ply.exe laz_to_txt.exe lidar_odometry_step_1.exe lidar_odometry_step_1_legacy.exe livox_mid_360_intrinsic_calibration.exe mandeye_compare_trajectories.exe mandeye_mission_recorder_calibration.exe mandeye_raw_data_viewer.exe mandeye_raw_data_viewer_legacy.exe mandeye_single_session_viewer.exe matrix_mul.exe mcap_to_laz.exe multiply_timestamps_session_point_cloud_laz.exe multiply_timestamps_session_trajectory_csv.exe multi_session_registration_step_3.exe multi_session_registration_step_3_legacy.exe multi_view_tls_registration_step_2.exe multi_view_tls_registration_step_2_legacy.exe ouster_pcap_to_laz.exe pcd_to_laz.exe precision_forestry_tools.exe session_intensity_panoramas.exe session_to_mcap.exe split_multi_livox.exe freeglut.dll laszip3.dll opencv_world4130.dll proj_9_3.dll tbb12.dll z.dll" +set "EXPECTED=camera_lidar_calibration.exe camera_lidar_intrinsics_calib.exe camera_lidar_trajectory_viewer.exe concatenate_multi_livox.exe drag_folder_with_mandeye_data_and_drop_here-precision_forestry.exe laz_to_mcap.exe laz_to_pcd.exe laz_to_ply.exe laz_to_txt.exe lidar_odometry_step_1.exe livox_mid_360_intrinsic_calibration.exe mandeye_compare_trajectories.exe mandeye_mission_recorder_calibration.exe mandeye_raw_data_viewer.exe mandeye_single_session_viewer.exe matrix_mul.exe mcap_to_laz.exe multiply_timestamps_session_point_cloud_laz.exe multiply_timestamps_session_trajectory_csv.exe multi_session_registration_step_3.exe multi_view_tls_registration_step_2.exe ouster_pcap_to_laz.exe pcd_to_laz.exe precision_forestry_tools.exe session_intensity_panoramas.exe session_to_mcap.exe split_multi_livox.exe freeglut.dll laszip3.dll opencv_world4130.dll proj_9_3.dll tbb12.dll z.dll" set "MISSING=" for %%F in (%EXPECTED%) do ( From a5b0d3d30d8ca64a9bfb6f2a54eb2319fd8ea8bb Mon Sep 17 00:00:00 2001 From: mwlasiuk Date: Fri, 27 Nov 2026 17:45:39 +0100 Subject: [PATCH 3/4] Update comments --- apps/lidar_odometry_step_1/CMakeLists.txt | 3 --- apps/mandeye_raw_data_viewer/CMakeLists.txt | 2 -- cmake/raylib.cmake | 10 ++-------- core/src/raylib_render.cpp | 3 +-- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/apps/lidar_odometry_step_1/CMakeLists.txt b/apps/lidar_odometry_step_1/CMakeLists.txt index 518add39d..15054aa5c 100644 --- a/apps/lidar_odometry_step_1/CMakeLists.txt +++ b/apps/lidar_odometry_step_1/CMakeLists.txt @@ -38,9 +38,6 @@ add_executable( target_compile_definitions(lidar_odometry_step_1 PRIVATE WITH_GUI=1) target_apply_hdmapping_profiler(lidar_odometry_step_1) -# lidar_odometry_gui.cpp is raylib-based (ported off GLUT; the GLUT build is kept as -# apps/lidar_odometry_step_1_legacy): (core_raylib_utils) replaces -# with the same names, so only the GL calls changed. target_include_directories( lidar_odometry_step_1 PRIVATE include diff --git a/apps/mandeye_raw_data_viewer/CMakeLists.txt b/apps/mandeye_raw_data_viewer/CMakeLists.txt index f87435a42..b29c1027b 100644 --- a/apps/mandeye_raw_data_viewer/CMakeLists.txt +++ b/apps/mandeye_raw_data_viewer/CMakeLists.txt @@ -22,8 +22,6 @@ add_executable( mandeye_raw_data_viewer ${SOURCES} ) -# raylib-based (ported off GLUT; the GLUT build is kept as apps/mandeye_raw_data_viewer_legacy): -# (core_raylib_utils) replaces with the same names. target_include_directories( mandeye_raw_data_viewer PRIVATE include diff --git a/cmake/raylib.cmake b/cmake/raylib.cmake index 2f46fb3dc..9f0eb0b39 100644 --- a/cmake/raylib.cmake +++ b/cmake/raylib.cmake @@ -3,11 +3,6 @@ include_guard() # raylib + Dear ImGui + rlImGui, for the raylib-based step2 viewer # (apps/multi_view_tls_registration_raylib). Mirrors the integration pattern # established in the sibling mandeye-colors project. -# -# NOTE: cmake/imgui.cmake already defines a target named `imgui`, statically -# linked with the GLUT/OpenGL2 backend baked in for the legacy GLUT apps. -# That target cannot be reused here (rlImGui needs a plain ImGui core with no -# backend baked in), so this file builds a separate `imgui_raylib` target. include(FetchContent) @@ -50,11 +45,10 @@ add_library(imgui_raylib STATIC target_include_directories(imgui_raylib PUBLIC ${IMGUI_RAYLIB_DIR}) # 32-bit indices: rlImGui ignores ImDrawCmd::VtxOffset, so with 16-bit indices a # draw list over 65535 vertices (e.g. ImPlot lines of a long IMU log) wraps -# around and renders garbage. Same setting as the legacy `imgui` target. +# around and renders garbage. target_compile_definitions(imgui_raylib PUBLIC ImDrawIdx=unsigned\ int) # NOTE: deliberately NOT defining IMGUI_DISABLE_OBSOLETE_FUNCTIONS (unlike -# mandeye-colors) -- core's WITH_GUI=1 sources (manual_pose_graph_loop_closure.cpp -# etc, shared unchanged with the legacy GLUT app) call a few of ImGui's +# mandeye-colors) -- core's WITH_GUI=1 sources call a few of ImGui's # "obsolete" functions (e.g. SetWindowFontScale), which that flag compiles # out entirely (declaration included), breaking the link against core.a. diff --git a/core/src/raylib_render.cpp b/core/src/raylib_render.cpp index 56664f100..175a1f4b6 100644 --- a/core/src/raylib_render.cpp +++ b/core/src/raylib_render.cpp @@ -136,8 +136,7 @@ void ScanRenderer::rebuild(size_t index, const PointCloud& pc) // Every point in points_local is uploaded -- no stride/skip here, so // loading a session always renders it at full point density. // Session::load's own voxel-bucket decimation, controlled by the - // Settings panel's "Downsample during load" checkbox, is unrelated and - // untouched -- it's shared unchanged with the legacy GLUT app. + // Settings panel's "Downsample during load" checkbox, is unrelated. const bool hasIntensity = pc.intensities.size() == pc.points_local.size(); float minIntensity = std::numeric_limits::max(); float maxIntensity = -std::numeric_limits::max(); From 99a1ea4a6bda34a09dac9d20e9104468be633c22 Mon Sep 17 00:00:00 2001 From: mwlasiuk Date: Fri, 27 Nov 2026 17:48:02 +0100 Subject: [PATCH 4/4] Update docs --- AGENTS.md | 3 +-- doc/processing_report.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fc20f0732..357223aa0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,8 +11,7 @@ platforms, see "Platforms and portability" below. - `shared/include/HDMapping/`: header-only utilities (`Assert.h` with `HDMAPPING_ASSERT`, `PoseInterpolation.h`, `SessionPaths.h`). - `apps/`: the tools. Main workflow: `mandeye_raw_data_viewer`, `lidar_odometry_step_1`, `multi_view_tls_registration` - (step 2), `multi_session_registration` (step 3). The `*_legacy` apps are the GLUT versions kept next to the raylib - ports. New rendering work goes into the raylib code. + (step 2), `multi_session_registration` (step 3). New rendering work goes into the raylib code. - `3rdparty/`: git submodules built from source. `3rdpartyBinary/`: prebuilt OpenCV and PROJ. Both are wired up in `cmake/dependencies.cmake`. - `scripts/`: developer tooling, documented in `scripts/README.md`. diff --git a/doc/processing_report.md b/doc/processing_report.md index 5f2050ca2..8f97e6411 100644 --- a/doc/processing_report.md +++ b/doc/processing_report.md @@ -112,5 +112,4 @@ cleanup. Failed or cancelled runs write a diagnostic report when an output directory is available; an unwritable destination cannot retain its own failure report. Fatal process termination cannot guarantee finalization. -This change covers the raylib Step 1 workflow. Shared processing sources also -build for the older GLUT entry points, whose legacy UI is not redesigned here. +This change covers the raylib Step 1 workflow.