This Blender add-on lets you create OpenDRIVE and OpenSCENARIO based scenarios for development and testing of advanced driver assistance systems and autonomous driving functions.
Prior to installing the add-on inside of Blender some requirements must be installed. The process slightly differs for Linux and Windows.
For the sake of simplifying the following instructions let's assume that we work with a Debian based Linux distribution (such as Ubuntu or Mint) and Blender has been downloaded and installed to
/opt/blender/
Then we first need to install the scenarigeneration library into the Blender Python environment since the add-on uses the library as a backend to write OpenDRIVE and OpenSCENARIO files. Additionally, pyclothoids is needed which is used by the add-on and the scenarigeneration lib as well. Navigate to your Blender included Python installation
cd /opt/blender/<blender_version>/python/bin
if pip is not already present in there then run (use sudo only if root is the owner)
sudo ./python<python_version> -m ensurepip
now install the lib(s)
sudo -E ./python<python_version> -m pip install scenariogeneration
where the -E
makes sudo preserve the exported environment variable. Note again
that sudo
is not required in case Blender is installed to the user home
directory or the user has write access to the directory. Also make sure not to
not forget the ./
at the beginning such that the Python executable from within
the directory is used and not another instance on your system.
For the esmini export functionality we also need to install
OpenSceneGraph to have the osgconv
tool
available. This is necessary because Blender is unable to directly export to the
.osgb scenegraph format, while esmini can only process this particular format.
On a Debian/Ubuntu/Mint system this can be achieved with
sudo apt install openscenegraph
If you manually install OpenSceneGraph make sure that osgconv
can be found
through your PATH
environment variable, otherwise the export with .osgb 3D
model files will fail.
Install esmini. Preferably to
/opt/esmini
and then put /opt/esmini/bin
it in your PATH
environment
variable with an export PATH=$PATH:/opt/esmini/bin
at the end of the
~/.bashrc
.
Assuming Blender has been downloaded and installed using the .msi installer, open PowerShell in admin mode by pressing Windows+X and then then A.
In PowerShell navigate to the Blender install folder with (don't forget to insert the version number)
cd "C:\Program Files\Blender Foundation\Blender <blender_version>\<blender_version>\python\bin"
Run the following command to install the scenariogeneration library
.\python -m pip install scenariogeneration --target ..\lib\site-packages
Note that you might be able to do this without admin rights in case you are
using the "Portable" version of Blender. Also if you are having trouble with
this part of the installation, consider starting over with a clean installation
of Blender and/or removing any leftovers of Python in your %appdata%
folder.
Download and extract (for example to C:\Tools\OpenSceneGraph
)
openscenegraph.
Also download and extract (for exampe to C:\Tools\esmini
)
esmini.
Add the OpenSceneGraph bin
folder and the esmini bin
folder to the PATH
environment variable using the "Edit environment variables for your account"
tool (look for it in the Windows start menu). Note that otherwise the export
with .osgb 3D model files will fail because osgconv
can not be found by the
add-on.
Finally download the driving scenario generator release .zip archive. Open Blender and go to Edit -> Preferences -> Add-ons. Click "Install...". Select the .zip archive and confirm. Activate the add-on by ticking the little box next to it, in the add-on list.
Before using the add-on some preliminary settings are recommended.
When you are in the Blender Layout workspace (see the tabs at the top), press
N or click the little left arrow next to the navigation gizmo to
toggle the sidebar. Click View, set Clip Start
to 1 m and Clip End
to 10000 m to avoid some 3D viewport clipping issues since the Blender
default setting is targeted more towards smaller models. Click the
Shading dropdown button (the little down arrow in the top right
corner of the 3D viewport) and select Texture
to be able to directly see the
road sign textures.
It is also very useful to make yourself familiar with the most important
shortcuts to navigate with the camera in the 3D viewport. The most important
ones are Shift + Middlemouse to pan and Alt +
Middlemouse to move the pivot point. The pivot point will
automatically be placed on the surface of an object when it is under the mouse
pointer which is extremely useful. The view can be rotated by holding
Middlemouse. Additionally, the View
Pie Menu is very useful to see
the scene from different fixed angles. It can be opened with the `
(backtick) button on the US keyboard layout, alternatively use the Numpad
shortcuts or go to Edit -> Preferences -> Input -> Emulate Numpad
and use the
1-9 keys. Hint for German keyboard layouts: go to Edit -> Preferences -> Keymap -> 3D View -> 3D View (Global) -> View
and add the
Ctrl modifier key to the shortcut. Then it will work with the
^ key which is in the same location as the ` key in the
US keyboard layout (above the Tab key).
Click Driving Scenario Creator in the sidebar. From here you can create roads and vehicles using the mouse by clicking the buttons in the "Driving Scenario Creator" menu. Roads, signs, vehicles and trajectories can be placed with the mouse. Junction connecting roads can be build using the mouse similar to normal roads after first building a junction area. The cursor will snap to the lanes of the incoming roads in this case. Note, that in Blender it is possible to quickly left click multiple times in order to select objects which are located on top of each other. This helps with selecting and deleting junction connecting roads. Grid snapping can be activated by holding Ctrl. Additional geometry sections can be added by holding Shift and clicking. Start heading of a road can be adjusted by holding Alt and moving the mouse pointer. For the clothoid geometry using the Hermite solver the end heading can be adjusted by holding Shift and moving the mouse wheel. Road elevation can be changed by holding E(3D view) or S(sideview) keys and moving the mouse. After placing roads, road signs can be attached to them and placed at the side. Finally, vehicles can be placed and a trajectory can be assigned to them.
Keyboard Shortcut | Function |
---|---|
N (vanilla Blender) | Toggle sidebar with add-on main menu |
Hold Ctrl | Activate grid snapping |
Hold Shift + Mouseleft | Add additional geometry section |
Hold Alt | Change start heading of a road |
Hold Shift + Mousewheel Up/Down | Change end heading of a road |
Hold E | Change road elevation (3D view) |
Hold S | Change road elevation (sideview) |
Before or after adding roads add additional Blender objects as desired. When done modelling, export everything together by clicking Export driving scenario. Choose a directory and a 3D file format (.fbx, .gltf, .osgb) for the export and confirm.
With esmini available the exported scenario can be run with
cd <export_directory>
esmini --osc xosc/bdsc_export.xosc --window 50 50 800 400
For development of the add-on the Blender VS Code extension is very recommendable. It allows hot reloading and rapid iterations.
There is a handful of tests for the geometries in the tests/
directory. They
can be run by executing pytest from the Blender python distribution in the
project root directory
/opt/blender/<blender_version>/python/bin/pytest
If pytest is not installed use pip to install it into the Blender directory as described with the scenariogeneration library above.
The tests can also be run and debugged from within VS Code by adding the
following line to the .vscode/settings.json
which is generated by VS Code when
configuring/scanning for the tests
{
...
"python.defaultInterpreterPath": "/opt/blender/<blender_version>/python/bin/python3.<python_version>",
...
}
The source code of this tool is distributed under the GPL version 3.0 license as required for all Blender add-ons. Note, that this does not imply that the tool can not be used in a commercial context. In fact, there is probably no issue using it in the same way as you would use Blender itself, Linux or GCC since you will probably not be modifying the source code and/or linking against it.
Furthermore, if your enterprise has already reached a state where open source software contribution is possible or your business has embraced open source software long ago, your contributions and pull requests are welcome if they are maintainable.
Credits for the current version go to
- pyoscx/scenarigeneration developers for the .xodr/.xosc generating/writing lib used as backend
- Archipack add-on developer(s) for general Blender add-on tool inspiration
- Blender VS Code extension for quick iterative development and hot reloading
- pyclothoids which is a Python wrapper for Enrico Bertolazzi's Clothoids library
- Wikipedia and its contributors for the public domain ("gemeinfrei") German road sign textures and road stencil designs
Please open issues and pull requests on GitHub to discuss openly. For private support inquiries contact the repository owner via email, Twitter or create an issue to initiate the communication. If you consider contributing large new features please consider to have a discussion before beginning with the clean implementation.