PX4-SITL-AirSim lockstep and timeouts

Hi there :slight_smile:
I already asked this in slack but did not get an answer yet. Probably it was the wrong channel? [0]

So whats my problem: I’m trying to setup a testing environment using px4-sitl, AirSim and QGroundControl.
Most of these parts work already. PX4 builds and starts correctly. It connects to AirSim (even in a multi-drone scenario) and can be controller via QGC.
But: during the simulation AirSim mentions that something went wrong and resets the lockstep mode.
At the same time (before and after the reset) the drones start to wobble around and QGC mentions sensor timeouts.

I already investigated a bit and went into the source code. AirSim resets lock-step if he did not receive a HIL-Control-Message within 100ms and some users mentioned that both problems might be duo to a too weak computer.

What I don’t understand about this is the lock-step part. If I understand it correctly, the lock-step mode should somehow synchronize the px4-container with the simulator. Thus, if one of them is too slow it slows down the other one.

Still timeouts occur and the simulation does not seem to be slowed down. If I start px4 and/or AirSim with a slower simulation speed the drones are slower in AirSim but following QGC MAVLink messages are still send at the same rate as before. Additionally the source-code of AirSim seems to not take the simulation speed into account when checking the 100ms timeout.

Did I understand anything wrong? Does anyone know how to fix this without buying a better computer? (It would be more than acceptable to slow down the simulation to reach this goal but it did not work yet)

Thanks already :slight_smile:

[0] https://px4.slack.com/archives/C0W2KUFFT/p1593162071003400

Hi!

Here is some more information on how lockstep works:
https://dev.px4.io/master/en/simulation/index.html#lockstep-simulation

The thing is that when simulating with Gazebo or jMAVSim, we never get out of lockstep, so we don’t need to do any resets or things like that.
Somehow, for AirSim this doesn’t seem to hold and as a workaround @clovett added the resets.
I haven’t looked into what exactly goes on for these cases.

I assume AirSim does not take the simulation speed into account (yet), so doesn’t support it.

Hi there,
thanks for the quick response!

The linked article is exactly what I thought lockstep would be (and I guess also what I found earlier).
So if AirSim implements it like explained there no Sensor-Timeouts should be possible as long as lock-step mode is active, right ? It might only fail during the reset period in which lockstep is temporarily disabled.

Feels a bit weird. I hope they support it better with the upcoming release.

Regarding the simulation speed: AirSim has its own setting for the simulation speed. It’s called “ClockSpeed” and can be set via the settings.json file. If lowered (e.g. 0.01) drones fly much slower but messages are send with the same frequency. Guess they only adapt parts of the system to the simulation speed.
Again I guess I should wait for the next release and then check if its working and what exactly is done with the parameter.