您的位置:首页 > 其它

SUMO文档006:初级教程(下)

2016-09-12 19:06 204 查看
这部分教程包含了使用一个例子网络的SUMO在交通分析方面的基本应用和必要函数讲解。

所有提到的文件都可以在安装文件目录:<SUMO_HOME>/docs/tutorial/quickstart 下找到,最新版本的可以在目录:<SUMO_HOME>/tests/complex/tutorial/quickstart/data/

实例描述

在这个例子中,将使用SUMO分析交通状况。这个交通网络包括4个出发地,4个目的地和2个没有信号控制的交叉口。每个方向的道路都是3个车道,并且每个车道的交通状况严格限制。在所有路口禁止掉头行为。较高的优先级已经给东行和西行的车辆。网络布局如图所示:



Fig.1.1: Network layout
在例子网络中针对交通需求有四种车辆类型(车A,B,C和D)。所有的司机都是50%完美的驾驶。相应的信息被列在表1.1中。在15:00到15:15的调查期间,每种类型的每辆车将每30秒从每个出发地到每个目的地。



Table 1.1 Vehicle types and vehicularcharacteristics in the example network

数据准备

在通过SUMO实施交通分析前,图1.1中的例子网络应该被转换成node-link(点连接)的基本网络,如图1.2所示。Node(点)的对等数据列在表1.2中。



Fig.1.2: Layout of the node-link based example network

Table1.2 Coordination data of the example network
一般来说,我们必须把给的信息转换成3个文件用于SUMO读取。其中两个文件包含网络信息,在SUMO中将被转变为node和link信息,通常命名后缀为.nod.xml和edg.xml文件。包含交通需求和路由信息的文件被命名为.rou.xml。另外,如果要求在十字路口的交通运动和车道连接的规范和链接类型是必需的,两个扩展名con.xml和typ.xml的文件包含。具体的文件组成如图1.3所示:



Fig.1.3: The required input files for the example network in SUMO
(*)链接的几何数据(Link geometry data)也可以定义在quickstart.edg.xml中。

(**)它是一个可选的文件。如果没有给出该文件,则将生成默认情况下的车道连接和交通运动。

网络编辑

Node

基于表1.2对等的数据和图1.2的基于网络的点连接,交叉口、出发地和目的地通过.nod.xml

给定的xy坐标值分别被编码为1-6和91-94. 虽然没有存在各自的交集, 由于车道节点的数量的变化需要添加1,2,4和5.虚拟节点911-914在分析网络上的交通进出表现时是需要的。如果需要的话(比如需要准确地几何定位或者检测器位置的规范),可以设置更多的虚拟节点。

在node文件里的属性的定义如下所示:(以下不翻译)

(a) id:the ID name of the node, defined by users with numbers, word strings or both.
(b) x:the x-coordinate location of the defined node (in meters)
(c) y:the y-coordinate location of the defined node (in meters)
(d) type:the signal control type of the defined node. It is an optional attribute anddefined
withpriority and traffic_light forunsignalized and signalized intersections respectively.
 
完整的node文件在列表1.1中列出:

<?xml version="1.0" encoding="UTF-8"?>
<nodes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/nodes_file.xsd">
<node id="91" x="-1000.0" y="1000.0" />
<node id="92" x="-1000.0" y="0.0" />
<node id="93" x="3000.0" y="0.0" />
<node id="94" x="+3000.0" y="+1000.0" />
<node id="911" x="-500.0" y="+1000.0" />
<node id="912" x="-500.0" y="0.0" />
<node id="913" x="+2500.0" y="0.0" />
<node id="914" x="2500.0" y="+1000.0" />
<node id="1" x="0.0" y="+1000.0" />
<node id="2" x="0.0" y="0.0" />
<node id="3" x="+1000.0" y="0.0" />
<node id="4" x="+2000.0" y="0.0" />
<node id="5" x="+2000.0" y="+1000.0" />
<node id="6" x="+1000.0" y="+1000.0" />
</nodes>


Listing 1.1 Formatof the node file of the example network (quickstart.nod.xml)

Link

就像其他交通仿真软件一样,在SUMO中道路表示为连接。为了定义link的铁证id,每一个link都被定义了一个数值、字符串或者两者。上游节点、下游节点和link类型存储在后缀为.edg.xml的文件中。每个link类型的信息也可以定义在后缀为.typ.xml和.edg.xml文件中。列表1.2展示了在实例中用到的link type文件还有其四个参数:

(a) id: defined by users withnumbers, word strings or both.
(b) priority: driving prioritybased on traffic regulations and is defined with numbers. The higher thenumber, the higher the priority for the respective road. The priorityinformation will override information from the node file,
if both of themexist.
(c) numLanes: number of laneson the respective road.
(d) speed: maximum allowedlink speed.
详细参数不翻译,看原文解释。

类型(a)和(b)是分别3车道和2车道的东西方向道路。类型(c)为低优先级的南北车道。【这里指的代码中的a、b、c】

<?xml version="1.0" encoding="UTF-8"?>
<types>
<type id="a" priority="3" numLanes="3" speed="13.889"/>
<type id="b" priority="3" numLanes="2" speed="13.889"/>
<type id="c" priority="2" numLanes="3" speed="13.889"/>
</types>


Listing1.2 Link type file of the example network (quickstart.typ.xml)
随着(link type)链接类型文件的使用,实例网络的连接文件生成。如列表1.3,定义的参数包括:

(a) id: link ID, defined byusers with numbers, word strings or both.
(b) from: ID of the upstreamnode of the respective link.
(c) to: ID of the downstreamnode of the respective link.
(d) type: ID of the link type,defined in the link type file.
(e) allow/disallow: ID of thevehicle group which is defined in the SUMO and might not be identical with thevehicle types defined by users. More information on the application of thisattribute is available in Section 4.2.

<?xml version="1.0" encoding="UTF-8"?>
<edges xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/edges_file.xsd">
<edge id="D1" from="911" to="91" type="a"/>
<edge id="D2" from="91" to="911" type="b"/>
<edge id="D3" from="912" to="92" type="a"/>
<edge id="D4" from="92" to="912" type="b"/>
<edge id="D5" from="913" to="93" type="a"/>
<edge id="D6" from="93" to="913" type="b"/>
<edge id="D7" from="914" to="94" type="a"/>
<edge id="D8" from="94" to="914" type="b"/>
<edge id="L1" from="1" to="911" type="a"/>
<edge id="L2" from="911" to="1" type="b"/>
<edge id="L3" from="2" to="912" type="a"/>
<edge id="L4" from="912" to="2" type="b"/>
<edge id="L5" from="4" to="913" type="a"/>
<edge id="L6" from="913" to="4" type="b"/>
<edge id="L7" from="5" to="914" type="a"/>
<edge id="L8" from="914" to="5" type="b"/>
<edge id="L9" from="5" to="6" type="a"/>
<edge id="L10" from="6" to="5" type="a"/>
<edge id="L11" from="6" to="1" type="a"/>
<edge id="L12" from="1" to="6" type="a"/>
<edge id="L13" from="3" to="2" type="a"/>
<edge id="L14" from="2" to="3" type="a"/>
<edge id="L15" from="6" to="3" type="c"/>
<edge id="L16" from="3" to="6" type="c"/>
<edge id="L17" from="4" to="3" type="a"/>
<edge id="L18" from="3" to="4" type="a"/>
</edges>


Listing1.3 Link file of the example network (quickstart.edg.xml)

Trafficmovements(交通状况)

给定的几何设计和逻辑交通状态都是默认的。在没有相应准则的时候,掉头转弯是可以的。默认的设置为每条链路的最右道路与响应的下游链路最右道路对其。针对特殊的交通状况和道路连接,一个后缀为.con.xml的文件是必须的。列表1.4展示了实例网络的响应的设置。每个参数的意义如下:

(a) from: ID of the link whichthe traffic movements will be specified.
(b) to: ID of the link whichis the downstream link of the above defined link.
(c) fromLane/toLane:lane number of the defined link in (a) and the lane number of the link in (b),which are connected.
例如,第一行<connection from="L2" to="L12"fromLane="0" toLane="0"/>和第二行<connection from="L2" to="L12"fromLane="0"
toLane="1"/>意味着Link L2的Lane 0只使用Link
L12的Lane 0和1(看图1.4).【貌似这里原文有错】

相反,图1.5展示了基于默认设置的交通状况。另一个例子在图1.6中展示,针对的是在Link
L9,L12和L16上的交通状况的规范。

急转弯的禁止智能进行全局定义,通过执行网络文件生成。详细解释会在1.3部分给出。

<?xml version="1.0" encoding="UTF-8"?>
<connections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/connections_file.xsd">
<connection from="L2" to="L12" fromLane="0" toLane="0"/>
<connection from="L2" to="L12" fromLane="0" toLane="1"/>
<connection from="L2" to="L12" fromLane="1" toLane="2"/>
<connection from="L4" to="L14" fromLane="0" toLane="0"/>
<connection from="L4" to="L14" fromLane="1" toLane="1"/>
<connection from="L4" to="L14" fromLane="1" toLane="2"/>
<connection from="L9" to="L11" fromLane="0" toLane="0"/>
<connection from="L9" to="L11" fromLane="1" toLane="1"/>
<connection from="L9" to="L11" fromLane="1" toLane="2"/>
<connection from="L9" to="L15" fromLane="1" toLane="1"/>
<connection from="L9" to="L15" fromLane="2" toLane="2"/>
<connection from="L16" to="L10" fromLane="0" toLane="0"/>
<connection from="L16" to="L10" fromLane="1" toLane="1"/>
<connection from="L16" to="L10" fromLane="1" toLane="2"/>
<connection from="L16" to="L11" fromLane="2" toLane="2"/>
<connection from="L12" to="L15" fromLane="0" toLane="0"/>
<connection from="L12" to="L15" fromLane="1" toLane="1"/>
<connection from="L12" to="L10" fromLane="1" toLane="0"/>
<connection from="L12" to="L10" fromLane="1" toLane="1"/>
<connection from="L12" to="L10" fromLane="2" toLane="2"/>
<connection from="L14" to="L16" fromLane="1" toLane="1"/>
<connection from="L14" to="L16" fromLane="1" toLane="0"/>
<connection from="L14" to="L16" fromLane="2" toLane="2"/>
<connection from="L14" to="L18" fromLane="0" toLane="0"/>
<connection from="L14" to="L18" fromLane="1" toLane="1"/>
<connection from="L14" to="L18" fromLane="1" toLane="2"/>
<connection from="L17" to="L16" fromLane="0" toLane="0"/>
<connection from="L17" to="L16" fromLane="1" toLane="1"/>
<connection from="L17" to="L16" fromLane="1" toLane="2"/>
<connection from="L17" to="L13" fromLane="1" toLane="0"/>
<connection from="L17" to="L13" fromLane="1" toLane="1"/>
<connection from="L17" to="L13" fromLane="2" toLane="2"/>
</connections>


Listing 1.4 Specification of traffic movements (quickstart.con.xml)



Fig. 1.4: Allowed traffic movements from Link L2 to Link L12 (with thespecified lane connection setting)



Fig. 1.5: Allowed traffic movements from Link L8 to Link L9 and fromLink L10 to Link L7 (default setting)



Fig. 1.6: The allowed traffic movements at Node 6

Networkgeneration(生成网络)

SUMO的网路文件后缀为.net.xml。根据前面生成的文件quiclkstart.nod.xml,quickstart.edg.xml,quickstart.con.xml和quickstart.typ.xml,可以通过SUMO的NETCONVERT程序生成网络文件。为了有效执行,包含输入文件名、输出文件名和其他需要动作的的配置文件应该被创建。如果这些文件和模块NETCONVERT没有在同一个目录,那么每个文件的绝对路径需要包含。配置文件的详细内容如列表1.6所示,命名为quickstart.netc.cfg。如果掉转头不允许,命令<no-turnarounds
value="true"/>应该被加入到配置文件中。如前所述,掉转头(u-turn)的禁止只能是全局设置。

<configuration>
<input>
<edge-files value="quickstart.edg.xml"/>
<node-files value="quickstart.nod.xml"/>
<type-files value="quickstart.typ.xml"/>
<connection-files value="quickstart.con.xml"/>
</input>
<output>
<output-file value="quickstart.net.xml"/>
</output>
<processing>
<no-turnarounds value="true"/>
</processing>
</configuration>


Listing1.6 Configuration file for generating the network file (quickstart.netc.cfg)
在我们的例子中,quickstart.net.xml通过执行下面的语句生成:

netconvert –c quickstart.netccfg


生成的文件可以通过SUMO-GUi进行查看是否创建正确。图1.7展示了急转弯被禁止,通过列表1.6中的命令。



Fig.1.7: The allowed traffic movements at Node 2 (with U-turn prohibition)

Trafficdemand(交通需求)

交通需求、路由数据及车辆类型数据都定义在后缀为.rou.xml的文件中。在例子网络中的响应格式在列表1.5中有展示。

VehicleTypes(车辆类型)

列表1.5展示出,根据表1.1的信息全部的车辆类型被首先定义。相关的参数如下:

(a) id: ID of the vehicle type, defined byusers with numbers, word strings or both;
(b) accel: maximum acceleration of therespective vehicle type (in m/s2);
(c) decal: maximum deceleration of therespective vehicle type (in m/s2);
(d) sigma: drivers’ imperfection indriving (between 0 and 1);
(e) length: vehicle length (in meters);
(f) maxSpeed: maximum vehicular velocity(in m/s);
(g) color: color of the vehicle type. Itis defined with 3 numbers (between 0 and 1) for red, green and bluerespectively. Values are separated by comma and in quotes with no space betweenthe values. For example, 1,0,0 represents the
red color, 0,1,0 representsgreen color and 0,0,1 represents blue color.
这些属性可以点到顺序,其中属性sigma针对所有车辆都定义为0.5.

<?xml version="1.0" encoding="UTF-8"?>
<routes>
<vType accel="3.0" decel="6.0" id="CarA" length="5.0" minGap="2.5" maxSpeed="50.0" sigma="0.5" />
<vType accel="2.0" decel="6.0" id="CarB" length="7.5" minGap="2.5" maxSpeed="50.0" sigma="0.5" />
<vType accel="1.0" decel="5.0" id="CarC" length="5.0" minGap="2.5" maxSpeed="40.0" sigma="0.5" />
<vType accel="1.0" decel="5.0" id="CarD" length="7.5" minGap="2.5" maxSpeed="30.0" sigma="0.5" />
<route id="route01" edges="D2 L2 L12 L10 L7 D7"/>
<route id="route02" edges="D2 L2 L12 L15 L18 L5 D5"/>
<route id="route03" edges="D2 L2 L12 L15 L13 L3 D3"/>
<route id="route04" edges="D4 L4 L14 L18 L5 D5"/>
<route id="route05" edges="D4 L4 L14 L16 L10 L7 D7"/>
<route id="route06" edges="D4 L4 L14 L16 L11 L1 D1"/>
<route id="route07" edges="D6 L6 L17 L13 L3 D3"/>
<route id="route08" edges="D6 L6 L17 L16 L11 L1 D1"/>
<route id="route09" edges="D6 L6 L17 L16 L10 L7 D7"/>
<route id="route10" edges="D8 L8 L9 L11 L1 D1"/>
<route id="route11" edges="D8 L8 L9 L15 L13 L3 D3"/>
<route id="route12" edges="D8 L8 L9 L15 L18 L5 D5"/>
<vehicle depart="54000" id="veh0" route="route01" type="CarA" color="1,0,0" />
<vehicle depart="54000" id="veh1" route="route02" type="CarA" />
<vehicle depart="54000" id="veh2" route="route03" type="CarA" />
<vehicle depart="54000" id="veh3" route="route04" type="CarA" />
<vehicle depart="54000" id="veh4" route="route05" type="CarA" />
<vehicle depart="54000" id="veh5" route="route06" type="CarA" />
<vehicle depart="54000" id="veh6" route="route07" type="CarA" />
<vehicle depart="54000" id="veh7" route="route08" type="CarA" />
<vehicle depart="54000" id="veh8" route="route09" type="CarA" />
<vehicle depart="54000" id="veh9" route="route10" type="CarA" />
<vehicle depart="54000" id="veh10" route="route11" type="CarA" />
<vehicle depart="54000" id="veh11" route="route12" type="CarA" />
<vehicle depart="54000" id="veh12" route="route01" type="CarB" color="1,0,0" />
<vehicle depart="54000" id="veh13" route="route02" type="CarB" />
<vehicle depart="54000" id="veh14" route="route03" type="CarB" />
<vehicle depart="54000" id="veh15" route="route04" type="CarB" />
<vehicle depart="54000" id="veh16" route="route05" type="CarB" />
<vehicle depart="54000" id="veh17" route="route06" type="CarB" />
<vehicle depart="54000" id="veh18" route="route07" type="CarB" />
...
</routes>


Listing 1.5 Traffic demand and route data(quickstart.rou.xml)

Trafficroutes(交通路由)

在定义了车辆类型信息后,交通路由数据同样也需要定义。相应的参数包括:

(a) id: ID of a certain routeand defined by users with numbers, word strings or both.
(b) edges: The sequence of thenames of the links, composing the defined route.

Trafficdemand(交通需求)

交通需求数据定义的四个参数

(a) depart: departure time ofa certain vehicle.
(b) id: ID of a certainvehicle and defined by users with numbers, word strings or both.
(c) route: the route used bythe defined vehicle;
(d) type: ID of the definedvehicle type.

Simulation(模拟)

SUMO进行交通模拟讷讷够通过两种方式(命令行和GUI)实现,如下所述。仿真过程的概述如图1.8所示。



Fig.1.8: Overview of traffic simulation process

命令行

当针对大型复杂的交通网络时,命令行是有效的执行交通仿真的手段。为了简化执行过程,建议路径、输入文件名、输出文件类型、输出路径、仿真时间等都在配置文件中吗,明确下来。针对例子,响应的配置文件如列表1.7所示,可以通过以下命令执行仿真:

sumo –c quickstart.sumocfg


 

<?xml version="1.0" encoding="iso-8859-1"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/sumoConfiguration.xsd">
<input>
<net-file value="quickstart.net.xml"/>
<route-files value="quickstart.rou.xml"/>
</input>
<time>
<begin value="54000"/>
<end value="54900"/>
</time>
<time-to-teleport value="-1"/>
</configuration>


Listing 1.7 Configuration file for thetraffic simulation of the example network (quickstart.sumo.cfg)

我们使用命令<time-to-teleport value="-1"/>,去禁止在交叉口等待多时的车辆自动擦除。

SUMO-GUI

SUMO-GUi是另一种运行交通仿真的方式。执行过程中,车辆运动和交通处理过程都能够直观的观察到,可能的瓶颈问题也可以及时发现。执行动作所需的配置文件如Table 1.9是需要的。书记SUMO-gui.exe就能激活程序。通过打开配置文件既可以激活程序,通过点击绿色三角按钮运行。用户可以随时点击红色方块按钮停止程序。只要程序没有运行完,就可以接着运行。插图例子如图1.9所示。



Fig.1.9: Illustration of the example network in SUMO-GUI
NOTE:

如果你通过SUMO-GUI运行的教程,可能整个网络可以看到但是看不到车辆,因为视觉焦点非常远。你需要通过鼠标右键进行调整焦距(zoom),以便能看到你车辆。还有,你最好设置延迟大于0【原文好像是不需要设置大于零】,否则摸你很快结束,你看不到车辆的运动。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: