绕圈环境
https://sumo.dlr.de/docs/Tutorials/Driving_in_Circles.html
创建一个圆环
创建需求(路由)文件
<routes> <vType id="car" type="passenger" length="5" accel="3.5" decel="2.2" sigma="1.0"/> <flow id="carflow" type="car" beg="0" end="0" number="5" from="edge1" to="edge2"/> </routes>
修改网络文件的边的id,为edge1和edge2,便于路由文件识别。修改前确保输入法为英文
之后创建可视化文件,查看结果
<configuration> <input> <net-file value="222.net.xml"/> <route-files value="222.rou.xml"/> </input> </configuration>
创建额外文件,以add.xml表示,它不属于网络文件
<additionals> <rerouter id="rerouter_0" edges="edge1"> <interval end="1e9"> <destProbReroute id="edge2"/> </interval> </rerouter> <rerouter id="rerouter_1" edges="edge2"> <interval end="1e9"> <destProbReroute id="edge1"/> </interval> </rerouter> </additionals>
然后在可视化文件的input标签上添加,使得最终显示为一个循环圈。
<additional-files value="222.add.xml"/>
创建另外一个圈,并建立路径。
路径上添加车辆流
修改车辆数和结束时间
建立循环圈路由信息,其中E6为选择的边,
对应的下一条边,和时间
同样操作gneE8,得到一个循环,使用ctrl+shift+a,保存add.xml文件。
竞赛环境
https://sumo.dlr.de/docs/Tutorials/SUMOlympics.html
创建一条赛道,两个点的坐标分别为0,0和1000,0
添加特殊赛道
额外添加一条赛道
取消整体勾选并选择某一赛道
修改最上一个赛道只允许火车,靠下的对应赛道只允许passenger
切换为赛道整体选中方式,点击将赛道分割,设置分割点为900,0
设置前一段线条为beg,后一段线条为end
创建红绿灯
修改交通灯参数
保存net.xml后,创建rou.xml文件,内容如下
<routes> <vType id="pkw" length="5" maxSpeed="50" accel="2.6" decel="4.5" speedDev="0.2" sigma="0.2" vClass="passenger"/> <vType id="bus" length="15" maxSpeed="30" accel="1.2" decel="2.5" sigma="0.1" speedDev="0.1" vClass="bus"/> <vType id="tram" length="40" maxSpeed="13" accel="0.8" decel="0.5" sigma="0.1" speedDev="0.1" vClass="rail_urban"/> <vType id="bike" length="1.8" width="0.8" maxSpeed="7.5" accel="0.8" decel="1.5" sigma="0.5" speedDev="0.5" vClass="bicycle"/> <route id="r1" edges="beg end" /> <vehicle id="pkw_starter" type = "pkw" depart="0" departPos="-0.01" route="r1"/> <vehicle id="bus_starter" type = "bus" depart="0" departPos="-0.01" route="r1"/> <vehicle id="tram_starter" type = "tram" depart="0" departPos="-0.01" route="r1"/> <vehicle id="bike_starter" type = "bike" depart="0" departPos="-0.01" route="r1"/> <flow id="pkw" type="pkw" from="beg" to="end" begin="0" end="0" number="65" departPos="last"/> <flow id="bus" type="bus" from="beg" to="end" begin="0" end="0" number="4" departPos="last"/> <flow id="tram" type="tram" from="beg" to="end" begin="0" end="0" number="1" departPos="last"/> <flow id="bike" type="bike" from="beg" to="end" begin="0" end="0" number="99" departPos="last"/> </routes>
创建sumocfg文件,内容如下
<?xml version="1.0" encoding="UTF-8"?> <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://sumo.sf.net/xsd/sumoConfiguration.xsd"> <input> <net-file value="111.net.xml"/> <route-files value="111Walks.rou.xml,111.rou.xml"/> </input> <processing> <lateral-resolution value="1." /> </processing> </configuration>
其中的111Walks.rou.xml,由python脚本生成,python脚本如下
outfile = "111Walks.rou.xml" startEdge = "beg" endEdge = "end" # Startzeit departTime = 0. # Startposition departPos = -30. # Anzahl Fussgaenger numberTrips = 200 # Generiere XML Datei xml_string = "<routes> " for i in range(numberTrips): xml_string += ' <person depart="%f" id="p%d" departPos="%f"> ' % (departTime, i, departPos) xml_string += ' <walk edges="%s %s"/> ' % (startEdge, endEdge) xml_string += ' </person> ' xml_string += "</routes> " with open(outfile, "w") as f: f.write(xml_string)