sumo交通仿真教程系列(一):路网的建立

2,769 阅读8分钟

参考sumo官方文档进行的总结

路网的建立主要有三种途径,一种是自己手工搭建,第二种是建立抽象路网的生成,第三种是从第三方导入(比如OSM地图)。

这里我们只介绍第一种用XML手工搭建的方法(不推荐用neteditor用图形化界面进行搭建,比较麻烦)。

路网有节点和连边组成,所以建立路网先要搞清楚如何建立节点和连边。在sumo里,节点和连边会分开建立,最后统一用netconvert工具把定义好的节点和连边转化成路网。

节点的建立

节点主要是用来表征路口和连接点,文件扩展名为.node.xml节点的属性如下:

Attribute NameValue TypeDescription
**id**id (string)The name of the node
**x**floatThe x-position of the node on the plane in meters
**y**floatThe y-position of the node on the plane in meters
zfloatThe z-position of the node on the plane in meters
typeenum ( "priority", "traffic_light", "right_before_left", "unregulated", "priority_stop", "traffic_light_unregulated", "allway_stop", "rail_signal", "zipper", "traffic_light_right_on_red", "rail_crossing")An optional type for the node
tlTypeenum ( **"static"**, "actuated", "delay_based")An optional type for the [traffic light algorithm](https://sumo.dlr.de/docs/Simulation/Traffic_Lights.html#actuated_traffic_lights)
tlLayoutenum ( **"opposites"**, "incoming", "alternateOneWay")An optional layout for the traffic light plan (see below)
tlid (string)An optional id for the traffic light program. Nodes with the same tl-value will be joined into a single program
radiuspositive float;optional turning radius (for all corners) for that node in meters
(default 1.5)
shapeList of positions; each position is encoded in x,y or x,y,z in meters (do not separate the numbers with a space!).A custom shape for that node. If less than two positions are given, netconvert will reset that node to use a computed shape.
keepClearboolWhether the [junction-blocking-heuristic](https://sumo.dlr.de/docs/Simulation/Intersections.html#junction_blocking) should be activated at this node
(default true)
rightOfWaystringSet algorithm for computing [#Right-of-way](https://sumo.dlr.de/docs/Networks/PlainXML.html#right-of-way). Allowed values are
default

and

edgePriority
controlledInnerlist of edge idsEdges which shall be controlled by a joined TLS despite being incoming as well as outgoing to the jointly controlled nodes

常见的例子:

<nodes> <!-- The opening tag -->

  <node id="0" x="0.0" y="0.0" type="traffic_light"/> <!-- def. of node "0" -->

  <node id="1" x="-500.0" y="0.0" type="priority"/> <!-- def. of node "1" -->
  <node id="2" x="+500.0" y="0.0" type="priority"/> <!-- def. of node "2" -->
  <node id="3" x="0.0" y="-500.0" type="priority"/> <!-- def. of node "3" -->
  <node id="4" x="0.0" y="+500.0" type="priority"/> <!-- def. of node "4" -->

  <node id="m1" x="-250.0" y="0.0" type="priority"/> <!-- def. of node "m1" -->
  <node id="m2" x="+250.0" y="0.0" type="priority"/> <!-- def. of node "m2" -->
  <node id="m3" x="0.0" y="-250.0" type="priority"/> <!-- def. of node "m3" -->
  <node id="m4" x="0.0" y="+250.0" type="priority"/> <!-- def. of node "m4" -->

</nodes> <!-- The closing tag -->

交通信号灯

对于交通信号灯节点,netconvert会生成一个默认的交通信号灯程序。该模拟可以加载其他可以替代使用的程序。

tlType

如果省略节点的tlType,则将其设置为static。可以使用选项--tls.default-type <STRING>更改此默认值。

  • static:交通信号灯的每个阶段都会持续固定的时间
  • actuated:根据自动添加的感应环路的流量测量结果,绿相可能会延长。

tlLayout

如果省略节点的tlLayout,则将其设置为opposites。可使用选项--tls.layout <STRING>更改此默认设置。

  • opposites:相反方向的道路会同时获得绿灯。左转弯(与相反的流发生冲突)要么具有"green-with-conflict",要么具有自己的相位。
  • incoming:每条进入的道路都有自己的绿色阶段 
  • alternateOneWay:此程序适用于连接的控制器,该控制器调节从工作区(或狭窄道路)的两个或更多侧面交替单向访问。每条进入的道路都有自己的绿色阶段,根据工作区域的大小,有一个全红色阶段,以便在下一个方向启动之前清除交通。

节点类型

如果省略节点的类型,netconvert会自动猜测该节点的类型, 但可能不是您想要的类型。以下类型是可能的,任何其他字符串都将计为错误,并在程序停止时产生:

  • priority:处于低优先级边缘的车辆必须等待,直到处于高优先级边缘的车辆通过路口。
  • traffic_light:交汇点由交通信号灯控制(如果冲突的链接同时亮绿灯,则使用优先级规则来避免冲突)。 
  • right_before_left:车辆将让从其右侧驶来的车辆通过。
  • unregulated:交汇处完全不受管制-所有车辆可能在没有制动的情况下通过;禁用了相交处的碰撞检测,但会检测到并有可能发生相交以外的碰撞。 
  • traffic_light_unregulated:交汇处由交通信号灯控制,没有任何其他规则。如果使用不安全的信号计划,可能会导致碰撞。请注意,将永远不会检测到相交处的碰撞。 
  • priority_stop:这就像是 优先路口,但次要路段上的车辆始终必须先停车,然后才能通过 。
  • allway_stop:此路口的工作方式就像一个all way stop。
  • rail_signal:此路口由铁路信号控制。这种连接/控制类型仅对导轨有用。 
  • zipper:此连接点表示车道数在这个节点处减少,需要进行merge操作 。 
  • rail_crossing:此路口为铁路道口建模。它将使火车不受阻碍地通过,并在火车接近时通过交通信号限制车辆。 
  • traffic_light_right_on_red:该结由交通灯作为用于类型控制 traffic_light。此外,在安全的情况下(在停止一次之后),右转车辆可以在任何阶段行驶。此行为称为“ 右转红灯”。

路权

每个路口的通行权计算都是基于节点的type的。如果types为priority和priority_stop,路权取决于出边和入边的优先级的大小。边的优先级的大小同时速度和边的权值影响。通常交通中优先级最高的边会得到路权。

modifying Right-of-Way:可以通过指定其他禁止条件和指定connection属性 来定制路权pass="true"。 从版本1.1.0开始,可以使用-attribute rightOfWay在两种模式之间切换从边缘优先级计算通行权的算法。

**rightOfWay =“default” :**如果不能单独依靠边缘的优先级属性来确定通行权,则此模式很有用。它根据优先级,速度和 laneNumber对边缘进行排序。确定具有最高位置的2个输入边,它们将接收通行权。所有其他边缘将被分类为次要边缘。

rightOfWay =“ edgePriority” :此模式对于通过调整边缘优先级属性来定制通行权很有用。边缘优先级不同的流之间的关系将完全由边缘优先级确定。对于相等优先级的值,还将评估转向。  

特别案例: 为了对转弯优先道路建模,构成该道路的所有入站和出站边必须具有比未优先道路边缘更高的优先值。 对于环岛,环岛内的边缘始终比从外部进入的边缘具有通行权。 当来自同一边的两条车道接近同一目标车道时,路权取决于节点类型: 如果类型是zipper,则两个车道将相互对称反应,并且车辆将执行zipper合并。 否则,左车道将具有优先权,而右车道将让行。

连边的描述

连边文件拓展名为.edg.xml,属性如下:

Attribute NameValue TypeDescription
**id**id (string)The id of the edge (must be unique)
fromreferenced node idThe name of a node within the nodes-file the edge shall start at
toreferenced node idThe name of a node within the nodes-file the edge shall end at
typereferenced type idThe name of a type within the [SUMO edge type file](https://sumo.dlr.de/docs/SUMO_edge_type_file.html)
numLanesintThe number of lanes of the edge; must be an integer value
speedfloatThe maximum speed allowed on the edge in m/s; must be a floating point number (see also "Using Edges' maximum Speed Definitions in km/h")
priorityintThe priority of the edge. Used for [#Right-of-way](https://sumo.dlr.de/docs/Networks/PlainXML.html#right-of-way)-computation
lengthfloatThe length of the edge in meter
shapeList of positions; each position is encoded in x,y or x,y,z in meters (do not separate the numbers with a space!).If the shape is given it should start and end with the positions of the from-node and to-node. Alternatively it can also start and end with the position where the edge leaves or enters the junction shape. This gives some control over the final junction shape. When using the option **--plain.extend-edge-shape** it is sufficient to supply inner geometry points and extend the shape with the starting and ending node positions automatically
spreadTypeenum ( "right", "center", "roadCenter")The description of how to compute lane geometry from edge geometry. See [SpreadType](https://sumo.dlr.de/docs/Networks/PlainXML.html#spreadtype)
allowlist of vehicle classesList of permitted vehicle classes (see [access permissions](https://sumo.dlr.de/docs/Networks/PlainXML.html#road_access_permissions_allow_disallow))
disallowlist of vehicle classesList of forbidden vehicle classes (see [access permissions](https://sumo.dlr.de/docs/Networks/PlainXML.html#road_access_permissions_allow_disallow))
widthfloatlane width for all lanes of this edge in meters (used for visualization)
namestringstreet name (need not be unique, used for visualization)
endOffsetfloat >= 0Move the stop line back from the intersection by the given amount (effectively shortening the edge and locally enlarging the intersection)
sidewalkWidthfloat >= 0Adds a sidewalk with the given width (defaults to -1 which adds nothing).

下面是一个具体的例子:

<edges>

  <edge id="1fi" from="1" to="m1" priority="2" numLanes="2" speed="11.11"/>
  <edge id="1si" from="m1" to="0" priority="3" numLanes="3" speed="13.89"/>
  <edge id="1o" from="0" to="1" priority="1" numLanes="1" speed="11.11"/>

  <edge id="2fi" from="2" to="m2" priority="2" numLanes="2" speed="11.11"/>
  <edge id="2si" from="m2" to="0" priority="3" numLanes="3" speed="13.89"/>
  <edge id="2o" from="0" to="2" priority="1" numLanes="1" speed="11.11"/>

  <edge id="3fi" from="3" to="m3" priority="2" numLanes="2" speed="11.11"/>
  <edge id="3si" from="m3" to="0" priority="3" numLanes="3" speed="13.89"/>
  <edge id="3o" from="0" to="3" priority="1" numLanes="1" speed="11.11"/>

  <edge id="4fi" from="4" to="m4" priority="2" numLanes="2" speed="11.11"/>
  <edge id="4si" from="m4" to="0" priority="3" numLanes="3" speed="13.89"/>
  <edge id="4o" from="0" to="4" priority="1" numLanes="1" speed="11.11"/>

</edges>

车道特定的定义

您可以允许/禁止显式车辆类别使用车道。可以通过在边沿描述文件中指定车道列表以及在这些边沿车道中允许/禁止的车类,来在边沿描述文件中指定允许车道上的哪些车辆类别的信息。
假设您想只允许总线使用上例中的边“ 2si”的最左侧通道。只需将此边的定义更改为:
... previous definitions ...
  <edge id="2si" from="m2" to="0" priority="3" numLanes="3" speed="13.89">
    <lane index="2" allow="bus"/>
  </edge>
... further definitions ...
如果您想禁止乘用车和出租车,请按照以下代码片段进行操作:
... previous definitions ...
  <edge id="2si" from="m2" to="0" priority="3" numLanes="3" speed="13.89">
    <lane index="2" disallow="passenger taxi"/>
  </edge>
... further definitions ...
车道的定义包含以下可选属性:

Attribute NameValue TypeDescription
**index**intThe enumeration index of the lane (0 is the rightmost lane, -1 is the leftmost one)
allowlist of vehicle classesList of permitted vehicle classes (see [access permissions](https://sumo.dlr.de/docs/Networks/PlainXML.html#road_access_permissions_allow_disallow))
disallowlist of vehicle classesList of forbidden vehicle classes (see [access permissions](https://sumo.dlr.de/docs/Networks/PlainXML.html#road_access_permissions_allow_disallow))
speedfloatspeed in meters per second
widthfloatwidth in meters (used for visualization)
endOffsetfloat >= 0Move the stop line back from the intersection by the given amount (effectively shortening the lane and locally enlarging the intersection)
shapeList of positions; each position is encoded in x,y or x,y,z in meters (do not separate the numbers with a space!).A custom shape for this lane.

Note: The lane lengths will be averaged in the generated network. Lane-changing will ignore gaps between lanes.

未完待续。。。