Definition of Vehicles, Vehicle Types, and Routes

From Sumo
Revision as of 10:31, 5 April 2009 by Dkrajzew (talk | contribs) (New page: =Definition of Vehicles= The most simple way to get own routes is to edit a routes file by hand, but only if the number of different routes is not too high. Before starting, it is of impor...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Definition of Vehicles

The most simple way to get own routes is to edit a routes file by hand, but only if the number of different routes is not too high. Before starting, it is of importance to know that a vehicle in SUMO consists of three parts: a vehicle type which describes the vehicle's physical properties, a route the vehicle shall take, and the vehicle itself. Both routes and vehicle types can be shared by several vehicles.

In the following, building a route file which contains all these information will be presented by example. The file will be named "routes.rou.xml". Herein, at first a vehicle type will be defined:

<routes>
    <vtype id="type1" accel="0.8" decel="4.5" sigma="0.5" length="7.5" maxspeed="70"/>
</routes>

The values used above are the ones most of the examples use. They resemble a standard vehicle as used within the Stefan Krauß'. These values have the following meanings:

   *
     id: A string holding the id of the vehicle type
   *
     accel: The acceleration ability of vehicles of this type (in m/s^2)
   *
     decel: The deceleration ability of vehicles of this type (in m/s^2)
   *
     sigma: The driver imperfection (between 0 and 1)
   *
     length: The vehicle length (in m)
   *
     maxspeed: The vehicle's maximum velocity (in m/s)
   *
     color: An optional color of the vehicle type, encoded as three values between 0 and 1 for red, green, and blue, divided by a ','. Please remark that no spaces between the numbers are allowed.

Having this defined, one can build vehicles of type "type1". As next, we will define a vehicle with a route owned by him only:

<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="beg middle end rend"/>
   </vehicle>

</routes>

Ok, now we have a red (color=1,0,0) vehicle of type "type1" named "0" which will start at time 0. The vehicle will drive along the streets "beg", "middle", "end", and as soon as it has approached the edge "rend" it will be removed from the simulation. Ok, let's review a vehicle's attributes:

   *
     id: A string holding the id of the vehicle
   *
     type: The vehicle type to use for this vehicle
   *
     depart: The time at which the vehicle shall be emitted into the net
   *
     color: An optional color of the vehicle, encoded as three values between 0 and 1 for red, green, and blue, divided by a ','. Please remark that no spaces between the numbers are allowed.

This vehicle has an own, internal route which is not shared with other vehicles. It is also possible to define two vehicles using the same route. In this case the route must be "externalized" - defined before being referenced by the vehicles. Also, the route must be named by giving it an id. The vehicles using the route refer it using the "route"-attribute. The complete change looks like this:

<routes>
   <vtype id="type1" accel="0.8" decel="4.5" sigma="0.5" length="5" maxspeed="70"/>

   <route id="route0" color="1,1,0" edges="beg middle end rend"/>

   <vehicle id="0" type="type1" route="route0" depart="0" color="1,0,0"/>
   <vehicle id="1" type="type1" route="route0" depart="0" color="0,1,0"/>

</routes>

One may notice, that the route itself also got a color definition, so the attributes of a route are:

   *
     id: A string holding the id of the route
   *
     edges: A space spearated list of edge ids forming the route (the old style of defining the edges inside route brackets is considered deprecated)
   *
     color: An optional color of the vehicle, encoded as three values between 0 and 1 for red, green, and blue, divided by a ','. Please remark that no spaces between the numbers are allowed.

This knowledge should enable you to specify own route definitions by hand or using self-written scripts. All routing modules are generating route files that match this routes and vehicles specification.There are a few important things to consider when building your own routes:

   *
     Routes have to be connected. At the moment the simulation does not raise an error if the next edge of the current route is not a successor of the current edge. The car will simply stop at the end of the current edge and will possibly be "teleported" to the next edge after a waiting time. This is very likely to change in future versions.
   *
     Routes have to contain at least two edges. The simulation stops the car at the start of the last edge, thus a route consisting of a single edge is empty. This is likely to change in future versions of SUMO.
   *
     The starting edge has to be at least as long as the car starting on it. At the moment cars can only start at a position which makes them fit on the road completely.
   *
     The route file has to be sorted by starting times. In fact this is only relevant, when you define a lot of routes or have large gaps between departure times. The simulation parameter --route-steps, which defaults to 200, defines the size of the time interval with which the simulation loads its routes. That means by default at startup only route with departure time <200 are loaded, if all the vehicles have departed, the routes up to departure time 400 are loaded etc. pp. This works only if the route file is sorted. This behaviour may be disabled by specifying --route-steps 0.

The first three conditions can be checked using <SUMO_DIST>/tools/routecheck.py. 5.3.1.2. Route and vehicle type distributions

Instead of defining routes and vtypes explicitly SUMO can choose them at runtime from a given distribution. In order to use this feature just define distributions as following:

<routes>

  <vtypeDistribution id="typedist1">
     <vtype id="type1" accel="0.8" decel="4.5" sigma="0.5" length="5" maxspeed="70" probability="0.9"/>
     <vtype id="type2" accel="1.8" decel="4.5" sigma="0.5" length="15" maxspeed="50" probability="0.1"/>
  </vtypeDistribution>

</routes>

<routes>

  <routeDistribution id="routedist1">
     <route id="route0" color="1,1,0" edges="beg middle end rend" probability="0.9"/>
     <route id="route1" color="1,2,0" edges="beg middle end" probability="0.1"/>
  </routeDistribution>

</routes>

A distribution has only an id as (mandatory) attribute and needs a probability attribute for each of its child elements. The sum of the probability values needs not to be 1, they are scaled accordingly. At the moment the id for the childs is mandatory, this is likely to change in future versions.

Now you can use distribution just as you would use individual types and routes:

<routes>

  <vehicle id="0" type="typedist1" route="routedist1" depart="0" color="1,0,0"/>

</routes>