SUMO經驗(二)設計更為複雜的網路
阿新 • • 發佈:2022-01-16
本專案記錄sumo建立一個更為複雜網路的過程,SUMO版本:1.11.0,Python 3.7,使用Pycharm ide。主要參考官方文件:https://sumo.dlr.de/docs/Tutorials/quick_start.html
本文寫於2022-01-16
1 建立網路
我們來建立一個更為複雜的網路,需要設定junction與edge的一些常用引數,首先還是按照SUMO經驗(一)的方式,建立一個如圖所示的網路:
然後一番操作,實現了“增加反向車道”、“改變車道數量”
隨便設定設定節點的位置(我這裡設定每一個相距100m),隨便設定一下numOfLane,得到下圖
2 編寫demand檔案
demand當然也可以按照之前的方式設定,但是我們這裡採取另一種方式 - 編寫 demand.rou.xml 檔案,直接設定route以及vehicle。可以在netedit.exe檔案中檢視自己的edge名稱,我這裡分別為
所以設定helloDemand檔案為:
<?xml version="1.0" encoding="UTF-8"?> <!-- generated on 2022-01-16 08:45:57 by Eclipse SUMO netedit Version 1.11.0 --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd"> <route edges="E0 E1 E2" color="yellow" id="route_0"/> <route edges="E0 -E3" color="yellow" id="route_1"/> <vehicle id="vehicle_0" depart="0.00" route="route_1"/> <vehicle id="vehicle_1" depart="10.00" route="route_0"/> <vehicle id="vehicle_2" depart="0.00" route="route_1"/> <vehicle id="vehicle_3" depart="5.00" route="route_0"/> <vehicle id="vehicle_4" depart="10.00" color="blue" route="route_1"/> </routes>
然後編寫模擬檔案,hello.sumocfg如下,大意就是載入net-file以及route-files
<?xml version="1.0" encoding="UTF-8"?> <!-- generated on 2022-01-16 08:46:16 by Eclipse SUMO GUI Version 1.11.0 --> <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd"> <input> <net-file value="F:\PycharmProgram\sumo_helloWorld\hello.net.xml"/> <route-files value="F:\PycharmProgram\sumo_helloWorld\helloDemand.rou.xml"/> </input> </configuration>
點開sumo-gui,load simulation,調整延遲以及顯示模式(real world/ standard...),然後執行即可。
Appendix: 遇到問題
1 sumo-gui中報錯,顯示cannot load simulation,細看發現是說,edge E0 與 E2無法連線。開啟netedit.exe發現,在demand->route creation選項中,E0與E2確實是無法連線的,選中E0,E2會是紫色,代表edge conflict。該問題目前不知道怎麼回事,解決方案是重新建一遍網路。