Import OpenDRIVE roads into Blender as 3D meshes. This repository is based on the libOpenDRIVE.
Assuming that you are using a Windows machine and Blender is installed and you are able to run the blender --python
command from your command prompt/terminal:
- Create a python environment with python 3.8 and where
pip install scenariogeneration
is done. - Run
python odrgen.py
. This will generate thejunction.xodr
file in the libOpenDRIVE directory using thescenariogeneration
python package. Alternatively, you can also just place a .xodr file in the libOpenDRIVE directory directly. cd libOpenDRIVE
and runworkflow.bat
. This will install the test-xodr executable in thebuild/Release
directory that will be the one generating the mesh obj files.- Make appropriate edits in the
genobj.bat
file according to the name of the .xodr file and run it. This will run the opendrive parser library executable (test-xodr.exe
) for an xodr file and run the Blender python command to import the generated .obj files into Blender. It will also generate the .fbx files in the project directory. Here are some outputs:
Assuming you have Blender installed and you are able to run the blender --python
command from your command prompt/terminal and have installed CARLA simulator from source (0.9.14) on Windows with python 3.8 (since for this python version, the python module is available via Pypi)
- Open a
x64
command prompt. Runmake launch
to start the simulator. When the Unreal Editor opens, click theplay
button. If this isn't working, make sure your CARLA installation is correct. - Open a new
x64
command prompt. - Create a python environment with Python 3.8 and ensure that
import carla
works. If it doesn't, install the python package directly usingpython -m pip install carla
. - As written in the quick start before, run
python odrgen.py
to generate OpenDRIVE .xodr files andgenobj.bat
to generate 3D meshes for the same road via Blender. - Run
carlaimport.bat
. - Check if map is imported into CARLA.
Here's a procedurally generated 3 way intersection generated in odrgen.py
in Blender and CARLA:
- You can further generate .xodr files using python by referring to the scenariogeneration library or by modifying the
odrgen.py
script. - You can further generate the larger 3D scene beyond the road (road signs, trees, fences, buildings) using the Blender python API by modifying the
import.py
script. - You can also manually import the map into CARLA. I wrote a step-by-step guide to do so here
- Once you have imported the map into CARLA, you can develop the python scripting using the CARLA python API or use the CARLA scenario runner to run traffic in the scene.