'Inconsistencies of the positions in a linear VEINS car flow

I am trying to monitor positions (X coordinate, it is horizontal) of vehicles in a linear flow.

In TraCIDemo11p::handlePositionUpdate method, I added current vehicle position (by getCurrentPosition().x) and vehicle id (by getExternalId()) to message data using,

wsm ->setWsmData (parameters) and sent it down via sendDown(wsm).

Then in TraCIDemo11p::onWSM(WaveShortMessage* wsm), those information is retrieved and added to a std::map which I use for my calculations.

However in an arbitary momnet during the simulation vehicle positions can be found like this (v0:439.60 v1:389.60 v2:339.60 v3:339.60 v4:289.60) in the map. This is because v2 has not updated its position after v3 updated its position. I would appreciate any advice on this to avoid this inconsistency.

Thank you.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source