ardupilot
ardupilot copied to clipboard
SITL: Fix SIM_SPEEDUP -1
If you start a sim without setting param SIM_SPEEDUP then it will default to -1. That can't be good. Luckily, what's actually used in the SITL code is target_speedup that can be fetched via get_speedup() within the Airplane class and that set_speedup() at boot does a sanity check on the param. However, AP_Logger looks directly at the param value and sets a timeout depending on that.
When it's negative it hangs the logio thread.
This PR does two things: change SIM_SPEEDUP default from -1 to +1 sanity check sitl->speedup in logger. It's the only place in the code that uses it
Thanks Tom - I've found that using the default on Mac crashes SITL. I always set --speedup 1 on the command line as a workaround, I guess it might be related to this.
OK, correct fix is probably to move all the time handling code (sync_frame_time) out of SIM_Aircraft.
We should probably merge this this-century, however.
@timtuxworth are you able to test this PR?
I talked to @peterbarker about this and we both agree the better solution is to go through get_speedup() which I tried to use but we can't reqch that from our normal libraries so it requires larger infrastructure changes that start to become out of scope so this is good as-is for now until we get those larger infrastructure changes at a later time. Just waiting on a test confirmation from @timtuxworth to merge.
Might take me a couple of days, I'm on the road, but I'll test it as soon as I get back to Edmonton likely Monday/Tuesday.
This works. Tested in SITL on Mac M1 Pro. Without this fix SITL will crash unless you pass --speedup 1 on the command line (which sim_vehicle.py does by default, which is a workaround to this problem).
Now running a SITL instance of ardupilot on a Mac doesn't crash.
Merged, thanks!
@timtuxworth Thanks for testing!