To be used outside of apollo's docker container
A tool for converting standard OpenDRIVE map to Apollo's HDMap XODR format, the generated HDMap XODR map then can be converted to pb map (Protocol Buffers) map as used by Apollo. This implemetation works for all our maps, but is not comprehensive, see the Ommitted Features section!
Since Apollo does not support native OpenDrive-formatted maps, errors occur during the loading of a map file.
According to the GitHub issue 3864 (ApolloAuto#3864), there is no way of converting an existing OpenDrive map to an Apollo map. (18.6.18)
We use pygraphviz for visualizing the road topology, which is why we need to install graphviz first
sudo apt-get install -y graphviz-dev
Install a virtual environment with all required dependencies. (execute the first time only!)
bash install.sh
We then go into the virtual environment (Execute every time after openning a new terminal!)
source dev_into.sh
- Inout: OpenDRIVE map
- Output: Apollo HDMap
# input and output path need to be absolute (except the maps in test_maps)
bazel run //modules:converter -- -m /apollo/modules/test_maps/Osterwaldstrasse_v1.xodr -o ~/Desktop/osterwald.txt -d 0.1
- -m: absolute path of input OpenDRIVE map
- -o: absolute path of output Apollo HDMap
- -d: distance value to discretize lines (<2 is recommended)
- -p: plot the discretized HDmap with matplotlib
- --debug: ignore all checkings to prevent known issues mentioned below
bazel run //modules:converter -- -m modules/test_maps/Osterwaldstrasse_v1.xodr -p
- -m: absolute path of input Apollo HDMap (generated by opendrive2apollo)
- -o: absolute path of connections in dot style pdf
# input needs to be absolute path
# show lane connections in matplotlib and output a dot file
bazel run //modules/visualization_tools:lane_connection_visualization -- -m ~/Desktop/osterwald.txt -o ~/Desktop/dot.pdf
where ~/Desktop/osterwald.txt
is the file we created in the previous step
- Input: Apollo HDMap
- Output: pb map (that's what we want to generate)
Copy the map into the apollo docker container:
docker cp osterwald.txt apollo_dev_kessler:/apollo/osterwald.txt
Start Apollo as usual
source scripts/apollo_base.sh # execute every time after openning a new terminal
sudo bash docker/scripts/dev_start.sh
sudo bash docker/scripts/dev_into.sh
Input and output path in apollo/modules/map/tools/proto_map_generator parameters need to be modified first
bazel run modules/map/tools:proto_map_generator
# install a gui backend for matplotlib if needed:
sudo apt-get install python3-tk
python3 modules/tools/mapshow/mapshow.py -m base_map.bin
# at Apollo root directory
source scripts/apollo_base.sh
python modules/tools/mapshow/mapshow.py -m base_map_guericke_straße.txt
- In the header of OpenDRIVE map, east and west cannot be the same for projecting points
- Apollo checks longitude zone of east (max longitude) and west (min longitude), they must be in the same zone
- A correct geoReference is necessary to project points in Apollo proto map generator
- elevation (OpenDRIVE 5.3.5, z axis in HDMap)
- roadMark (OpenDRIVE 5.3.7.2.1.1.4, boderType in HDMap)
- we assume starting s coordinate of each laneSection intersect with the coordinate of one of the geometries
- Traffic lights
- https://github.com/ApolloAuto/apollo/tree/master/modules/tools/map_gen
The detailed structure of Apollo HDMaps can be estimated from here - https://gitlab.lrz.de/tum-cps/opendrive2lanelet
for the problems they were facing when parsing an open-drive map - https://github.com/CWGran/osm2opendrive
A tool for generating Apollo OpenDRIVE maps from OpenStreetMap data
- The converter is very slow. This is due to the number of projections done by pyproj
- Internal Proj Error: proj_create: Error -38 (failed to load datum shift file): vgridshift: could not find required grid(s). -> The egm96_15.gtx cannot be located. pyproj in the venv is somehow lacking this file. Workaround: Provide the absolute path to the file.