一、安裝sumo
安裝用apt-get就行:
sudo apt-get install sumo sumo-tools sumo-doc
測試
輸入sumo:出現sumo版本信息
輸入sumo-gui:出現sumo的運行界面
二、使用sumo
http://blog.csdn.net/sxsj333/article/details/22855555
參考這個博客下的2和3
1.產生地圖:MySUMONet.net.xml
用nod和edg文件(描述點和邊的文件)生成地圖MySUMONet.net.xml,用sumo-gui (ctr+N)打開就是地圖了
netconvert --node-files=ex_NODE.nod.xml --edge-files=ex_EDGE.edg.xml --output-file=MySUMONet.net.xml
2.產生車輛移動模型:ex_ROU.rou.xml
2.1.指定起止點duarouter
用flow文件和前面生成的net文件產生車輛移動模型 ex_ROU.rou.xml
duarouter -n MySUMONet.net.xml -f ex_FLOW.flow.xml -o ex_ROU.rou.xml
ex_FLOW.flow.xml:重要的參數,end=10000,number=100 表示在10000個時間單位內,流出100輛車,也就是每隔100個時間單位流出一輛車
由於速度太快,需要設置Delay才能夠觀察到結果
<flows> <flow id="flow0" from="edgeD-2-0" to="edgeD-0-2" begin="0" end="10000" number="100" /> </flows>
2.2.指定路口轉彎概率jtrrouter
sudo jtrrouter --sinks="edgeD-0-2" --flows=ex_FLOW.flow.xml --turn-defaults 65,30,5 --net=MySUMONet.net.xml --output-file=1.rou.xml -b ${begin} -e ${end}
--turn-defaults 65,30,5 表示三個后繼街道的情況下選擇最右街道的概率是65%,
3.配置:ex_SUMO.sumo.cfg
將以上文件整合到一起的是配置文件,然后(ctr+O)打開就可以進行仿真了
這里10000是整個仿真的總時間
<configuration> <input> <net-file value="/home/song/sumoworkspace/move/MySUMONet.net.xml"/> <route-files value="/home/song/sumoworkspace/move/ex_ROU.rou.xml"/> <additional-files value=""/> <junction-files value=""/> </input> <output> <netstate-dump value="/home/song/sumoworkspace/move/ex_sumo.sumo.tr"/> <tripinfo-output value="output-tripinfos.xml"/> <emissions-output value="output-emissions.xml"/> <vehroute-output value="output-vehroutes.xml"/> </output> <time> <begin value="0"/> <end value="10000"/> <time-to-teleport value="-1"/> <srand value="23423"/> <route-steps value="-1"/> </time> <reports> <print-options value="false"/> </reports> </configuration>