carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.4k stars 3.7k forks source link

issues transforming openstreetmap to opendrive format #3523

Closed ThierryDeruyttere closed 1 year ago

ThierryDeruyttere commented 4 years ago

So I follow the instructions from the documentation on how to convert the openstreetmap format to open drive. However, I get an error saying: RuntimeError: No nodes loaded.

The code that I use is:

    osm = "sing-one.osm"
    f = open(osm, 'r')
    osm_data = f.read()
    f.close()
    # Define the desired settings. In this case, default values.
    settings = carla.Osm2OdrSettings()
    # Convert to .xodr
    print(len(osm_data), settings)
    xodr_data = carla.Osm2Odr.convert(osm_data, settings)
    # save opendrive file
    f = open(osm.split("/")[-1].replace("osm", "xodr"), 'w')
    f.write(xodr_data)
    f.close()

File to recreate the issue: sing-one.zip

corkyw10 commented 3 years ago

@Axel1092 could you have a look at this please?

Axel1092 commented 3 years ago

Hi @ThierryDeruyttere, sorry for the late response, apparently your OSM data does not contain the type of the roads it is exporting (highway, railway, waterway, cycleway, busway, route, sidewalk, highspeed or usage) which is necessary to properly generate the representation of the road. How are you generating this data?

ThierryDeruyttere commented 3 years ago

I was using https://github.com/gdlg/nuscenes-to-osm-exporter to generate the file I believe.

Axel1092 commented 3 years ago

After seeing the code you would have to add the road type for our converter to work. Something like changing in nuscenes_map_to_osm_exporter.py line 110 with export_polygon(output_file, numap, 'drivable_area', record, '<tag k="highway" v="residential"/>'). The issue with not having the tag "highway" is that we cannot know if the way is defining a road or a shape of something different.

driverych commented 3 years ago

Have you found a valid solution to this problem? I believe I have fallen into a similar circumstance as you. I have been trying to convert a .osm file in the Lanelet2 structure to a .xodr file, which could be imported by the Driving Scenario Designer of Matlab.

The Carla version is 0.9.11, the Ubuntu 18.04, operated with Intel i7-8700K and Nvidia GTX1070.

location1.zip The python code is as follows:

import carla f = open("location1.osm", 'r') # Windows will need to encode the file in UTF-8. Read the note below. osm_data = f.read() f.close()

settings = carla.Osm2OdrSettings() xodr_data = carla.Osm2Odr.convert(osm_data, settings)

f = open("location.xodr", 'w') f.write(xodr_data) f.close()

And these codes are performed in the Examples folder of PythonAPI. The Carla is installed both through Linux build and a recommended quick start installation.

Could you help with this problem? The .osm file is attached. Any suggestions will be helpful.

werewolfdev commented 3 years ago

Hi @driverych have you found a solution for osm to xodr conversion yet

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

muety commented 1 year ago

I tried to convert Lanelet maps in OSM format to OpenDRIVE and ran into the same issue as well. Any ideas?

devanshanker commented 1 year ago

@driverych how did you resolve this issue in the end?