CARLA Simulator: Difference between revisions

Line 47: Line 47:
./CarlaUE4.sh -benchmark -fps=30
./CarlaUE4.sh -benchmark -fps=30
</pre>
</pre>
Alternatively, you can do this on the client by modifying the time step.
 
Alternatively, you can do this on the client by modifying the time step setting of your world.
<pre>
<pre>
settings = world.get_settings()
settings = world.get_settings()
Line 54: Line 55:
</pre>
</pre>


If your client needs to record data every frame, you may want to use synchronous mode
If your client needs to record data every frame, you may want to use [[#synchronous mode]].
 
==Synchronous Mode==
Synchronous mode will force the server to wait for <code>world.tick()</code> on the client rather than run as fast as possible. 
This is ideal if you need to do something per-frame which causes your client to be slower than your server.
<pre>
<pre>
settings = world.get_settings()
settings = world.get_settings()
settings.fixed_delta_seconds = 1 / 30
settings.synchronous_mode = True # Enables synchronous mode
settings.synchronous_mode = True # Enables synchronous mode
world.apply_settings(settings)
world.apply_settings(settings)
</pre>
</pre>
If you are using the built in traffic manager for autopilot, you will need to set that to synchronous mode as well:
<syntaxhighlight lang="python">
tm = client.get_trafficmanager()
tm.set_synchronous_mode(True)
</syntaxhighlight>
See [https://github.com/carla-simulator/carla/blob/master/PythonAPI/examples/spawn_npc.py spawn_npc.py] for an example of synchronous mode.