0.背景
基于开源的地图制作工具osm以及开源的仿真引擎CARLA完成交通场景仿真场景的搭建。
1.构建OSM场景
https://www.openstreetmap.org/#map=16/31.2808/121.1690
1.1.搜索关键字
1.2. 手动选择不同的区域
1.3.导出
导出为osm文件
2.osm->xodr
OpenStreetMap 格式文件后缀为.osm
OpenDERIVRE 格式文件后缀为.xodr
CARLA提供了转换方法:详情
OpenStreetMap is an open license map of the world developed by contributors. Sections of these map can be exported to a .osm
file, the OpenSreetMap format, which is essentially an XML. CARLA can convert this file to OpenDRIVE format and ingest it as any other OpenDRIVE map using the OpenDRIVE Standalone Mode. The process is quite straightforward.
2.1.install python3.7 & CALRA Python API
python3.7
2.2.Osm2Odr.convert
import glob
import os
import sys
try:
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
import carla
vertex_distance = 1.0
max_road_length = 50.0
wall_height = 0.1
extra_width = 0.1
if __name__ == '__main__':
f = open("../map/boyuanRoad.osm",'r',encoding='utf-8')
osm_data = f.read()
settings = carla.Osm2OdrSettings()
xodr_data = carla.Osm2Odr.convert(osm_data,settings)
f=open("../map/boyuanRoad.xodr",'w',encoding='utf-8')
f.write(xodr_data)
f.close()
2.3.效果图
创新港.osm->创新港.xodr,效果不佳