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.