namespace mola
Overview
@file VizInterface.cpp @brief Virtual visualization interface (see MolaViz) @author Jose Luis Blanco Claraco @date Feb 15, 2026
namespace mola { // namespaces namespace mola::detail; namespace mola::factors; namespace mola::gui; namespace mola::kf_cli; namespace mola::state_estimation_simple; namespace mola::state_estimation_smoother; // typedefs typedef std::allocator<T> FastAllocator; typedef std::set<T, Compare, FastAllocator<T>> fast_set; typedef std::map<Key, T, Compare, FastAllocator<std::pair<const Key, T>>> fast_map; typedef std::uint64_t id_t; typedef std::uint64_t fid_t; typedef mrpt::system::CTimeLogger Profiler; typedef mrpt::system::CTimeLoggerEntry ProfilerEntry; typedef mrpt::system::CTimeLoggerSaveAtDtor ProfilerSaverAtDtor; typedef mrpt::poses::CPose3DInterpolator trajectory_t; typedef mrpt::obs::CObservation CObservation; typedef std::size_t timestep_t; typedef mrpt::containers::yaml Yaml; typedef std::variant<std::monostate, SensorCamera, SensorIMU> SensorEntry; typedef uint64_t euroc_timestamp_t; typedef std::multimap<euroc_timestamp_t, SensorEntry> euroc_dataset_t; // enums enum DiagnosticLevel; enum InitLocalization; enum InputMode; // structs struct AddGNSSFactorParams; struct AddIMUAttitudeFactorParams; struct AddIMUGravityFactorParams; struct ConsoleLogEntry; struct DiagnosticKeyValue; struct DiagnosticStatusMsg; struct FrameGNSS; struct FrameIMU; struct FrameIMUAcc; struct GNSSFrames; struct Georeferencing; struct IMUAccFrames; struct IMUFrames; struct MetricSample; struct NavState; struct RelocalizationICP_SE2; struct RelocalizationLikelihood_SE2; struct SMGeoReferencingOutput; struct SMGeoReferencingParams; struct SensorCamera; struct SensorIMU; struct YAMLParseOptions; template <typename cell_coord_t = int32_t> struct index3d_hash; template <typename cell_coord_t = int32_t> struct index3d_t; template <typename cell_coord_t = int32_t> struct index_se3_t; template <typename cell_coord_t = int32_t> struct index_se3_t_hash; template <class... Ts> struct overloaded; // classes class BinFileDataset; class BridgeROS2; class ConsoleLogSink; class Dataset_UI; class DiagnosticsProvider; class EurocDataset; class ExecutableBase; class FilterBase; template <typename T, size_t SIDE_NUM_BITS, typename inner_coord_t> class FixedDenseGrid3D; class FrontEndBase; class GravityMapAligner; class HashedSetSE3; class HashedVoxelPointCloud; class KeyframeMapCapable; class KeyframePointCloudMap; class Kitti360Dataset; class KittiOdometryDataset; class LidarOdometry; class LocalizationSourceBase; class MapServer; class MapSourceBase; class MetricChannel; class MetricChannelImpl; class MetricsRegistry; class MinimalModuleContainer; class MockDiagModule; class MolaLauncherApp; class MolaViz; class MolaVizImGui; class MolaVizImGuiCore; class MulranDataset; class NDT; class NavStateFilter; class OccGrid; class OfflineDatasetSource; class OptionsCapable; class ParisLucoDataset; class RawDataConsumer; class RawDataSourceBase; class RawlogDataset; class RegexCache; class Relocalization; class Rosbag2Dataset; class SearchablePoseList; class SharedKeyframeMap; class SparseTreesPointCloud; class SparseVoxelPointCloud; class Synchronizer; class TrajectoryRebaker; class VideoDataset; class VizInterface; // global variables constexpr id_t INVALID_ID = std::numeric_limits<id_t>::max(); constexpr fid_t INVALID_FID = std::numeric_limits<fid_t>::max(); // global functions void pretty_print_exception( const std::exception& e, const std::string& headerLine, const bool use_std_cerr = true ); template <class... Ts> overloaded(Ts...); template <typename cell_coord_t> std::ostream& operator << ( std::ostream& o, const index3d_t<cell_coord_t>& idx ); void exportLoadableOptionsToIni( const mrpt::config::CLoadableOptions& opts, mrpt::config::CConfigFileBase& cfg, const std::string& section, const std::set<std::string>& excludeKeys = {} ); bool importLoadableOptionsFromIni( mrpt::config::CLoadableOptions& opts, const mrpt::config::CConfigFileBase& cfg, const std::string& section ); bool exportMapLayerOptionsToIni( mrpt::maps::CMetricMap& map, mrpt::config::CConfigFileBase& cfg, const std::string& layerName ); bool importMapLayerOptionsFromIni( mrpt::maps::CMetricMap& map, const mrpt::config::CConfigFileBase& cfg, const std::string& layerName, std::vector<std::string>* appliedSections = nullptr, std::vector<std::string>* rejectedSections = nullptr ); template <typename cell_coord_t> std::ostream& operator << ( std::ostream& o, const index_se3_t<cell_coord_t>& idx ); auto find_best_poses_se2(const mrpt::poses::CPosePDFGrid& grid, const double percentile = 0.99); std::string parse_yaml(const std::string& text, const YAMLParseOptions& opts = YAMLParseOptions()); mrpt::containers::yaml parse_yaml(const mrpt::containers::yaml& input, const YAMLParseOptions& opts = YAMLParseOptions()); mrpt::containers::yaml load_yaml_file(const std::string& fileName, const YAMLParseOptions& opts = YAMLParseOptions()); std::string yaml_to_string(const mrpt::containers::yaml& cfg); template <std::size_t N, typename T> constexpr std::array<T, N> create_array(const T& value); SMGeoReferencingOutput simplemap_georeference(const mrpt::maps::CSimpleMap& sm, const SMGeoReferencingParams& params = {}); mp2p_icp::metric_map_t::Georeferencing recenter_georeference( const mp2p_icp::metric_map_t::Georeferencing& in, const mrpt::math::TPoint3D& desiredEnuToMapTranslation ); GNSSFrames extract_gnss_frames_from_sm( const mrpt::maps::CSimpleMap& sm, const std::optional<mrpt::topography::TGeodeticCoords>& refCoord = std::nullopt, unsigned int minimumFixQuality = 0 ); IMUFrames extract_imu_frames_from_sm(const mrpt::maps::CSimpleMap& sm); void add_imu_gravity_factors( gtsam::NonlinearFactorGraph& fg, gtsam::Values& v, const IMUFrames& imuFrames, const std::set<size_t>& existingPoseKeys, const AddIMUGravityFactorParams& params ); void add_imu_attitude_factors( gtsam::NonlinearFactorGraph& fg, gtsam::Values& v, const IMUFrames& imuFrames, const std::set<size_t>& existingPoseKeys, const AddIMUAttitudeFactorParams& params ); void add_gnss_factors( gtsam::NonlinearFactorGraph& fg, gtsam::Values& v, const GNSSFrames& frames, const AddGNSSFactorParams& params ); IMUAccFrames extract_imu_acc_frames_from_sm(const mrpt::maps::CSimpleMap& sm); } // namespace mola
Typedefs
typedef mrpt::poses::CPose3DInterpolator trajectory_t
We reuse mrpt::poses::CPose3DInterpolator as a time-indexed map of SE(3) poses
typedef std::size_t timestep_t
0-based indices of observations in a dataset
typedef mrpt::containers::yaml Yaml
Convenient typedef to save typing in the MOLA project.
Global Functions
template <class... Ts> overloaded(Ts...)
Based on https://en.cppreference.com/w/cpp/utility/variant/visit
void exportLoadableOptionsToIni( const mrpt::config::CLoadableOptions& opts, mrpt::config::CConfigFileBase& cfg, const std::string& section, const std::set<std::string>& excludeKeys = {} )
Dumps all parameters of opts (via its dumpToTextStream(), which all known CLoadableOptions implement) as key = value entries under section in cfg.
This indirect route (instead of calling saveToConfigFile() directly) is needed because several CLoadableOptions subclasses in this library (and in MRPT itself) only override dumpToTextStream(), not saveToConfigFile(), which would otherwise throw.
Any key listed in excludeKeys is skipped entirely (neither written nor overwritten), which is used to work around individual fields whose dumpToTextStream()/loadFromConfigFile() pair is known to be inconsistent in some MRPT classes (e.g. unit mismatches, or values that get truncated for display and can no longer be parsed back). Importing such a field then simply leaves it at whatever value it already had.
bool importLoadableOptionsFromIni( mrpt::config::CLoadableOptions& opts, const mrpt::config::CConfigFileBase& cfg, const std::string& section )
If section exists in cfg, calls opts.loadFromConfigFile() on it and returns true. Otherwise leaves opts untouched and returns false.
bool exportMapLayerOptionsToIni( mrpt::maps::CMetricMap& map, mrpt::config::CConfigFileBase& cfg, const std::string& layerName )
Exports all CLoadableOptions structures of map into cfg, one section per structure, named "<layerName>.<structName>". If map implements mola::OptionsCapable, the set of structures (and their names) is obtained generically via OptionsCapable::optionsByName() this covers all classes in this library, present and future, without needing per-class code here. Otherwise, a fallback handles basic mrpt::maps classes (CPointsMap and derivatives, COccupancyGridMap2D) via dynamic_cast.
Also writes a [<layerName>] section with a class key holding the MRPT RTTI class name, used by importMapLayerOptionsFromIni() as a sanity check.
Returns:
false if map is none of the known, supported classes (nothing is written).
bool importMapLayerOptionsFromIni( mrpt::maps::CMetricMap& map, const mrpt::config::CConfigFileBase& cfg, const std::string& layerName, std::vector<std::string>* appliedSections = nullptr, std::vector<std::string>* rejectedSections = nullptr )
The reverse of exportMapLayerOptionsToIni() : for each of map ‘s CLoadableOptions structures whose section is present in cfg, loads it from cfg into map.
Sections absent from cfg are silently skipped, leaving the corresponding options untouched. Names of the sections actually applied are appended to appliedSections, if provided.
The “creationOptions” structure (if present) is handled specially: instead of being overwritten directly, the new values are passed to OptionsCapable::trySetCreationOptions(), which may refuse to apply them (e.g. a voxel size change that would require discarding the map’s current contents). Section names refused this way are appended to rejectedSections, if provided, instead of appliedSections.
Returns:
false if map is none of the known, supported classes (nothing is read).
SMGeoReferencingOutput simplemap_georeference(const mrpt::maps::CSimpleMap& sm, const SMGeoReferencingParams& params = {})
Function to georeferencing a given SimpleMap with GNSS observations. A minimum of 3 (non-colinear) KFs with GNSS data are required to solve for the optimal transformation.
mp2p_icp::metric_map_t::Georeferencing recenter_georeference( const mp2p_icp::metric_map_t::Georeferencing& in, const mrpt::math::TPoint3D& desiredEnuToMapTranslation )
Re-datums a geo-referencing so that its T_enu_to_map has exactly the given translation, shifting the geodetic datum (geo_coord) accordingly so that the map <-> geodetic mapping is left completely unchanged. Since the local ENU axes rotate as the datum moves on the curved Earth, the rotation of T_enu_to_map is only approximately preserved (exactly so for small datum shifts); the 6D covariance is propagated accordingly, not just copied.
The ENU frame origin (datum) ends up placed at the map point located at desiredEnuToMapTranslation (since T_enu_to_map maps ENU (0,0,0) to its own translation).
This is useful to force the ENU origin to a chosen map location (e.g. the map origin, passing {0,0,0}) instead of the arbitrary first-GNSS position, which may be several meters from the map origin and make it awkward to pick an initial pose for localization.
Parameters:
in |
The input geo-referencing (datum + T_enu_to_map). |
desiredEnuToMapTranslation |
The desired translation of T_enu_to_map. |
Returns:
The re-datumed, geometrically-equivalent geo-referencing.
IMUFrames extract_imu_frames_from_sm(const mrpt::maps::CSimpleMap& sm)
Single pass over the simplemap collecting both gravity (accelerometer) and absolute-attitude (orientation) observations per keyframe.
void add_imu_gravity_factors( gtsam::NonlinearFactorGraph& fg, gtsam::Values& v, const IMUFrames& imuFrames, const std::set<size_t>& existingPoseKeys, const AddIMUGravityFactorParams& params )
Adds MeasuredGravityFactor factors to the graph. Creates new P(kf_index) variables for keyframes not already present in existingPoseKeys.
void add_imu_attitude_factors( gtsam::NonlinearFactorGraph& fg, gtsam::Values& v, const IMUFrames& imuFrames, const std::set<size_t>& existingPoseKeys, const AddIMUAttitudeFactorParams& params )
Adds Pose3RotationFactor factors to the graph. Creates new P(kf_index) variables for keyframes not already present in existingPoseKeys.
IMUAccFrames extract_imu_acc_frames_from_sm(const mrpt::maps::CSimpleMap& sm)
Deprecated Use extract_imu_frames_from_sm() instead, which also extracts absolute-attitude readings alongside gravity ones. This wrapper is kept for backward compatibility and simply forwards to it, returning only the gravity (accelerometer) subset.