Currently, I am generating vehicles from SUMO and importing into veins. However, now I want to use large number of vehicles (from 100 to 1000) and I want their random generation (e.g., random start time and random speed).
Can anyone help that i) how can I create/generate vehicles from veins instead of SUMO? and ii) how to randomly select start time and speed of vehicles?
Best Regards,
Yasir
This is what https://github.com/sommer/veins/blob/veins-5.1/src/veins/modules/mobility/traci/TraCIVehicleInserter.ned was designed for. Whenever the number of active vehicles in OMNeT++ is less than a configured number, it starts a new vehicle using one of the existing route definitions.
You can use python to generate route files with random seed/random start time.
Refer to runner.py file in https://github.com/eclipse/sumo/blob/master/tests/complex/tutorial/traci_tls/runner.py and to the tutorial in https://sumo.dlr.de/docs/Tutorials/TraCI4Traffic_Lights.html
Related
When using omnet++ to get CO2 emission, the data is given for each node(vehicle) seperately. Is there a way to take the data for a number of vehicles or for the whole simulation as a whole?
The functions you are looking for are covered in section 12 "Result Recording and Analysis" of the OMNeT++ manual https://doc.omnetpp.org/omnetpp/manual/#cha:ana-sim. It explains how you can merge multiple results into one.
I want to keep a constant number of cars in my (long) simulation (OMNeT+Veins). I do not care about mobility that much so i could probably use the Veins in-built function *.manager.numVehicles = 100. The thing is that if i do not specify any(enough) vehicle flows (from SUMO) my simulation terminates instantly (because of no events). So i create some flows (that exit the simulation sooner) and Veins fills up for the cars as they dissappear.
Is there a more elegant way to do this? I'd prefer to just use the numVehicles function since it's easier and the cars move minimally so they remain in the simulation for long.
I need steady-state vehicular density (number of vehicles fixed - even if old ones leave and new ones enter to replace them at the same instant).
Thanks,
Andreas
The autoShutdown parameter can be set to false to instruct the coupling interface to keep going even though there are no more cars in the simulation. See https://github.com/sommer/veins/blob/veins-4.5/src/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.ned#L55
https://stackoverflow.com/a/71071341/7215379 has a solution. It actually is meant to keep the number of vehicles in simulation constant. You can look into the possibility of reusing it.
For my simulation I want to find out the count of lines in a single road. I search sumo and viens and there is nothing there. I can retrieves all lanes count in map but what about lanes(lines) in a single road?
You can simply parse the sumo network. It is a quite straightforward XML file. For your specific question there is even support in the sumolib which is a python library coming with sumo.
net = sumolib.net.readNet("netfile")
edge = net.getEdge("edgeID")
numLanes = edge.getLaneNumber()
You can also look here: http://sumo.dlr.de/wiki/Tools/Sumolib
My field of study is about travel time of cars so to evaluate my proposed methods it's very important to know how much time it takes for each individual car to reach to its destination
I use Veins 3.0, Sumo0.21.0 and Omnet++ 4.6 for simulation. I record destination of each car and base on their position, I record the exit time when a car reaches to its destination.
Is there a straightforward way to get notified when a car left the simulation?
Veins 3.0 already records several metrics in each TraCIMobility module. Among them are each vehicle's startTime, stopTime, and totalTime in the simulation.
Vehicles get removed from the simulation when they arrive. This means that, if you want to execute arbitrary code when a vehicle leaves the simulation, you can just add this code to the finish method of any module contained in the vehicle.
I uniformly distributed the sensor nodes using
intuniform (0,1000);However,everytime when I started the simulation from beginnig, all the sensor nodes is placed at the same position.Then I used the srand(time(NULL)) the result is again same.For example, in the first run sn[1] position is
(150, 167), it is same in the second run.I want to change it.The program should not memorize it.Thanks for your help.
OMNeT++ uses different pseudo random number generators than standard C++. It is a core feature of OMNeT++ that running the same simulation twice yields exactly the same result. The function srand changes the seed of the standard C++ generator only. You can also change the seed of OMNeT++ generators, but more likely you want to start a different run of your simulation. This will automatically use a different (well chosen) seed.