上图是一个简单的道路模型,在SUMO 中街道模型采用结点(Nodes)和线段(Edges)进行描述,例如一条街道至少需要两个结点和一条线段描述。这个道路模型比较简单,具体步骤如下:
XML Schema Definitions: http://sumo.sourceforge.net/xsd/nodes_file.xsd
其中id 是结点的标识号码,用于后面的程序调用使用,x和y都是坐标,其数值单位为m,描述了这些结点距离参考原点的距离。具体可以查看XML Schema Definitions里的内容。
ex_NODE.nod.xml
<nodes> <node id="node1" x="100.0" y="100.0" type="traffic_light"/> <node id="node2" x="400.0" y="100.0" type="priority"/> <node id="node3" x="700.0" y="100.0" type="traffic_light"/> <node id="node4" x="100.0" y="300.0" type="traffic_light"/> <node id="node5" x="400.0" y="300.0" type="traffic_light"/> <node id="node6" x="700.0" y="300.0" type="traffic_light"/> <node id="node7" x="100.0" y="600.0" type="traffic_light"/> <node id="node8" x="400.0" y="600.0" type="traffic_light"/> <node id="node9" x="700.0" y="600.0" type="traffic_light"/> <node id="node10" x="100.0" y="800.0" type="traffic_light"/> <node id="node11" x="400.0" y="800.0" type="traffic_light"/> <node id="node12" x="700.0" y="800.0" type="priority"/> </nodes>
XML Schema Definitions:http://sumo.sourceforge.net/xsd/edges_file.xsd
具体可以看XML Schema Definitions里的内容。注意Nolanes属性名称已改为numLanes。
ex_EDGE.edg.xml
<edges> <edge id="edgeR-0-0" from="node1" to="node2" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-0-1" from="node2" to="node3" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-0-0" from="node2" to="node1" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-0-1" from="node3" to="node2" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-0-0" from="node1" to="node4" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-0-0" from="node4" to="node1" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-0-1" from="node2" to="node5" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-0-1" from="node5" to="node2" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-0-2" from="node3" to="node6" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-0-2" from="node6" to="node3" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-1-0" from="node4" to="node5" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-1-1" from="node5" to="node6" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-1-0" from="node5" to="node4" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-1-1" from="node6" to="node5" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-1-0" from="node4" to="node7" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-1-0" from="node7" to="node4" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-1-1" from="node5" to="node8" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-1-1" from="node8" to="node5" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-1-2" from="node6" to="node9" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-1-2" from="node9" to="node6" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-2-0" from="node7" to="node8" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-2-1" from="node8" to="node9" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-2-0" from="node8" to="node7" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-2-1" from="node9" to="node8" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-2-0" from="node7" to="node10" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-2-0" from="node10" to="node7" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-2-1" from="node8" to="node11" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-2-1" from="node11" to="node8" priority="75" numLanes="2" speed="40" /> <edge id="edgeU-2-2" from="node9" to="node12" priority="75" numLanes="2" speed="40" /> <edge id="edgeD-2-2" from="node12" to="node9" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-3-0" from="node10" to="node11" priority="75" numLanes="2" speed="40" /> <edge id="edgeR-3-1" from="node11" to="node12" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-3-0" from="node11" to="node10" priority="75" numLanes="2" speed="40" /> <edge id="edgeL-3-1" from="node12" to="node11" priority="75" numLanes="2" speed="40" /> </edges>
netconvert --node-files=ex_NODE.nod.xml --edge-files=ex_EDGE.edg.xml --output-file=MySUMONet.net.xml
在terminal中输入sumo-gui,File->Open Network
路口细节:
至此,简单的自定义地图就实现了。