Search code examples
omnet++veinssumo

How to get n number of vehicles for x sec of simulation using SUMO randomTrips script?


I am using Veins simulator, for creating cars with path I am using the following commands:

python c:/DLR/Sumo/tools/randomTrips.py -n test.net.xml -e 1200 -l
python c:/DLR/Sumo/tools/randomTrips.py -n test.net.xml -r test.rou.xml -e 1200 -l

This command generated 1200 vehicles for 1200 sec of simulation but I want to generated 1200 vehicles for 100 sec of simulation. How can I do that?


Solution

  • Just to answer this (mainly rephrasing what Julian Heinovski said in the comments)

    randomTrips.py -n net.net.xml -o passenger.trips.xml -e 100
    

    will generate 100 trips. If you want to make sure all of them are possible (connected in the network) you can add --validate but this will remove invalid trips (and you may end up with less than 100). You can simply play around with the number then.

    To let all of them start at second 0 you can edit the trips file using a regular expression replacement, replacing all departure times with 0s. On *nix the following will probably do:

    sed -i 's/depart="[0-9]*/depart="0/' passenger.trips.xml
    

    Now you can start sumo for the period of your choice

    sumo -n net.net.xml -r passenger.trips.xml -e 1200