Simulation timestep

  • Fady

    Fady - 2013-07-31

    According to the specs, the simulation time step is 0.02sec. I noticed that if the driver's computing time exceeds 0.02sec then the simulator simply waits until he finishes its computation before it refreshes the screen while I thought that the simulator uses the previous control data of the car and doesn't wait for more than 0.02sec.
    I simply added a busy wait to the drive function just to see what happens and the graphics refresh rate became slower.
    Could you please explain this behavior?


  • Bernhard Wymann

    Bernhard Wymann - 2013-08-01


    No, the simulation timestep is 0.002s (500Hz), the robots are called all 0.02s (50Hz). The simulator has just one thread and works the following:
    - Simulate as fast as you can without worrying about real time
    - If visualization is enabled then a frame is rendered if:
    1. the simulation time catches up with real time
    2. for 2 seconds of simulation time no frame has rendered, so render a frame to show progress and to process GUI events

    Have a look as well into the TORCS FAQ, the researchers section.

    The scr patch changes the game, if you are interested follow the link on the TORCS site.

    Best regards


  • Fady

    Fady - 2013-08-01

    Thanks Bernhard.
    I am more interested in the robot calls, don't they have a timeout? what happens in case the computational time took more than 0.02sec?
    Also, could you please direct me to the place where the AI engine calls the drivers and passes the relevant info?


  • Bernhard Wymann

    Bernhard Wymann - 2013-08-07

    Without the scr patch, the robots have no timeout (one thread), correct. From my previous post you can see then what happens: the simulation just lags behind real time. The scr patch handles that differently, there you can run the AI on a different computer if you like and it is non-blocking.

    The robots are called in raceengine.cpp, around line 600, please have a look as well in the TORCS FAQ.

    Best regards



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks