OSM Visualization and Navigation For Autonomous Robotics
Project Overview
map_data is an open-source Python library and ROS2 package designed to bridge the gap between Geographic Information Systems (GIS) and autonomous mobile robot navigation. It allows developers and researchers to pull real-world geographic features from the OpenStreetMap (OSM) database, parse them, and construct dense, structured layered navigation grids suitable for global path planning, collision mapping, and lane keeping.
The package processes raw geographic geometriesβsuch as roads, intersections, pedestrian pathways, buildings, and fencesβand converts them into structured topological road network graphs or costmaps that autonomous planners can consume. It parses a .gpx file containing GPS waypoints into a Python class, queries OpenStreetMap for map features within the area, and serializes the parsed data into a compact .mapdata file.
Key Features
- Automated Geographic Fetching: Downloads raw OSM XML features via Overpass API queries based on coordinate bounding boxes.
- Navigation Layer Segmentation: Parsed features are classified into three distinct categories:
- Barriers (
barriers): Obstacles assumed to be untraversable (walls, buildings, fences, water, etc.). - Footways (
footways): Paths intended for pedestrian travel and robot traversal. - Roads (
roads): Main transit areas intended for vehicles.
- Barriers (
- Interactive Editing Suite: Incorporates a Flask-based web editor (implemented with Leaflet) to inspect, tag, modify, and manually plan topological waypoint routes.
- ROS2 & GIS Export: Converts the processed map layers directly into ROS2 occupancy grids (
nav_msgs/OccupancyGrid) or outputs standard GIS formats like GeoJSON, publishing a cost-aware footway point cloud.
Technical Architecture & ROS2 Integration
The map processing pipeline follows a simple, robust serialization logic:
- Extraction: Raw nodes and ways are parsed from OpenStreetMap data.
- Filtering: Elements are classified using standard OSM keys (e.g.
highway,barrier,building). - Geometry Construction: Lines and points are converted into closed polygons or multi-line graphs representing road corridors.
- Export: Layers are projected from global GPS coordinates (WGS84) to local metric Cartesian coordinates (UTM) for local path planners.
Standalone Runtime Design
A key design strength of map_data is its decoupled execution. The MapData core class, the path planning modules, and the interactive viewer work standalone β no running ROS2 context is required for data parsing, annotation, or planning. ROS2 is only needed for the osm_cloud publisher node and the create_mapdata CLI node.
- Target OS / Environment: ROS2 Humble or later on Ubuntu 22.04.
Installation
As a Standalone Python Package
git clone https://github.com/vras-robotour/map_data.git
cd map_data
pip install -e .
With ROS2 (colcon)
git clone https://github.com/vras-robotour/map_data.git
cd map_data
colcon build --packages-select map_data
source install/setup.bash
Python Library Usage
The MapData and Way classes can be imported and used directly in Python scripts as long as the package is installed (e.g., via pip or colcon build) to access base configuration files.
Parse a GPX file and save map data
from map_data.map_data import MapData
md = MapData("./data/coords.gpx")
md.run_all(save=True) # Queries OSM, parses, and saves coords.mapdata
Load an existing .mapdata file and access parsed features
from map_data.map_data import MapData
# Load serialized data
md = MapData.load("coords.mapdata")
print(f"Roads: {len(md.roads_list)}") # List of Way objects
print(f"Footways: {len(md.footways_list)}")
print(f"Barriers: {len(md.barriers_list)}")
Project Structure
map_data/
βββ map_data.py # MapData class β parses GPX + OSM into roads/footways/barriers
βββ info.py # CLI tool to print information about a .mapdata file
βββ create_mapdata.py # ROS2 node / CLI: download and parse OSM data
βββ osm_cloud.py # ROS2 node: publishes footway grid and intersections
βββ pathsolver/ # Path planning algorithms
β βββ graph_planner.py # Global A* planning on OSM ways
β βββ replan.py # Local/Grid-based replanning (Grid A*, RRT*)
β βββ grid_astar.py # Grid-based A* implementation
β βββ rrt_star.py # RRT* implementation
β βββ astar.py # Generic A* search logic
βββ utils/ # Shared utility functions
β βββ way.py # Way class β represents a single OSM feature with geometry
β βββ overpass.py # OSM Overpass API client
β βββ parsing.py # OSM XML/JSON parsing logic
β βββ serialization.py # .mapdata file I/O
β βββ points_to_graph_points.py # Equidistant point interpolation
βββ viewer/ # Modular interactive viewer (Flask + Leaflet)
βββ app.py # App factory and server entry point
βββ routes.py # REST API endpoints and GeoJSON conversion
βββ helpers.py # Geometry and annotation utility functions
βββ cache.py # MapData object caching
βββ templates/ # HTML templates
βββ static/ # External CSS and Modular JS assets
For full implementation details, API references, and advanced usage, refer to the Official Documentation Page.
