avidbots / flatland

A 2D robot simulator for ROS
BSD 3-Clause "New" or "Revised" License
107 stars 65 forks source link

How do I speed up the simulation ? #88

Closed allwinlucious closed 1 year ago

allwinlucious commented 1 year ago

Is there a way to speed up the simulation time? I belive it runs in real time .

I am sorry if this sounds trivial but I'm quite new to flatland

josephduchesne commented 1 year ago

The simulation time is virtual, but defaults to roughly 1:1 with real time.

The parameters you're looking for are update_rate (default 200) and step_size (default 0.005). Multiply them together and you get the simulation speed (1x real time by default). To run flatland at 2x, you could either double update_rate (to 400), which would use 2x the CPU, but keep the simulation time step resolution, or drop step_size to 0.01 (seconds/simulation timestep), which would use the same CPU but be half the time step resolution. You can play with both numbers. Flatland server outputs its current timestep resolution on the command line log (since beyond a certain point your PC won't be able to run it any faster).

For more details: https://flatland-simulator.readthedocs.io/en/latest/core_functions/ros_launch.html

Depending on the rest of the system, you can probably run flatland anywhere from 2x - 8x real time, but at a certain point either the physics simulation has a bad time (objects skip through eachother or have unexpectedly high contact forces), or more likely something else in the ROS chain has a race condition or can't keep up.

allwinlucious commented 1 year ago

Thank you very much!