This tutorial aims at first time Sumo users. We are building the simplest net possible and let a single car drive on it. All files mentioned here can also be found in the data/tutorial/hello directory in the Sumo repository (or distributions later than 0.9.5).
In sumo a street network consists of nodes (junctions) and edges (streets connecting the junctions). Thus, if we want to create a network with two streets, subsequent to each other, we need three nodes and two edges. We will see in the section on #Routes, why the simplest network cannot contain only one edge.
All nodes have at location (x- and y-coordinate, describing distance to the origin in meters) and an id for future reference. Thus our simple node file looks as follows
<nodes> <node id="1" x="-500.0" y="0.0" /> <node id="2" x="+500.0" y="0.0" /> <node id="3" x="+501.0" y="0.0" /> </nodes>
You can edit a file with a text editor of your choice and save this for instance as hello.nod.xml where .nod.xml is the default suffix for Sumo node files.
Now we are connecting the nodes with edges. This is as easy as it sounds, we have a source node id, a target node id, and an edge id for future reference. Edges are directed, thus every vehicle travelling this edge will start at fromnode and end at tonode.
<edges> <edge fromnode="1" id="1to2" tonode="2" /> <edge fromnode="2" id="out" tonode="3" /> </edges>
Save this data into a file called hello.edg.xml. Now that we have nodes and edges we can call the first sumo tool to create a network. Make sure netconvert is somewhere in your PATH and call
> netconvert --xml-node-files=hello.nod.xml --xml-edge-files=hello.edg.xml --output-file=hello.net.xml
This will generate our network called hello.net.xml.
It is possible to achieve the same result with only defining an edge file as follows
<edges> <edge id="1to2" xfrom="-500.0" xto="+500.0" yfrom="0.0" yto="0.0" /> <edge id="out" xfrom="+500.0" xto="+501.0" yfrom="0.0" yto="0.0" /> </edges>
This way the netconvert tool generates the nodes automatically and via
> netconvert --xml-edge-files=hello_redux.edg.xml --output-file=hello.net.xml
we get the same net as before.
Now we have a net, we still need a car. In SUMO the vehicles have types defining their basic properties such as length, acceleration and deceleration and maximum speed. Furthermore it needs a so called sigma parameter which introduces some random behavior and is due to the car following model used. Setting it to 0 gives a deterministic car.
Now we define a route for our car which simply consists of the two edges we defined. The reason why we need two edges is that in SUMO the car disappears as soon as it has reached the last edge of its route (the position of a car is defined by the position of its front). Last but not least we define our single car mainly referring to the entries before and giving it a departure time as in the following hello.rou.xml file.
<routes> <vtype accel="1.0" decel="5.0" id="Car" length="2.0" maxspeed="100.0" sigma="0.0" /> <route id="route0">1to2 out</route> <vehicle depart="1" id="veh0" route="route0" type="Car" /> </routes>
Now we glue everything together into a configuration file
<configuration> <files> <net-file>hello.net.xml</net-file> <route-files>hello.rou.xml</route-files> </files> <simulation> <begin>0</begin> <end>10000</end> </simulation> </configuration>
Saving this to hello.sumo.cfg we can start the simulation by either
> sumo -c hello.sumo.cfg
or with GUI by
> guisim -c hello.sumo.cfg