OSM(OpenStreetMap)使用简述

该博客介绍了如何利用开源地图制作工具OSM和仿真引擎CARLA来搭建交通场景仿真。首先,从OSM网站下载指定区域的地图数据,然后通过CARLA提供的osm2odr工具将OSM文件转换为XODR格式,适用于CARLA的仿真环境。在转换过程中,详细展示了Python代码实现。最后,尽管转换示例中提到的效果可能不尽如人意,但整个过程展示了将真实世界地图数据引入交通场景仿真的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

python api

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,效果不佳

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值