DRL-AutonomousVehicles
DRL-AutonomousVehicles copied to clipboard
Manually control simulation step?
Hi @kaihuchen! Great work here. I have a question about Airsim's simulation step that I thought you might know (cross posted on AirSim here).
Is it possible to manually control when and for how long the simulator steps? Basically I wanted to use AirSim with a Gym-like interface (which you've done), but it wasn't clear to me how to do a simulator step. Are you stepping AirSim manually?
In my code envs/airsim/airsimcarenv.py you will find a _step function, which is called by OpenAI Baselines. This _step function is the main connecting point between the OpenAi Baselines and AirSim.
Inside this _step function the state of the AirSim environment is fetched and processed into what I wanted Baselines to see. If you want to control the pace of the simulation step, then this is the place to do it. For my experiments here I did not make any attempt to control the pace and just let it run as fast as possible. As a result the _step function is called 2-4 times per second (Intel Core i7 w 16GB RAM, GPU is nVidia GTX 1070 with 8GB) in my experiments.
But does calling _step correspond to a fixed, consistent dt step in AirSim? Or does the step in AirSim depend on your computer specs, how long it takes to compute your desired action, the sim environment, etc?
AirSim runs its simulation in real time (assuming you have reasonable hardware) as a separate process, so when _step queries AirSim's state it just gets whatever AirSim has at the moment, it is unrelated to how fast _step does its computation.
Separately there is a discussion thread about how to run AirSim at faster than real time here: https://github.com/Microsoft/AirSim/issues/522
Hm I see. It's unfortunate since debugging deep RL algorithms is a lot easier when you can control the environment step. Hopefully AirSim will expose the SteppableClock interface at some point.
Thanks for your help!