Accident Avoidance in Veins - omnet++

I am implementing an Accident Avoidance scheme in Veins. I modified the TracIDemo11p.cc and changed the onData function as following -
void TraCIDemo11p::onData(WaveShortMessage* wsm) {
findHost()->getDisplayString().updateWith("r=16,green");
annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), traci->getPositionAt(simTime()), "blue"));
if (!sentMessage)
{
traci->commandSlowDown(0.0,4); //speed changes smoothly to 0 in 4sec
sendMessage(wsm->getWsmData());
}
}
I want the vehicles to decelerate and stop in 4 sec after receiving the message. But this thing is not happening. When accident occurs the first vehicle brakes immediately and the remaining vehicles stop as usual. Where am I going wrong? Please suggest.

As I wrote on the mailing list; I think that the cause of your problem is that SUMO automatically simulates the response of drivers to accidents or obstacles. If drivers see an accident, their response is to break with a specific pattern. SUMO is developed by the traffic science community to reflect this behavior with some degree of realism.
As far as I know, the commandSlowDown is intended as an additional feature, for example when you want to simulate vehicles slowing down for other reasons that SUMO does not simulate. In particular, you could use to slow down when you receive information about an accident that is further away (e.g., over multiple hops). I suspect that might be what you're trying to achieve, so are you sure that the other vehicles are receiving the message too?

The accident avoidance behavior overrides TraCI commands by default. You need to enable unsafe driving explicitly using the 'speed mode' command. See http://sumo.dlr.de/wiki/TraCI/Change_Vehicle_State#speed_mode_.280xb3.29

Related

In Oment veins, how to get speed of a vehicle by providing vehicle ID which is not transmitting or receiving any message?

I want to to get vehicle speed by defining a function like getSpeedById(Std::string vid) which will give me the current speed of that vehicle. it doesnot matter the vehicle is receiving/transmitting any message. I am using TraciDemo11p example file. In that example, i know that I can get current speed only when the message is sent/ received. But I want to get speed of a particular vehicle all the simulation time which will not transmit any signal at all.
See answer https://stackoverflow.com/a/49973662/4707703 for how to iterate over all currently simulated vehicles in OMNeT++ and how to get a pointer to their mobility simulation module. From there, it should be as easy as calling getCurrentSpeed (instead of getCurrentPosition, which is done in the linked answer)

How can I modify veins source code to build my first VANET simulation trigger by a RSU?

In a section of road (I exported a portion of map from osm), I have already placed a RSU and generate some random trips of some vehicles. I would like now simulate the exchanges of messages as described bellow:
- the RSU broadcasts periodically a message, like WSA or SAM (Service Announcement Message), and all vehicles that receive the message will respond to the RSU.
Hence, I would like to simulate packet loss according to the number of vehicles and number of exchanges messages handled by the RSU.
I don't know where to change the first sender of message in the original veins source code. In the original veins program, it is a node[0] that triggers the accident message.
Thank you in advance for your return.
You can find the source code of the application running in the Veins 5a1 example simulation in src/veins/modules/application/traci/TraCIDemo11p.cc
I would recommend to start learning about Veins by running the example simulation and playing around with the above mentioned file to see how/what the behavior of the simulation changes.
If you are new to OMNeT++ as well, you will likely find it very useful to start by learning plain OMNeT++ (that is, without Veins) first. The OMNeT++ Tic Toc tutorial is an excellent place to start here.

Disabling Re-routing of vehicles when running Veins Example Scenario

Dears,
These days I am doing a research secnario with Veins. As a first step, I am going to run the example veins scenario with vehicles re-rerouting option and without re-routing when accidents happen. Is this possible? Will it possible with configurations change? Anyway accidents(nodes getting stopped) needs to happen in both scenarios.
Thanks,
Rakkesh
To disable cars' rerouting you can comment out line https://github.com/sommer/veins/blob/veins-4.4/src/veins/modules/application/traci/TraCIDemo11p.cc#L54 but to make this configurable, you will need to implement an .ini parameter yourself.

How can I simulate the two simple scenarios in Veins?

I am a PhD student at INSA Lyon, France. I work on mobility in urban environments.
I installed Omnet ++ 4.6, Sumo 0.21.0 and Veins 3.0 to simulate vehicle mobility.
In fact, I've never used Omnet ++ in my previous work. I read the existing tutorials of Omnet ++ in the website and now I want to start to simulate these two small scenarios:
1 Scenario: I want to have a set of mobile vehicles that exchange information among themselves
2nd scenario: I want to have a set of mobile vehicles and a set of fixed RSU that exchange information
What can I change in the existing example of Veins to lead simulate these scenarios please?
Can you help me to do this please.
Thanks very much in advance.
If you are interested in using Road Side Units (RSUs) in your simulation, you might want to base your work on Veins 4a2 instead. Its example simulation already includes an RSU participating in data exchange: as soon as a vehicle stops, it sends a message. Each vehicle and RSU that receives a message re-broadcasts one message per simulation. Each vehicle that receives a message computes a different route to avoid the road where the message originated. See this answer for a screenshot of the resulting simulation.

Allow a RSU receive messages in Veins

I'm trying to implement a very simple scenery on Veins (OMNeT++ + SUMO) with just three vehicles and one unique fixed RSU, but I'm new in Veins and I'm not able to move very well, despite the tons of documents, FAQs and tutorials I've already read!
My start point is the default TraCI scenary demo, but here the vehicles send and receive, while the RSU just send in broadcast. I managed to fix manually my RSU (adding a MapName.add.xml file and import it from MapName.sumo.cfg, and later modifying RSU.ned and omnetpp.ini). So, at this point I can see my RSU on the simulation map, and the SUMO simulation end well. But for resolve my problem I need to allow RSU not only to send, but also to receive (I have to establish a V2I2V communication).
The copious material I found is sometimes similar to my goal, but dispersive and lacking, and none found any solution. How to edit this default scenery to reach this outcome? Would be extraordinary to have a complete and working code, or be driven by someone more experienced than me.
Many thanks!
The tutorial that comes with Veins 4a2 already includes an RSU that receives data. When it does, it changes its color to green. See TraCIDemoRSU11p::onData for how this is done.

Resources