刚看到sumo,我的心态是崩溃的,网上的资料也很少,不知道如何下手。好在本蓝灵机一动,找到了示例文件,模仿着弄了一下,成功跑了起来。
首先,一个仿真模型需要的基本文件如下:
网上冲浪的时候发现很多选手不知道这几个文件怎么生成。很简单,去示例文件里复制就好,然后重命名,修改里面的代码。
net文件用编辑器创建就好,简单快速,有点像vissim
rou文件是车流文件,定义车辆属性就好。
<routes>
<vType id="type1" accel="0.8" decel="4.5" sigma="0.5" length="5" maxSpeed="70"/>
<vehicle id="0" type="type1" depart="0" color="1,0,0">
<route edges="1 6"/>
</vehicle>
</routes>
代码具体代表什么,我们这里不过多讨论,但是车辆轨迹要说明一下:
<route edges="1 6"/>
1和6代表从1号边驶向6号边,在此强调,边的id一定要认真修改,不要使用默认的。我这里用顺时针编号。
sumocfg文件是仿真运行文件,这里主要是为了把路网和其他属性文件链接在一下,代码如下:
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
<input>
<net-file value="1.net.xml"/>
<route-files value="1.rou.xml"/>
</input>
<output>
<write-license value="true"/>
</output>
<time>
<begin value="0"/>
<end value="10000"/>
</time>
<processing>
<default.speeddev value="0"/>
</processing>
<report>
<duration-log.disable value="true"/>
<no-step-log value="true"/>
</report>
</configuration>
因为修改了文件名,所以这段代码大家看起来会很容易,这里不做过多解释。仿真的时候要设置延时,建议设置1000ms,否则捕捉不到这一辆车就结束了。