From af6c6b5e0d323ff2e8d539dee2131f59d7500747 Mon Sep 17 00:00:00 2001 From: Alvaro Gaona Date: Thu, 1 Jan 2026 18:08:05 +0100 Subject: [PATCH 1/2] fix: replace forward references with header file Forward references for GSTAM are aliases rather than classes. Defining them as forward reference clases require unnecessary processing. Better to use header files. --- include/glim/mapping/sub_mapping.hpp | 2 +- include/glim/odometry/odometry_estimation_imu.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/glim/mapping/sub_mapping.hpp b/include/glim/mapping/sub_mapping.hpp index 2ac38b24..bc111f78 100644 --- a/include/glim/mapping/sub_mapping.hpp +++ b/include/glim/mapping/sub_mapping.hpp @@ -5,11 +5,11 @@ #include #include #include +#include namespace gtsam { class Values; class NonlinearFactorGraph; -class PreintegratedImuMeasurements; } // namespace gtsam namespace glim { diff --git a/include/glim/odometry/odometry_estimation_imu.hpp b/include/glim/odometry/odometry_estimation_imu.hpp index 96b4b0ab..72c5f346 100644 --- a/include/glim/odometry/odometry_estimation_imu.hpp +++ b/include/glim/odometry/odometry_estimation_imu.hpp @@ -7,11 +7,11 @@ #include #include #include +#include namespace gtsam { class Pose3; class Values; -class ImuFactor; class NonlinearFactorGraph; } // namespace gtsam From 121e5bdeaf525df056e0b2c446b274725015d6e6 Mon Sep 17 00:00:00 2001 From: Alvaro Gaona Date: Tue, 27 Jan 2026 16:44:11 +0100 Subject: [PATCH 2/2] fix: replace forward declarations with proper includes - Replace forward declarations with actual includes in callbacks.hpp, sub_mapping.hpp, data_validator.hpp, and interactive_viewer.hpp - Add proper GTSAM includes instead of relying on forward declarations - Fix smart pointer dereference in odometry logging - Improve type safety in convert_to_string with size_t and vector specialization --- include/glim/mapping/callbacks.hpp | 4 ++-- include/glim/mapping/sub_mapping.hpp | 16 +++++----------- include/glim/util/convert_to_string.hpp | 16 +++++++++++++++- include/glim/util/data_validator.hpp | 5 ++--- include/glim/viewer/interactive_viewer.hpp | 7 ++----- src/glim/odometry/odometry_estimation_ct.cpp | 2 +- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/include/glim/mapping/callbacks.hpp b/include/glim/mapping/callbacks.hpp index 0abfff1d..6c9db178 100644 --- a/include/glim/mapping/callbacks.hpp +++ b/include/glim/mapping/callbacks.hpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #ifdef GLIM_USE_OPENCV namespace cv { @@ -16,8 +18,6 @@ class NonlinearFactorGraph; } // namespace gtsam namespace gtsam_points { -class ISAM2Ext; -class ISAM2ResultExt; class LevenbergMarquardtOptimizationStatus; } // namespace gtsam_points diff --git a/include/glim/mapping/sub_mapping.hpp b/include/glim/mapping/sub_mapping.hpp index bc111f78..de6f8d09 100644 --- a/include/glim/mapping/sub_mapping.hpp +++ b/include/glim/mapping/sub_mapping.hpp @@ -1,23 +1,17 @@ #pragma once -#include -#include #include #include #include +#include +#include +#include #include - -namespace gtsam { -class Values; -class NonlinearFactorGraph; -} // namespace gtsam +#include +#include namespace glim { -class IMUIntegration; -class CloudDeskewing; -class CloudCovarianceEstimation; - /** * @brief Sub mapping parameters */ diff --git a/include/glim/util/convert_to_string.hpp b/include/glim/util/convert_to_string.hpp index 1249bf38..88d4060f 100644 --- a/include/glim/util/convert_to_string.hpp +++ b/include/glim/util/convert_to_string.hpp @@ -19,7 +19,7 @@ template std::string convert_to_string(const std::vector& values) { std::stringstream sst; sst << "["; - for (int i = 0; i < values.size(); i++) { + for (size_t i = 0; i < values.size(); i++) { if (i) { sst << ","; } @@ -29,6 +29,20 @@ std::string convert_to_string(const std::vector& values) { return sst.str(); } +template <> +inline std::string convert_to_string(const std::vector& values) { + std::stringstream sst; + sst << "["; + for (size_t i = 0; i < values.size(); i++) { + if (i) { + sst << ","; + } + sst << convert_to_string(static_cast(values[i])); + } + sst << "]"; + return sst.str(); +} + template std::string convert_to_string(const Eigen::Matrix& value) { std::stringstream sst; diff --git a/include/glim/util/data_validator.hpp b/include/glim/util/data_validator.hpp index 9314de04..e73133b2 100644 --- a/include/glim/util/data_validator.hpp +++ b/include/glim/util/data_validator.hpp @@ -3,12 +3,11 @@ #include #include #include +#include +#include namespace glim { -class RawPoints; -class TimeKeeper; - class DataValidator { public: DataValidator(bool debug = false); diff --git a/include/glim/viewer/interactive_viewer.hpp b/include/glim/viewer/interactive_viewer.hpp index fd6fa8dc..27b3ed63 100644 --- a/include/glim/viewer/interactive_viewer.hpp +++ b/include/glim/viewer/interactive_viewer.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include namespace spdlog { @@ -23,11 +25,6 @@ class NonlinearFactor; class NonlinearFactorGraph; } // namespace gtsam -namespace gtsam_points { -class ISAM2Ext; -class ISAM2ResultExt; -} // namespace gtsam_points - namespace glim { class TrajectoryManager; diff --git a/src/glim/odometry/odometry_estimation_ct.cpp b/src/glim/odometry/odometry_estimation_ct.cpp index 8c34db77..00386710 100644 --- a/src/glim/odometry/odometry_estimation_ct.cpp +++ b/src/glim/odometry/odometry_estimation_ct.cpp @@ -121,7 +121,7 @@ EstimationFrame::ConstPtr OdometryEstimationCT::insert_frame(const PreprocessedF gtsam::Vector6 last_twist = gtsam::Vector6::Zero(); if (current >= 2) { if (!frames[last] || !frames[last - 1]) { - logger->warn("neither frames[last]={} nor frames[last - 1]={} is released!!", fmt::ptr(frames[last]), fmt::ptr(frames[last - 1])); + logger->warn("neither frames[last]={} nor frames[last - 1]={} is released!!", fmt::ptr(frames[last].get()), fmt::ptr(frames[last - 1].get())); logger->warn("there might be a large time gap between point cloud frames"); } else { const double delta_time = (frames[last]->stamp + frames[last]->frame->times[frames[last]->frame->size() - 1]) - frames[last - 1]->stamp;