SUMO仿真高级进阶系列一:利用OpenStreetMap生成地图

在快速入门系列中,贯穿始终例子的道路模型是我们自定义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

五、用sumo-gui查看生成的道路地图




原创文章,转载请注明!

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值