Sumo学习日记-day2 路网编辑及仿真流程

Sumo学习日记-day2 路网编辑及各个文件说明

很久没有写博客了,因为最近比较忙碌,但是自己还是在不断的学习。最近对sumo学习的一些相关经验一直想写一个系列的博客跟大家分享,但是还没有一个具体的思路,目前是按照自己学习的一些路线跟大家分享,有错误的话大家多多担待!



路网编辑文件

Sumo的运行是离不开路网文件的,包括VISSIM在内的一系列交通仿真软件都是需要进行路网编辑的,这里先对路网文件进行一些具体的说明,也为后面Sumo的学习补充一些基础知识。


一、nod.xml文件

node是sumo中比较基础的节点,它一般表示道路的一个节点,学过其它仿真软件的话应该了解相关的概念。一般道路开始、结束点都是一个节点。nod.xml文件就是用来定义这些节点。

<?xml version="1.0" ?>
<nodes>
	<node id="1" x="0" y="0" type="traffic_light"/>
	<node id="2" x="0" y="300"/>
	<node id="3" x="0" y="1000"/>
	<node id="4" x="300" y="0"/>
	<node id="5" x="1000" y="0"/>
	<node id="6" x="0" y="-300"/>
	<node id="7" x="0" y="-1000"/>
	<node id="8" x="-300" y="0"/>
	<node id="9" x="-1000" y="0"/>
</nodes>

一个简单的交叉口路网的nod.xml文件就像上面所展示的一样,id表示节点的唯一ID,这个id不能重复,不然会报错,x和y分别表示节点的坐标(这个坐标比较坑,因为和traci里的坐标不一样),坐标以左下角为原点,x轴为横向,y轴为纵向。

二、 edg.xml

edge文件即edg.xml文件主要是定义路线信息,包括车道数量信息,主要是确定起始节点和结束节点以及是否允许换道,因为交叉口在靠近交叉口的地方不允许换道,所以需要定义多个节点。

<?xml version="1.0" ?>
<edges>
	<edge from="1" id="N_out_1" to="2" numLanes="2"/>
	<edge from="2" id="N_out_2" to="3" numLanes="2"/>
	<edge from="3" id="N_in_2" to="2" numLanes="2"/>
	<edge from="2" id="N_in_1" to="1" numLanes="3" allowChaning="false"/>
	<edge from="1" id="E_out_1" to="4" numLanes="3"/>
	<edge from="4" id="E_out_2" to="5" numLanes="3"/>
	<edge from="5" id="E_in_2" to="4" numLanes="3"/>
	<edge from="4" id="E_in_1" to="1" numLanes="3" allowChaning="false"/>
	<edge from="1" id="S_out_1" to="6" numLanes="2"/>
	<edge from="6" id="S_out_2" to="7" numLanes="2"/>
	<edge from="7" id="S_in_2" to="6" numLanes="2"/>
	<edge from="6" id="S_in_1" to="1" numLanes="3" allowChaning="false"/>
	<edge from="1" id="W_out_1" to="8" numLanes="3"/>
	<edge from="8" id="W_out_2" to="9" numLanes="3"/>
	<edge from="9" id="W_in_2" to="8" numLanes="3"/>
	<edge from="8" id="W_in_1" to="1" numLanes="3" allowChaning="false"/>
</edges>

三、rou.xml

rou.xml和nod.xml文件一样,是路网文件中不可缺少的一个文件。rou文件定义车辆信息(也可以是车流信息),一个完整的rou文件如下:

<?xml version="1.0" ?>
<routes>
	<vType accel="3.0" decel="6.0" id="CarA" length="5.0" minGap="1" maxSpeed="16.6" sigma="1" laneChangeMode="no"/>
	<vType accel="2.0" decel="6.0" id="CarB" length="7.5" minGap="1" maxSpeed="50.0" sigma="0.95"/>
	<vType accel="3.0" decel="6.0" id="CarC" length="5.0" minGap="1" maxSpeed="50.0" sigma="0.95"/>
	<vType accel="3.0" decel="6.0" id="CarD" length="7.5" minGap="1" maxSpeed="30.0" sigma="0.95"/>
	<route id="route1_1" edges="W_in_2 W_in_1 E_out_1 E_out_2"/>
	<route id="route1_2" edges="W_in_2 W_in_1 N_out_1 N_out_2"/>
	<route id="route1_3" edges="W_in_2 W_in_1 S_out_1 S_out_2"/>
	<route id="route2_1" edges="E_in_2 E_in_1 W_out_1 W_out_2"/>
	<route id="route2_2" edges="E_in_2 E_in_1 S_out_1 S_out_2"/>
	<route id="route2_3" edges="E_in_2 E_in_1 N_out_1 N_out_2"/>
	<route id="route3_1" edges="N_in_2 N_in_1 S_out_1 S_out_2"/>
	<route id="route3_2" edges="N_in_2 N_in_1 E_out_1 E_out_2"/>
	<route id="route3_3" edges="N_in_2 N_in_1 W_out_1 W_out_2"/>
	<route id="route4_1" edges="S_in_2 S_in_1 N_out_1 N_out_2"/>
	<route id="route4_2" edges="S_in_2 S_in_1 W_out_1 W_out_2"/>
	<route id="route4_3" edges="S_in_2 S_in_1 E_out_1 E_out_2"/>
</routes>

其中vType标签定义的是车辆类型,decel为减速度、id(唯一,sumo中所有关于id的东西最好都要唯一,不然容易报错),length表示车长,其余的一些属性官网上都有,链接:sumo官网对rou文件介绍

四、net.xml

net.xml不需要自己写,是通过rou.xml和nod.xml自动生成,当然如果你用sumo自带的路网编辑器,也会自动生成:

netconvert --node-files=xxx.nod.xml --edge-files=xxx.edge.xml --connection-files=xxx.con.xml --tllogic-files=xxx.add.xml --output-file=xxx.net.xml

可以使用cmd命令来生成net.xml文件,其中对应的文件名需要对应,各个文件也需要在同一文件夹下,不然无法生成。

四、其余xml文件

按理来说,一个基础的能运行的net.xml文件通过上述步骤就可以生成了,但是还需要一些细节方面的定义,如交叉口车道流向,交通信号灯配时及相位信息等。这些可以通过con.xml各种add.xml文件进行定义

1.con.xml

con.xml文件是定义各个车道在交叉口的流向的文件,具体如下:

<?xml version="1.0" ?>
<connections>
	<connection from="W_in_1" to="N_out_1" fromLane="2" toLane="1"/>
	<connection from="W_in_1" to="E_out_1" fromLane="1" toLane="1"/>
	<connection from="W_in_1" to="S_out_1" fromLane="0" toLane="0"/>
	<connection from="E_in_1" to="S_out_1" fromLane="2" toLane="1"/>
	<connection from="E_in_1" to="W_out_1" fromLane="1" toLane="1"/>
	<connection from="E_in_1" to="N_out_1" fromLane="0" toLane="0"/>
	<connection from="N_in_1" to="E_out_1" fromLane="2" toLane="2"/>
	<connection from="N_in_1" to="S_out_1" fromLane="1" toLane="1"/>
	<connection from="N_in_1" to="W_out_1" fromLane="0" toLane="0"/>
	<connection from="S_in_1" to="W_out_1" fromLane="2" toLane="2"/>
	<connection from="S_in_1" to="N_out_1" fromLane="1" toLane="1"/>
	<connection from="S_in_1" to="E_out_1" fromLane="0" toLane="0"/>
</connections>

其中fromLane是从该edge从右往左数第几条车道,toLane同理

2.add.xml

add.xml包括很多内容,这里介绍的主要是信号灯相关的add.xml的内容:

<?xml version="1.0" ?>
<additional>
	<tlLogic id="1" type="static" programID="tls_1" offset="0">
		<phase duration="35" state="rrrggrrrrggr"/>
		<phase duration="8" state="rrrrrgrrrrrg"/>
		<phase duration="3" state="rrryyyrrryyy"/>
		<phase duration="12" state="rGGrrrGGrrrr"/>
		<phase duration="8" state="GGGrrrGGGrrr"/>
		<phase duration="3" state="yyyrrryyyrrr"/>
	</tlLogic>
</additional>

id表示信号灯作用的交叉口id(是nod.xml定义的),programID="tls_1"表示信号灯id,offset表示信号灯偏置,state比较有意思,是从12点钟方向顺时针转动,分别为右转直行左转。duration表示持续时间。

五、sumocfg文件

<?xml version="1.0" ?>
<configuration>
	<input>
		<net-file value="test.net.xml"/>
		<route-files value="test.rou.xml"/>
		<additional-files value="outputConfig.add.xml"/>
	</input>
	<time>
		<begin value="0"/>
		<end value="7200"/>
		<step-length value="1"/>
	</time>
</configuration>

设置net文件和rou文件

总结

本文主要介绍了sumo中路网配置的流程及各个xml文件的含义。
欢迎大家交流

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
SUMO(Simulation of Urban MObility)是一种交通模拟工具,用于对城市交通系统进行建模和仿真。而OSM(OpenStreetMap)是一种开放源码的地图数据项目,由志愿者共同创建和维护。 在进行SUMO路网建模时,可以使用OSM作为基础数据源。首先,通过OSM可以获取到真实世界的道路网络数据,包括道路的形状、长度、连接关系以及车道数等信息。使用SUMO的OSM2SUMO工具,可以将OSM数据转换为SUMO所能识别的格式。这样,就可以在SUMO环境使用这些道路网络数据。 借助OSM数据进行SUMO路网建模,可以有效地模拟城市交通系统,从而进行交通流量、交通拥堵、交通信号灯以及交通规划等方面的仿真研究。通过将现实世界的道路网络数据导入SUMO,可以在SUMO设置车辆流量、车辆速度、路口信号灯、车辆行为等参数,并通过仿真模拟不同交通状况下的车辆运行情况。 SUMO路网建模可以帮助交通规划者和决策者更好地了解城市交通系统的运行机理,评估交通政策和规划对交通状况的影响,优化交通路网布局、信号灯配时等,以提高交通效率和减少拥堵问题。 综上所述,SUMO可以通过使用OSM的地图数据进行交通路网建模,从而进行城市交通系统的仿真研究和交通规划优化。使用OSM提供的道路网络数据,可以帮助SUMO模拟真实世界的交通状况,并为相关决策提供可靠的依据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值