A ROS2 package for real-time odometry trajectory correction using OpenStreetMap (OSM) lanelet data. This system subscribes to odometry messages, maintains a sliding window of poses, and periodically aligns the trajectory to a high-definition map using robust ICP (Iterative Closest Point) algorithms.
OSM Align implements trajectory-to-map alignment for autonomous vehicle navigation, correcting drift in laser odometry systems using OpenStreetMap road network data. The system uses Lanelet2 library to process OSM data and publishes corrected odometry on /osm_align/odom_aligned.
- Trajectory Buffering: Maintains a sliding window of recent odometry poses
- Map Loading: Loads OSM lanelet data and converts to 2D point cloud representation
- Correspondence Finding: Uses KD-tree for efficient nearest neighbor queries
- Normal Shooting: Projects trajectory normals to find map intersections
- Robust Alignment: Employs trimmed/RANSAC ICP for drift-resistant pose correction
- Publish Corrected Odometry: Outputs corrected poses on
/osm_align/odom_aligned
- ROS2: Tested with ROS2 Humble
- Python: 3.12 (compatible with other Python 3.x versions)
- Operating System: Linux (tested on Ubuntu)
rclpy- ROS2 Python client librarynav_msgs- Navigation message typestf2_ros- Transform librarytf_transformations- Transform utilities
lanelet2_core- Core lanelet functionalitylanelet2_io- I/O operations for lanelet mapslanelet2_projection- Map projection utilities
numpy- Numerical computingscipy- Scientific computing (spatial algorithms, transforms)transforms3d- 3D transformation utilities
cd ~/ros2_ws/src
git clone <repository-url> osm_align# Install ROS2 dependencies
sudo apt install ros-<humble>-lanelet2-core ros-humble-lanelet2-io ros-humble-lanelet2-projection
# Install Python dependencies
pip install numpy scipy transforms3dcd ~/ros2_ws
colcon build --packages-select osm_align --symlink-install
source install/setup.bashros2 launch osm_align osm_align.launch.pyros2 launch osm_align osm_align.launch.py \
frame_id:=02 \
pose_segment_size:=150 \
icp_error_threshold:=1.5 \
odom_topic:=/your_odom_topic| Parameter | Default | Description |
|---|---|---|
frame_id |
"00" |
KITTI sequence identifier for coordinate system |
map_lanelet_path |
"" |
Path to OSM lanelet file (auto-constructed if empty) |
pose_segment_size |
150 |
Number of poses in sliding window buffer |
knn_neighbors |
100 |
Number of nearest neighbors for spatial queries |
valid_correspondence_threshold |
0.9 |
Minimum ratio of valid correspondences |
icp_error_threshold |
1.5 |
Maximum ICP error for successful alignment |
trimming_ratio |
0.4 |
Trimming ratio for robust ICP |
min_distance_threshold |
10.0 |
Minimum trajectory distance before alignment |
odom_topic |
"/liodom/odom" |
Input odometry topic name |
save_resuts_path |
'/home/.../results/osm_aligned/...' |
Directory to save results (optional) |
odom_topic(nav_msgs/Odometry) - Input odometry messages (default/liodom/odom)
/osm_align/odom_aligned(nav_msgs/Odometry) - Corrected odometry
The package has been tested with:
- KITTI Odometry Dataset - Multiple sequences (00, 01, 02, etc.)
- LIODOM - Lidar Inertial Odometry via Smoothing and Mapping (for testing)
- Any odometry source that publishes
nav_msgs/Odometry
The package includes pre-configured coordinate systems for KITTI sequences. Each sequence has specific:
- GPS origin coordinates for map projection
- Rotation angles for coordinate frame alignment
- Optimized algorithm parameters
ros2 launch osm_align osm_align.launch.py frame_id:=00ros2 launch osm_align osm_align.launch.py \
map_lanelet_path:=/path/to/your/map.osm \
frame_id:=custom- Map Loading Errors: Ensure OSM file contains valid lanelet data
- Odometry Input: Verify the configured
odom_topicis being published - Coordinate Frames: Check that map and odometry coordinate systems are properly aligned
Enable debug logging to monitor alignment performance:
ros2 launch osm_align osm_align.launch.py --ros-args --log-level debugThis project is licensed under the Apache License 2.0. See LICENSE file for details.
Joaquin Caballero
Email: [email protected]