ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

SITL: Fix SIM_SPEEDUP -1

Open magicrub opened this issue 5 months ago • 4 comments

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

magicrub avatar Jun 03 '25 21:06 magicrub

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.

timtuxworth avatar Jun 04 '25 02:06 timtuxworth

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?

peterbarker avatar Jun 04 '25 03:06 peterbarker

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.

magicrub avatar Jun 06 '25 17:06 magicrub

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.

timtuxworth avatar Jun 06 '25 23:06 timtuxworth

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.

timtuxworth avatar Jun 08 '25 02:06 timtuxworth

Merged, thanks!

peterbarker avatar Jun 08 '25 22:06 peterbarker

@timtuxworth Thanks for testing!

magicrub avatar Jun 16 '25 16:06 magicrub