Search code examples
omnet++veinssumo

Value of getSpeed() function is different to the calculated value


I use OMNeT++-4.6, sumo-0.22.0 and Veins-4a2.

I am interested to calculate the speed of the vehicle when a message is received. I used getSpeed() function to do it. But the problem is that when I calculated manually the speed basing on the time and the distance (using the formula s = d / t), the value is different.

For example, at t= 55.104470531278 s and the distance d= 29.0477 m, the speed obtained by calling the function getSpeed() is s= 3.34862 m/s = 10.8 km/h. On the other hand the one calculated manually is s= 0.52713 m/s = 1.9 km/h.

I need help to understand why the value obtained by using getSpeed() is different please.


Solution

  • getSpeed() returns the current speed of the vehicle (to be precise the one in the last simulation step which is by default 1s) while your calculation gives the average speed over the last ~55s (assuming your simulation started at time 0).