Georeferencing

Geo-referencing, i.e. finding the transformation between a map and the Earth (latitude, longitude and height), can be done live, while the vehicle moves, or afterwards on a recorded map. Both are implemented in the mola_state_estimation package.

The concept of using simple-maps as intermediary map format together with the layered metric map format (see [BC25]) enables embedding georeferenced coordinates to any kind of map typically used in robotics: grid maps, voxel maps, point clouds, etc.


https://mrpt.github.io/imgs/kaist01_georef_sample.png

Frames for geo-referenced maps

When working with ROS tf (transformations), MOLA packages use the following frame convention, which extends the standard REP-105 with additional enu and utm frames:

https://mrpt.github.io/imgs/mola_mrpt_ros_geo_referenced_utm_frames.png

The existing frames are explained here.


Live geo-referencing, without a prebuilt map

Based on the smoother state estimator, this solution allows to localize a vehicle in geodetic or UTM coordinates without the need of a prebuilt map.

MOLA-LO runs in mapping mode with a local map that follows the vehicle (old points are dropped, so memory and run time stay bounded however long the session is), and its poses go to the smoother state estimator as one more odometry, together with wheel odometry, an IMU and a GNSS receiver. The smoother corrects the drift of the LiDAR odometry with GNSS, bridges GNSS outages (under trees, indoors) with the LiDAR and wheel odometry, and estimates the geo-reference (\(T_{\text{enu}}^{\text{map}}\)) online. The result is a pose that is locally as smooth as LiDAR odometry and globally as accurate as the GNSS, given both in the map frame (where the vehicle started) and in latitude/longitude, e.g. to give navigation goals on satellite imagery.

How the sources are combined

  • LiDAR odometry publishes its poses in its own frame (mola_lo_reference_frame:=lidar_odom), so the smoother fuses only their increments, with the accuracy relative_pose_increment_sigma_lin/ang (MOLA_REL_POSE_INCR_SIGMA_LIN/ANG, per pose, as a random walk), and estimates how that frame drifts with respect to map. Its local map is not geo-referenced and never needs to be: use a local map class with a maximum size, e.g. mola::IncrementalPointCloud (the default of the GICP pipelines; MOLA_INCREMENTAL_MAP_MAX_SIZE in meters).

  • Wheel odometry (odom_topic_name) is better forwarded as planar odometry (MOLA_ODOM_AS_ROBOT_POSE_OBS=false), so the smoother weights it with its own motion model (odom_motion_model_a1..a4: error proportional to distance and rotation) instead of the much tighter LiDAR odometry increment sigmas, which would let wheel slippage (skid-steer turns!) drag the heading.

  • IMU: the LiDAR IMU de-skews scans (use_imu_for_lio:=True) and gives gravity. An optional absolute attitude IMU (AHRS with magnetometer, attitude_imu_topic_name) gives an azimuth before the vehicle moves; give it a realistic sigma (MOLA_IMU_ATTITUDE_SIGMA) and an azimuth bias state (MOLA_IMU_ATTITUDE_YAW_BIAS_SIGMA), since magnetometers often carry a few degrees of bias. Its sigma also applies to roll and pitch, which on a vehicle that accelerates or vibrates follow those accelerations: with an accurate (RTK) receiver it may be better left out, and the azimuth then comes from the GNSS track once the vehicle moves (see below). With a consumer receiver (meters of noise) the GNSS baseline needed is long (tens of meters), so an attitude IMU is worth having.

  • GNSS (gnss_mode:=live_georef, gnss_topic_name): each fix is an ENU position factor with a robust (Huber) kernel. Its NavSatFix covariance must reflect the real accuracy: some receivers report centimeter-level sigmas also in RTK float or DGNSS solutions, which are tens of centimeters or meters off. Republish them with a covariance per solution type if needed (e.g. at least 3 cm for RTK fixed, 0.5 m for RTK float, 3 m otherwise). The antenna position on the vehicle (lever arm) comes from /tf: measure or calibrate it, since with the antenna high above the vehicle frame, tilting moves it.

Geo-reference convergence: the map frame is the first vehicle pose. The geo-reference is published once its uncertainty is below MOLA_SE_CONVERGENCE_POS_SIGMA (m) and MOLA_SE_CONVERGENCE_ORI_SIGMA (deg). With an attitude IMU and RTK, that takes about a second. Without attitude, the azimuth is unknown until the GNSS fixes span a baseline of about \(\sqrt{2}\,\sigma_{xy} / \sigma_{\text{conv}}\) (0.5 m with 3 cm fixes and 5 deg): drive a few meters.

Outputs (besides the usual ones, see ROS 2 API):

  • /tf: map -> odom, straight from the smoother estimate of the wheel odometry frame (localization_publish_tf_source:=state_estimation/map_odom and MOLA_PUBLISH_MAP_TO_ODOM_TF, see TF frames), so the robot odom -> base_link chain is kept (REP 105); and, once converged, enu -> map and enu -> utm.

  • state_estimator/geo_ref_metadata (mrpt_nav_interfaces/GeoreferencingMetadata, transient local): the geo-reference (ENU origin latitude/longitude/height, \(T_{\text{enu}}^{\text{map}}\), UTM zone).

  • state_estimation/geo_pose (geographic_msgs/GeoPoseStamped): the vehicle pose in latitude, longitude and height, with its ENU orientation.

  • state_estimation/pose (nav_msgs/Odometry): the fused pose in map.

A goal given in latitude/longitude can be converted to the map frame with the geo-reference (geodetic to ENU at its origin, then \((T_{\text{enu}}^{\text{map}})^{-1}\)), or sent in the enu frame to a planner that transforms goals with /tf.

Example, for a vehicle with an Ouster LiDAR, wheel odometry on /odom (odom -> base_link on /tf), an AHRS on /imu_ahrs and a GNSS on /gps (with an RTK receiver, consider dropping the AHRS lines, see above):

MOLA_INCREMENTAL_MAP_MAX_SIZE=60.0 \
MOLA_REL_POSE_INCR_SIGMA_LIN=0.005 MOLA_REL_POSE_INCR_SIGMA_ANG=0.0005 \
MOLA_ODOM_AS_ROBOT_POSE_OBS=false \
MOLA_PUBLISH_MAP_TO_ODOM_TF=true \
MOLA_MAP_TO_ODOM_FRAME=odom_wheels MOLA_MAP_TO_ODOM_CHILD_FRAME=odom \
MOLA_IMU_ATTITUDE_SIGMA=3.0 MOLA_IMU_ATTITUDE_YAW_BIAS_SIGMA=10.0 \
ros2 launch mola_lidar_odometry ros2-lidar-odometry.launch.py \
  mola_lo_pipeline:=$(ros2 pkg prefix mola_lidar_odometry)/share/mola_lidar_odometry/pipelines/lidar3d-gicp.yaml \
  lidar_topic_name:=/ouster/points \
  imu_topic_name:=/ouster/imu use_imu_for_lio:=True \
  use_state_estimator:=True \
  gnss_mode:=live_georef gnss_topic_name:=/gps \
  attitude_imu_topic_name:=/imu_ahrs \
  odom_topic_name:=/odom \
  mola_lo_reference_frame:=lidar_odom \
  publish_localization_following_rep105:=True \
  localization_publish_tf_source:=state_estimation/map_odom

MOLA_MAP_TO_ODOM_FRAME is the smoother name of the wheel odometry source (odom_sensor_label, default odom_wheels) and MOLA_MAP_TO_ODOM_CHILD_FRAME the /tf frame its driver publishes odom -> base_link for. Without wheel odometry, drop those variables and odom_topic_name, use localization_publish_tf_source:=state_estimation and set publish_localization_following_rep105:=False (map -> base_link): with REP-105 on and no odom frame, the ROS 2 bridge has no odom -> base_link to compose with.

Expected accuracy: on an outdoor skid-steer ground robot at ~1 m/s with an RTK receiver whose fixes fell back to float or no-RTK for 1-2 minutes at a time under trees, replays against an RTK-aligned LiDAR odometry trajectory gave ~6 cm horizontal error with RTK fixed and ~12 cm median through the outages (where the raw fixes were 0.5-2 m off), with ~1 deg heading error, without the AHRS (with it: ~11 and ~27 cm). With a consumer (non-RTK) receiver the geo-reference inherits its bias (meters), while the trajectory stays locally as accurate as the LiDAR odometry.


Geo-referencing a map afterwards

A map built without live geo-referencing can be geo-referenced afterwards, if its keyframes carry GNSS readings (see Record a map to geo-reference it afterwards), with these applications:

mola-sm-georeferencing: optimal geo-referencing

This program finds the optimal geo-referencing parameters for a map.

First, build a simple-map from a dataset or a live robot as described in Build a map. Make sure of having a GPS (GNSS) sensor source emitting observations, and that they were captured by MOLA-LO (see the corresponding variable in the LO pipeline).

Then, build the corresponding metric map by applying a metric map generation pipeline (see [BC25]) or this step in the tutorial:

# Build metric map (mm) from simplemap (sm):
sm2mm -i datasetWithGPS.simplemap -o myMap.mm -p sm2mm_pipeline.yaml

Now, to find out the optimized map-to-ENU transformation and write it into the map file, use:

# georeference it:
mola-sm-georeferencing -i datasetWithGPS.simplemap --write-into myMap.mm

Alternatively, the georeferencing metadata can also be stored independently of a metric map in a standalone file. Two output formats are supported:

# Binary gzip format (compact, suitable for archiving):
mola-sm-georeferencing -i datasetWithGPS.simplemap -o myMap.georef

# YAML format (human-readable, easy to inspect or edit):
mola-sm-georeferencing -i datasetWithGPS.simplemap -o myMap.yaml

The output format is selected automatically from the file extension: *.georef produces a binary gzip file, while *.yaml or *.yml (or any other extension) produces a human-readable YAML file. Both formats are accepted by all other MOLA/mp2p_icp tools that consume georeferencing data (e.g. sm2mm --georef, mm-georef, mola-trajectory-georef).

Note

If neither --write-into nor -o is provided, the tool will print a warning and discard the computed result. Always supply at least one output destination.

Full CLI reference
USAGE:

   mola-sm-georeferencing  [-v <INFO>] [--no-imu-gravity] [-l <foobar.so>]
                           [--min-gnss-fix-quality <0>]
                           [--min-gnss-sigma <0.20>]
                           [--imu-gravity-sigma-deg <3.0>]
                           [--horizontality-sigma <1.0>]
                           [-o <(map.georef|map.yaml)>]
                           [--write-into <map.mm>] -i <map.simplemap> [--]
                           [--version] [-h]


Where:

   -v <INFO>,  --verbosity <INFO>
   Verbosity level: ERROR|WARN|INFO|DEBUG (Default: INFO)

   --no-imu-gravity
   Disable using IMU acceleration data for gravity alignment (enabled by
   default).

   -l <foobar.so>,  --load-plugins <foobar.so>
   One or more (comma separated) *.so files to load as plugins, e.g.
   defining new CMetricMap classes

   --min-gnss-fix-quality <0>
   If non-zero, discard GNSS frames whose NMEA GGA fix quality is below
   this value (1=GPS, 2=DGPS, 4=RTK fixed, 5=RTK float). Default: 0
   (filter disabled).

   --min-gnss-sigma <0.20>
   Minimum per-axis GNSS uncertainty (meters) used as a floor for the ENU
   noise model. Default: 0.20

   --imu-gravity-sigma-deg <3.0>
   IMU gravity alignment uncertainty (degrees).

   --horizontality-sigma <1.0>
   For short trajectories (not >10x the GPS uncertainty), this helps to
   avoid degeneracy.

   -o <(map.georef|map.yaml)>,  --output <(map.georef|map.yaml)>
   Write the obtained georeferencing metadata to a file. The format is
   determined by the file extension: binary gzip (``*.georef``) or YAML
   (``*.yaml``, ``*.yml``). Both formats are accepted by all MOLA/mp2p_icp
   tools that consume georeferencing data.

   --write-into <map.mm>
   An existing .mm file in which to write the georeferencing metadata

   -i <map.simplemap>,  --input <map.simplemap>
   (required)  Input .simplemap file

   --,  --ignore_rest
   Ignores the rest of the labeled arguments following this flag.

   --version
   Displays version information and exits.

   -h,  --help
   Displays usage information and exits.

mola-trajectory-georef: georeferenced trajectories

Once you already have a trajectory file in the local map frame of reference, for example, as generated by MOLA-LO in TUM format, and after georeferencing the generated map as shown above, you can use the CLI tool mola-trajectory-georef to convert it into geodetic coordinates, for example in KML format suitable for visualization in Google Earth.

Full CLI reference
USAGE:

   mola-trajectory-georef  -o <path.kml> -t <traj.tum> [-g <map.georef>]
                           [-m <map.mm>] [--] [--version] [-h]


Where:

   -o <path.kml>,  --output <path.kml>
   (required)  The name of the google earth kml file to write to

   -t <traj.tum>,  --trajectory <traj.tum>
   (required)  Input .tum trajectory, in map local coordinates

   -g <map.georef>,  --geo-ref <map.georef>
   Input .georef file with georef info

   -m <map.mm>,  --map <map.mm>
   Input .mm map with georef info

   --,  --ignore_rest
   Ignores the rest of the labeled arguments following this flag.

   --version
   Displays version information and exits.

   -h,  --help
   Displays usage information and exits.

mola-mm-add-geodetic: add geodetic coordinates to point clouds

Once you have a georeferenced metric map (*.mm file), you can use the CLI tool mola-mm-add-geodetic to enrich point cloud layers with geodetic coordinates (latitude, longitude, altitude in WGS84). This adds three new double-precision fields to each point in CGenericPointsMap-based layers, enabling direct use of geographic coordinates in subsequent analysis or export to GIS applications.

The tool automatically handles the coordinate transformation from the map’s local frame to geodetic coordinates using either embedded georeferencing metadata or an external georeferencing file.

The output metric map will contain the same structure as the input, but point cloud layers (CGenericPointsMap-based) will have three additional double-precision fields:

  • latitude: WGS84 latitude in decimal degrees

  • longitude: WGS84 longitude in decimal degrees

  • altitude: WGS84 ellipsoidal height in meters

These fields can then be exported to text or PLY format using mm2txt or mm2ply respectively, with the --export-fields option to include the geodetic coordinates.

For example, to export only coordinates and geodetic information:

mm2txt output.mm --export-fields "x,y,z,latitude,longitude,altitude"

Full CLI reference
USAGE:

   mola-mm-add-geodetic  -i <input.mm> -o <output.mm> [-g <map.georef>]
                         [-l <layerName>] ... [-p <foobar.so>] [-v] [--]
                         [--version] [-h]


Where:

   -i <input.mm>,  --input <input.mm>
   (required)  Input metric map file (*.mm)

   -o <output.mm>,  --output <output.mm>
   (required)  Output metric map file (*.mm) with geodetic coordinates
   added

   -g <map.georef>,  --georef <map.georef>
   Optional geo-referencing file (*.georef or *.yaml) to use if the
   input map does not have embedded georeferencing information

   -l <layerName>,  --layer <layerName>  (accepted multiple times)
   Layer(s) to process. If not provided, all CGenericPointsMap layers
   will be processed. This argument can appear multiple times.

   -p <foobar.so>,  --load-plugins <foobar.so>
   One or more (comma separated) *.so files to load as plugins

   -v,  --verbose
   Enable verbose output with progress information

   --,  --ignore_rest
   Ignores the rest of the labeled arguments following this flag.

   --version
   Displays version information and exits.

   -h,  --help
   Displays usage information and exits.
Examples

Basic usage with embedded georeferencing:

mola-mm-add-geodetic -i input.mm -o output.mm

Using an external georeferencing file:

mola-mm-add-geodetic -i input.mm -o output.mm -g map.georef

Process specific layers only:

mola-mm-add-geodetic -i input.mm -o output.mm -l raw -l filtered

Verbose mode for large datasets:

mola-mm-add-geodetic -i input.mm -o output.mm -v

Geo-referenced maps in mm-viewer

mm-viewer shows the geo-reference of a .mm map, if it has one:

  • Apply georeferenced pose: a checkbox that draws the map in the enu frame (applying \(T_{\text{enu}}^{\text{map}}\)), with the ENU axes next to the map ones.

  • Mouse coordinates in map, enu or latitude/longitude units, with a button to copy them, e.g. to look up a point in a GIS tool.

  • Overlay of a polygon given in latitude/longitude (e.g. a parcel or the boundary of the working area), from a text file with one lat,lon vertex (WGS84 degrees) per line:

    mm-viewer myMap.mm --georef-polygon area.txt
    

View GNSS readings on a geo-referenced map

Once you have published a georeferenced map (via mrpt_map_server or directly from mola_lidar_odometry), you can visualize in RViz or FoxGlove the localization from the GNSS sensor and its covariance uncertainty by installing mola_gnss_to_markers and then:

ros2 launch mola_gnss_to_markers mola_gnss_to_markers_launch.py