riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
203 stars 131 forks source link

Simulation time is less than real time #218

Closed xrispa-m closed 1 year ago

xrispa-m commented 3 years ago

I'm using artery (OMNeT++ 5.6.2) with sumo (1.7.1) and carla (0.9.11). I have set the simulation time in the omnet.ini file to a certain value but the actual simulation runs faster that the actual time spent during the simulation. Is there any way to solve this?

riebl commented 3 years ago

OMNeT++ will try to run as fast as possible by default. You need to configure OMNeT++ to use a so-called real-time scheduler via the scheduler-class option in omnetpp.ini. Which particular scheduler implementation fits best depends on your particular use case. OMNeT++ ships with cRealTimeScheduler but you may implement a custom scheduler as well.

xrispa-m commented 3 years ago

Thanks @riebl ! I've been using the cRealTimeScheduler but for some reason it doesn't work from the beginning. When the simulation starts, the simulation time isn't synchronised with the real time. At some point, the real time scheduler seems to kick in and everything is as it should. Is there any way to avoid that?

riebl commented 3 years ago

If I remember correctly, cRealTimeScheduler initialises an internal time stamp with the current system time at the start. As the simulation progresses, this scheduler tries to keep the duration between this "start time" and "now" equal to the simulation time advance. Consequently, the simulation may run faster than real time for a while if the simulation lagged behind real time in the beginning. May this be the reason for the observed behaviour in your case?