Search code examples
omnet++veinstraffic-simulation

Accident Avoidance in Veins


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.


Solution

  • 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?