Git Product home page Git Product logo

blender-driving-scenario-creator's Introduction

Blender Driving Scenario Creator add-on

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.

Screenshot

How to install

Prior to installing the add-on inside of Blender some requirements must be installed. The process slightly differs for Linux and Windows.

Requirements Linux

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.

Requirements Windows

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.

Add-on (Linux and Windows)

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.

How to use

Before using the add-on some preliminary settings are recommended.

Recommended Blender settings

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).

Using the actual add-on

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.

How to run exported scenarios

With esmini available the exported scenario can be run with

cd <export_directory>
esmini --osc xosc/bdsc_export.xosc --window 50 50 800 400

How to develop

For development of the add-on the Blender VS Code extension is very recommendable. It allows hot reloading and rapid iterations.

How to run the test

There is a handfull 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>",
    ...
}

License

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

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

Main author/maintainer contact

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.

blender-driving-scenario-creator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

blender-driving-scenario-creator's Issues

Is OpenCRG on the roadmap?

Is it on the roadmap to also be able to model and export OpenCRG data alongside the OpenDRIVE? This would enable to build more detailed 3D models of the road surface for sensor simulation while also enabling a consistent vehicle dynamics simulation.

Usability issue with not memorizing lane settings

Hello, following the previous suggestions, I also want to point a bug that I found.

When adding or removing a lane in the settings, it would just reset all the other lanes to a default setting. I then have to go over all the other lane settings again and reapply their values.

BugWithLaneSettings

ModuleNotFoundError: No module named 'lib2to3' when enabling the add-on on blender

Hi, I get the following error when trying to enable the blender-driving-scenario-creator add-on.
Here some remarks for reproducing the error. It would be great if you could help me with this issue.

Operating System Ubuntu 18.04.6 LTS
Step where the problem occurs: Add-on (Linux and Windows)
Blender version: Blender 3.2.2
Notes: I tried installing blender both under /opt and under my home and nothing changed
Printout when trying to enable the add-on:

Read prefs: /home/aaa/.config/blender/3.2/config/userpref.blend
Traceback (most recent call last):
  File "/home/aaa/blender-3/3.2/scripts/modules/addon_utils.py", line 335, in enable
    mod = __import__(module_name)
  File "/home/aaa/.config/blender/3.2/scripts/addons/blender-driving-scenario-creator/__init__.py", line 19, in <module>
    from . export import DSC_OT_export
  File "/home/aaa/.config/blender/3.2/scripts/addons/blender-driving-scenario-creator/export.py", line 17, in <module>
    from scenariogeneration import xosc
  File "/home/aaa/blender-3/3.2/python/lib/python3.10/site-packages/scenariogeneration/__init__.py", line 7, in <module>
    from .esmini_runner import *
  File "/home/aaa/blender-3/3.2/python/lib/python3.10/site-packages/scenariogeneration/esmini_runner.py", line 15, in <module>
    from .xodr import OpenDrive
  File "/home/aaa/blender-3/3.2/python/lib/python3.10/site-packages/scenariogeneration/xodr/__init__.py", line 11, in <module>
    from .signals_objects import *
  File "/home/aaa/blender-3/3.2/python/lib/python3.10/site-packages/scenariogeneration/xodr/signals_objects.py", line 12, in <module>
    from lib2to3.pytree import convert
ModuleNotFoundError: No module named 'lib2to3'

I tried to install it with ./python3.10 -m pip install 2to3 in /home/aaa/blender-3/3.2/python/bin but I didn't notice any improvements.

Thanks

./pip3 failed and no module named "scenariogeneration"

System: Ubuntu 22.04
Blender 3.5

I have run ./python3.10 -m ensurepip.

It shows satisfaction, but there is no pip3 in the folder. Thus, the scenariogeneration cannot be installed by ./pip3 install scenariogeneration and the addon does not work well.

I looked for some methods to address this issue. Fortunately, I got it.

Try download install package from https://pypi.python.org/pypi/pip#downloads and use ./python[python version] setup.py install to install pip.

I share this with someone who has the same issue here.

Locked objects

Hi,

Some of the objects are locked for me. Are they implemented or not?
image

Thanks

Error : no module named 'scenario generation'

Hello ! I am having trouble with the installation. I do have the scenariogeneration module installed but I still have this error when I want to enable the add-on.

Traceback (most recent call last):
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\3.0\scripts\modules\addon_utils.py", line 351, in enable
mod = import(module_name)
File "C:\Users\diane\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\blender-driving-scenario-creator_init_.py", line 19, in
from . export import DSC_OT_export
File "C:\Users\diane\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\blender-driving-scenario-creator\export.py", line 17, in
from scenariogeneration import xosc
ModuleNotFoundError: No module named 'scenariogeneration'

Has someone had the same error ? Thank you !

pip's dependency resolver error

When executing sudo -E ./pip3 install scenariogeneration I get the follwing error:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ipympl 0.9.3 requires matplotlib<4,>=3.4.0, which is not installed.
ipympl 0.9.3 requires pillow, which is not installed.
fmpy 0.3.15 requires attrs, which is not installed.
fmpy 0.3.15 requires lark, which is not installed.
fmpy 0.3.15 requires lxml, which is not installed.
fmpy 0.3.15 requires pytz, which is not installed.

I just executed it again and this time, no errors popped up. Is this normal behavior?

Import of OpenDRIVE files

Hi,

Thank you for the great software. I wonder if it is possible to import pre-existing opendrive maps and then edit them or define a scenario on that?

Thank you

Generate xodr file corresponding to fbx file

Hi, I have a fbx file that I generated using 3ds Max. Can I use the blender-driving-scenario-creator to generate this fbx file corresponding to xodr file, and then import them into Carla for use?
image

When exporting, there is an error: 'NoneType' object has no attribute 'predecessor'

Hi,

I just tried the add on for Blender 2.93 and I wanted to export the following map

first_infinity_like_map.zip.

When exporting, I received the following error:

Python: Traceback (most recent call last):
File ".config/blender/2.93/scripts/addons/blender-driving-scenario-creator/export.py", line 45, in execute
self.export_openscenario(context, self.directory)
File ".config/blender/2.93/scripts/addons/blender-driving-scenario-creator/export.py", line 223, in export_openscenario
if incoming_roads[k].predecessor:
AttributeError: 'NoneType' object has no attribute 'predecessor'

location: :-1

However, some folders were created (catalogs, models, scenegraph, xodr). But the xodr folder is empty, so I guess there is a problem with the OpenDrive file generation (would also match with 'predecessor' attribute I guess?)

Would be cool, if you could have a look at that, maybe try the blender file or say, what I did wrong. That would be awesome. :)

Show road lines and textures in CARLA

Hello :)

I am quite new to this, and I am curious is it possible to show road lines when I import the .xodr map file into CARLA simulator.

This is what I get in CARLA:

carla

And this is what I get in esmini:

esmini

Thank you :)

List of suggestions to improve workflow

Hello, I have been working with the Driving Scenario Creator and have made a list of suggestions that can improve the workflow.

  1. I like that I can make custom roads. However, it takes a very long time to create a version of a road that exists in real life. So far, my workflow has consisted of creating the road, checking if it fits, deleting the road, changing some settings and repeat. In other words, a lot of trial and error.
    My suggestion is to have a section in the object properties menu that holds the values for the created road, which can then be changed dynamically to update it when it's already placed. This would also make changing previously placed roads possible if they need to be adjusted to fit a newer one. I believe this would speed up the process of making and connecting roads by a lot.

  2. The road presets that are given by default are a great starting point in most cases. The problem I am having is that sometimes I would need one or a few settings that are different from the preset, which I need to use more than once. It would be nice to be able to save my own presets and maybe edit and delete them as well.

  3. Three great additions to the broken line setting would be:

  • a length value for when shorter broken lines are needed
  • a shift value. This removes the problem of when two roads that are connecting could also make a double-length broken white line.
  • a solid broken and broken solid line setting to allow cars to pass on only one side of the road.
  1. Roads that can be made using a curve with adjustable handles. In addition to that, the ability to rework this kind of road after it is placed down would make it even better.

Thank you!

Make an OpenDrive .xodr based on real world map

Hello

Your tool is very useful to create OpenDrive files. I just started using the tool and have a couple of questions regarding the tool.

  1. How can i create a map based on real world. I need to create a rough road based on google map. i roughly estimated the distances from the google map. I also created a straight road but seems like i can't control the length of the road. Is there any option to adjust the length of the road after plotting it. I saw the scale option but i think its not the right one as the markings are streching while using it. Any method i am missing ?

  2. Is there any another approach rather than the distance to create a map based on google map?

  3. How to join two roads expecially a road that goes left from the main road like a cut out road from the Autobahn?

Thanks

Open designed roads in CARLA

Hi
Would you please explain how I can export the roads designed in blender driving scenario creator to Carla?
which format should I export?
I wanted to design my own road and then open it in the Carla simulator, then I wanted to add objects such as a vehicle, pedestrian, bicycle, and .. (in Carla) to generate my scenario.

An OpenDRIVE file importer for Blender

Hello,

Using a parser for OpenDRIVE and its capability to generate .obj files, I was able to create an OpenDRIVE importer for Blender. I separated the .obj files for multiple elements so that each can have a different material applied to them. Currently, it's just the base road mesh and road markings. Luckily, all the imported meshes seem to have the same origin so no transformations are needed. Once the .obj files are brought in, I can apply materials and create a hierarchy for the meshes.

We can completely run the process without opening the Blender GUI to go from OpenDRIVE to FBX using the command blender --background --python <scriptname.py> -- <path to .obj 1> <path to .obj 2> <path to fbx output>. This can be combined with the steps mentioned in #23 to bring generated maps into CARLA if needed.

Playing OpenSCENARIO inside Blender

Hi! Thank you for the great software.

After I create OpenScenario (trajectories and car), I confirmed that xosc file has been created properly.
However, I want to check in the Blender layout that the scenario was created well as I expected.
Playing animation does not work so I can't check my scenario was created properly or not.
As I am new to blender, I want to know if these features are supported or not .

some suggestion for code

Hi, thanks for your contribution, it's a wonderful project for me, combine blender and openDrive is a genius idea!

but when i reading the code , here are some suggestion for your pro
image
The function's job is to translate the "sample points" to "Mesh", so may be we can delete the strip param in this function ? for this, we just delete none type points in "get_road_sample_points".

def get_road_vertices_edges_faces(self, road_sample_points): vertices = [] edges = [] faces = [] idx_vertex = 0 point_index = 0 while point_index < len(road_sample_points): for idx_face_strip in range(len(road_sample_points[point_index])): if not road_sample_points[point_index][0]: continue samples_right = road_sample_points[point_index + 1][idx_face_strip] samples_left = road_sample_points[point_index][idx_face_strip] num_vertices = len(samples_left) + len(samples_right) vertices += samples_right + samples_left[::-1] edges += [[idx_vertex + n, idx_vertex + n + 1] for n in range(num_vertices - 1)] \ + [[idx_vertex + num_vertices - 1, idx_vertex]] faces += [[idx_vertex + n for n in range(num_vertices)]] idx_vertex += num_vertices point_index = point_index + 2 return vertices, edges, faces

and when i want to add a solid_solid type for it, i found maybe it's better to add "s" and "t" to strip struct, because solid_solid neet 3 "t" value to create mesh (yellow line, asphalt line, yellow lin) , for this struct, i have to write this code anywhere

if strip.type_road_mark == 'solid_solid': do something

Blender with CARLA simulator

Hello @johschmitz , I am new to this openscenario and CARLA simulator, Is it possible to create a specific scenario, for example, a overtaking scenario in a two-way highway with this blender creator and to import it to CARLA for testing?

Also, just an add-on question from my side, Are there any solutions?/tools for creating concrete scenarios from functional scenarios for testing with CARLA simulator?

Update the locations of the section after it is first created

Hi, I'm having trouble creating a highway entrance/exit. I would like to know if there is anything about creating the roadway by entering the exact coordinates and heading of the startpoints/endpoints, or a way to update the coordinates of the startpoints/endpoints of the road section after the first creation.

Thanks a lot.

PS. If this is not the proper channel to ask for it, I do apologize

Junctions in CARLA

Hi, is there any way of controlling junctions?

When I load the xodr to CARLA with wider roads the junctions seem to be completly broken.

image

wrong snap point

Hello,
I found a problem. As shown in the figure when I use multiple lanes to reduce lanes, the connection snap point of the rear lanes is incorrect , and the connection is not continuous.
image

Procedure to automatically add roads on a set of curves

Hi, I don't know if it could be considered an issue but I was wondering if there is any suggestion on how to
automatically add OpenDrive roads on a set of curves (eventually imported from OSM) directly in Blender.

Thanks a lot.

PS. If this is not the proper channel to ask for it, I do apologize

Missing Spiral and polynomial functions

Really impressive tool!

Are the Spiral and Polynomial functions placeholders or do they function? They are greyed out in the plug-in I have.
These can be necessary to fit the xodr standard for linking some more complex road structures together.

where to download

where to download driving scenario generator release .zip archive?

CARLA map import experience

Hello,

Since several issues refer to this task (#21, #14, #4), I thought writing about my experience here would be useful. I ran both tools on Windows. Here was the process:

  • From the current latest version of this tool (0.17.2), I created a 4 way junction. I was able to snap straight roads easily to the junction polygon.
  • I used the eye icon on the right side menu (the outliner menu in Blender) to hide the junction_connecting_road elements. This is because no fbx is generated for these connecting roads and the CARLA map import had an issue with that. I don't think this affects the connecting roads in the OpenDRIVE file.
  • I chose the fbx import option. An opendrive is also generated when the export button of this tool is clicked.
  • I had CARLA installed, built from source on Windows. I added copies of the fbx file and the opendrive file in the Import folder in CARLA. I renamed both files to be the same name.
  • I ran make import from the CARLA project directory. It did not give any error. It creates a map_package directory in the <CARLA project folder>/Unreal/CarlaUE4/Content directory.
  • I started CARLA by running make launch from the CARLA project directory. Clicked the play button on Unreal Engine to start the server.
  • I opened another console and in the <CARLA project folder>/PythonAPI/util directory, I ran the config.py script using the following command: python config.py --map <map name> This is the same map name of the fbx and opendrive from earlier. This reloaded the scene with the imported map with lane markings. I also ran /PythonAPI/examples/generate_traffic.py to test simulation capability and it worked.

Here are the outputs on Blender and CARLA:

blender-intersection
unreal-blender-intersection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.