在快速入门系列中,贯穿始终例子的道路模型是我们自定义map生成的,为了更接近实际又减少工作量,我们可以用OpenStreetMap来生成地图。
一、利用OpenStreetMap得到osm文件
官方提供了用命令行的方式获得osm文件,具体见如下链接:Downloading a Rectangular Area Using the command line
这里我们直接来到OpenStreetMap的官网:OpenStreetMap
手动选择一个区域,输出osm文件。
二、利用JOSM软件,根据自身需要进行微调
JOSM官网:http://josm.openstreetmap.de/
三、加入交通灯
在JOSM中可以读到交通节点的id,点击交通灯所在位置,例如下图圈出的红点位置交通灯的id为1480362569
获取所有交通灯所在位置id后,编写tls-controlled-nodes.nod.xml文件
<nodes>
<node id="2305552583" type="traffic_light"/>
<node id="700709793" type="traffic_light"/>
<node id="2156292510" type="traffic_light"/>
<node id="1480362569" type="traffic_light"/>
<node id="700709810" type="traffic_light"/>
<node id="1480382895" type="traffic_light"/>
<node id="1480382720" type="traffic_light"/>
<node id="700709830" type="traffic_light"/>
<node id="700709776" type="traffic_light"/>
<node id="700709782" type="traffic_light"/>
<node id="1480382607" type="traffic_light"/>
<node id="1230462135" type="traffic_light"/>
<node id="1230462067" type="traffic_light"/>
<node id="2025035363" type="traffic_light"/>
<node id="2025035353" type="traffic_light"/>
<node id="667356834" type="traffic_light"/>
<node id="2025035359" type="traffic_light"/>
<node id="2024934554" type="traffic_light"/>
<node id="1480362632" type="traffic_light"/>
<node id="667356797" type="traffic_light"/>
<node id="1480382611" type="traffic_light"/>
<node id="1480362529" type="traffic_light"/>
<node id="868610539" type="traffic_light"/>
<node id="2305421779" type="traffic_light"/>
<node id="2305421769" type="traffic_light"/>
<node id="1477404082" type="traffic_light"/>
<node id="2305421783" type="traffic_light"/>
<node id="1477404020" type="traffic_light"/>
<node id="2025062497" type="traffic_light"/>
<node id="2025062397" type="traffic_light"/>
<node id="2305552331" type="traffic_light"/>
</nodes>
四、生成道路模型文件
首先将osm文件转换成sumo的道路模型文件:
netconvert --osm-files map.osm.xml -o map.net.xml
在地图中加入交通灯:
# 1. Import the OSM file to SUMO, discarding TLS information.
netconvert --osm-files map.osm.xml --output-file map-without-tls.net.xml --osm.discard-tls
# 2. Set traffic light information.
netconvert --sumo-net-file map-without-tls.net.xml --node-files tls-controlled-nodes.nod.xml --output-file map-with-tls.net.xml
本文介绍如何利用OpenStreetMap获取osm文件,并通过JOSM软件进行微调,接着详细说明如何在SUMO中加入交通灯及生成道路模型文件的过程。
810

被折叠的 条评论
为什么被折叠?



