SUMO-车流文件-小总结

时间:2023-10-03 04:32:14

下面是关于SUMO 车流文件(router)总结

参考资料:

SUMO笔记

OMNeT++ & SUMO 学习记录(七)SUMO netedit 简单交通流仿真

人工定义router文件vType: 为车辆宏观类型定义,可定义车辆加速度、减速度、最大速度、车身长度length、最小间距minGap、跟车模型、换道模型和车辆类型vClass等参数,当需要定义若干辆参数相同的车辆时,可以使用该类型进行定义,使代码更简洁
<vType id="type1" accel="0.8" decel="4.5" sigma="0.5" length="10" maxSpeed="70" vClass="truck" />
route: 定义route模块
<route id="route0" color="1,1,0" edges="beg middle end rend"/>

Vtype和route都可以被后面的vehicle直接调用

vehicle:定义车辆属性,如车辆id、出发时间depart、类型type、起始速度departSpeed、起始车道departLane、目标车道 arrivalLane、车辆颜色color、途径的边route edges

Definition of Vehicles, Vehicle Types, and Routes

<routes> <vType id="type1" accel="0.8" decel="4.5" sigma="0.5" length="5" maxSpeed="70"/> <route id="route0" color="1,1,0" edges="beg middle end rend"/> <vehicle id="0" type="type1" route="route0" depart="0" color="1,0,0"/> <vehicle id="1" type="type1" route="route0" depart="0" color="0,1,0"/> </routes>
<routes> <vType id="human" accel="0.8" decel="4.5" sigma="0.5" length="5" maxSpeed="70" carFollowModel="IDM" minGap="0" laneChangeModel="SL2015" guiShape=passenger/wagon/> <vType id="rl" accel="0.8" decel="4.5" sigma="0.5" length="5" maxSpeed="50" carFollowModel="IDM" minGap="2" laneChangeModel="SL2015" guiShape=passenger/van color="1,0,0"/> <vehicle id="6" depart="6.00" type="human" color="1,0,0"> <route edges="112900344 495816620 7092572 88837212#0 88837212#1 772465688 7097575 509618633 772465689#0 772465689#1 509618632#0 509618632#1 7092058 772464742 772464743 7098674 7098684 7098995 509618636 32427728 229093498 776593864#0 776593864#1 32427747 328348976#0 328348976#1 229093496 732366972 732366973#0 732366973#1 732366973#2 7101463 7101476 396359618 509618641 184441375 774704947 774704946 7107530 7108072 7108070 7108059 7108057 7108065 7108067 7110993 112900349 320693546 112636752 320693567 7111060 889352152 7111064 7111056#0 7111056#1 270175564 320693597 7111087 7111085#0 7111085#1 85081174 7111074 7111071 320693540"/> </vehicle> </routes>

2. Flow+ turns

jtrrouter ,将 *.flows.xml 文件和 *.turns.xml 文件生成 *.rou.xml 文件

3. randomTrips.py

手动定义router文件需要一条一条的去规划车辆行驶的路径,但是trip文件只需要说明起始点,SUMO的duarouter.exe工具会自动计算最优化路径并且生成router文件。模块SUMO-ROUTER读取将要模拟的一组虚拟群体的出发时间,起点和目的地,然后使用Dijkstra路由算法计算在交通网络中的最优路线。

这里需要介绍randomTrips生成trip文件的方法。

randomTrips.py 为给定的网络生成一组随机trips(选项-n),通过随机或者按照特定分布选择soruce edge和destination edge来生成 .trips.xml 文件。生成的随机trips在【开始时间--b,结束时间--e】均匀分布,行程数量由repetition rate (option-p, default 1)决定

(1)随机可重复性

--seed:保证随机行程的可重复性

(2)【边】选择概率

--fringe-factor:增加行程在网络边缘开始或者结束的概率,比如If the value10 is given, edges that have no successor or no predecessor will be 10 times more likely to be chosen as start- or endpoint of a trip. This is useful when modelling through-traffic which starts and ends at the outside of the simulated area.

此外,选择edge概率还可以通过以下参数进行调节:

edge length (option -l), 边长by number of lanes (option -L) 车道数edge speed (exponentially, by option --speed-exponent) 限速generic edge parameter (option --edge-param)direction of travel (option --angle-factor and --angle) 行程方向

更多信息:python tools/randomTrips.py --help

(3)Arrival rate 到达率

通过--period控制,(tf-ts)/n表示让n辆车在ts~tf之间出发,如果(tf-ts)/n<1则表明在某个时刻多辆车会同时到达(multiple arrivals per second)

例如:-b ts -e tf -p (tf-ts)/n

如果道路通行能力不足以容纳该数量的车辆,或者网络未完全连接(在这种情况下,某些产生的行程将是无效的),则实际的出发次数可能会更少

此外,还可以使用--binomial randomized the arrivals

(4)Validated routes and trips

--route-file, an output file with valid vehicle routes will be generated,自动调用duarouterin the background to turn the random trips into routes and automatically discard disconnected trips。另外,可能需要增加行程数量来弥补disconnected trips 来带的行程减少问题

有时候,to obtain validated trips会比validated routes更好

(5)生成车辆及参数设置

--trip-attributes<STRING>, additional parameters can be given to the generated vehicles (可参考上述vehicle parameter settings)

python tools/randomTrips.py -n <net-file> --trip-attributes="departLane=\"best\" departSpeed=\"max\" departPos=\"random\""

(6)通过外部文件(type.add.xml)设置车辆类型vehicle type

通过aditional-file 指定车辆类型,利用--additional-file导入这个文件type.add.xml

<additional> <vType id="myType" maxSpeed="27" vClass="passenger"/> </additional>

python tools/randomTrips.py -n <net-file> --trip-attributes="type=\"myType\"" --additional-file <add-file> --edge-permission passenger

其中 --edge-permission 确保随机的start edge和arrival edge允许特定的车辆类别

关于行人:to generate random pedestrian traffic instead of vehicular traffic, the option--pedestriansmay be used. It is recommended to combined this with the option--max-distanceto avoid walks of excessive length. See Simulation/Pedestriansfor additional information on the simulation of pedestrians.

关于vehicle-class:should only be used as a quick shorthand to generate trips for the standard type of the given vehicle class since it places a standard vType definition in the generated trips file.

(7)自动生成车辆类型vehicle type

By setting the option--vehicle-classa vehicle type definition that specifies vehicle class will be added to the output files.

例1:python tools/randomTrips.py --vehicle-class bus

就是:<vType id="bus" vClass="bus"/>

例2: python tools/randomTrips.py --vehicle-classbus --trip-attributes = "maxSpeed=\"27.8\""

就是:<vType id="bus" vClass="bus" maxSpeed="random"/>

(8)生成不同的交通模式(比如:行人)

Using the option --pedestrians will generated pedestrians instead of vehicles.Using the option --persontrips will generated persons with <persontrip> definitions. This allows to specify the available traffic modes and thus use IntermodalRouting to decided whether they use public transport, a personal car or walking.walking or public transport: --trip-attributes "modes=\"public\""walking, public transport or car --trip-attributes "modes=\"public car\""

(9)Intermediate way points

要在网络内生成longer trips的行程,可以使用选项--intermediate <INT>生成中间航路点,从而在trip中增加via-edges

(10)Customized Weights 自定义权重

权重文件:--weights-prefix demo.src.xml

改变出发、到达和途径边的概率(<prefix>.src.xml, <prefix>.dst.xml, <prefix>.via.xml)

上述文件可以在sumo-gui中可视化

下面是一个.src.xml,指定edge to be selected as from edge

<edgedata> <interval begin="0" end="10"/> <edge id="a" value="0.5"/> <edge id="b" value="0.5"/> </interval> </edgedata>

(11) 基于xx.net.xml和xx.trips.xml,利用duarouter.exe生成xx.rou.xml

/usr/local/share/sumo/bin$ ./duarouter -n /home/intel/Downloads/map.net.xml -t /home/intel/Downloads/map.trips.xml -o /home/intel/Downloads/map.rou.xml --ignore-errors

(12)仿真配置文件.sumo.cfg

<configuration> <input> <net-file value="map.net.xml"/> <route-files value="map.rou.xml"/> </input> <time> <begin value="0"/> <end value="360000"/> </time> </configuration>

修改.net.xml与.rou.xml

$ sumo-gui /home/intel/Downloads/map.sumo.cfg # sumo-gui打开仿真文件

(13)sumo-gui

Time:表示仿真时间

Delay: 控制仿真速度,一般取100ms~250ms

Scale Traffic:控制车流数量,数值越大表明车流量越大(独立于.rou.xml文件的车辆)

(14)跟车模型与换道模型

模拟是时间离散和空间连续的,并且在内部描述每个车辆的位置,即所在的车道和从起点开始的距离。当车辆移动时,使用跟车模型(car-following model)计算车速。

SUMO的车-驾驶员模型(Car-Driver Model)采用Gipps模型的扩展型。它能够显示交通的主要特征,如自由流和拥挤流。在每个时间步骤,车辆的速度适应于前车的速度,避免在随后的步骤中产生碰撞。

(15)TraCI

TraCI提供了一个控制正在运行的交通模拟的方法SUMO笔记TraCI提供了一个控制正在运行的交通模拟的方法基于Client/Server模型,SUMO作为Server ,外部脚本作为Client。启动SUMO,client 建立TCP连接,与指定的SUMO端口相连TraCI支持多个客户端,并按照顺序执行客户端的所有命令。SetOrder命令为客户端分配一个号码,并且在同一个时间片中,把来自不同Client的命令按照编号的顺序执行Client可以向SUMO发送命令来控制模拟的运行,控制命令可以是控制单个车辆的行为,也可以是询问当前环境情况。SUMO根据请求,返回一个响应的状态响应和一个附加的结果。Step 功能:Client使用Simulation Step命令来控制每一个时间片,如果操作执行完毕,则返回订阅的结果值,当所有的Client都发送完命令后,进入下一个时间片
TraCi连接SUMO

资讯排行榜

  • 每日排行
  • 每周排行
  • 每月排行