Search code examples
sumo

How can i make vehicles do random routes in SUMO?


I need to make vehicles do random routes, not random speed or acceleration, random edges that he moves to.

I tried using "RNG" and "random" to see if caused any effect and it didn't.Also tried searching for it and couldn't find anything about the issue.I'm on windows


Solution

  • To constantly change the vehicles' routes, you would have to use TraCI. You can use either one of the following ways:

    1. You can parse and store the net-file to understand how the edges are connected to each other and update the vehicle's route using setRoute.
    2. Pre-define multiple possible routes and pre-load it using TraCI or in the routes/additional file and change the vehicle's route using setRouteID
    3. Easiest of all is to use the command moveToXY in the TraCI package. When using this command, you can change the vehicle's edge for each time step (by setting the keepRoute parameter to 0). This forces the vehicle to change its route, however, now the route consists of only ONE single edge (to which the vehicle was moved). Do this repeatedly.