-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clock drift when running ArduPilot SITL in a Docker container on a Mac #12060
Comments
Hello, thanks for the report. |
I have uploaded it to my Dropbox. It's mostly standard stuff with a few extensions that allow me to supply a custom parameter set by mounting a file inside the container. I have also included the patch in the ZIP file that turns on the debug output that I have shown in my bug report. In the meanwhile, it seems like ignoring Edit: forgot to mention - on my machine it usually does not take more than 30 seconds for the simulation rate to get significantly different from the desired 1200 Hz so it's not a rare occasion. |
This happens when running the SITL in vagrant on Mac OS X as described here: https://ardupilot.org/dev/docs/setting-up-sitl-using-vagrant.html |
My issue is as follows: The log is attached. The issue described above coincides with a spike in |
Fro docker, maybe check the version being used - docker/for-mac#2076 (comment) Hope this helps! |
On Tue, 11 Feb 2020, Alexander Maryanovsky wrote:
This happens when running the SITL in vagrant on Mac OS X as described here: https://ardupilot.org/dev/docs/setting-up-sitl-using-vagrant.html
So it's not specific to Docker.
Don't expect SITL's simulated time to keep up with wallclock time.
Consider --speedup.
Consider what happens when you enter the debugger.
|
and indeed for me too setting |
Not sure I understand what you mean. I don't expect the simulated time to match wall-clock precisely. But what happens in my case is that the whole simulation gets 'stuck' for ~90 seconds, then speeds up like crazy, and then returns to normal. |
The problems appears to be that |
Changing gettimeofday to clock_gettime should be transparent. Do you want to open a PR doing it ? |
Yes, it appears that on Windows |
it should have been fixed by #14487. Please reopen it the bug is still here |
Bug report
Issue details
The internal clock of the ArduPilot SITL drifts from wall clock time when it is run in a Docker container on a Mac. This might not be an issue with ArduPilot itself (although it could be), but it would be nice to have it documented somewhere, at least in the issue tracker in case someone else bumps into this.
The issue can be seen by re-instantiating the commented-out debug section in
Aircraft::sync_frame_time()
and then looking for strange spikes inachieved_rate_hz
. In my case, it looks like this (note that I have extended the debug statement to print the value offrame_counter
as well as the difference between the current wall clock time and the last wall clock time seen in the previous iteration):You can see that occasionally, the simulator "thinks" that it has executed 41 frames in 3 microseconds, and this estimates the update rate at 13666667 Hz. This erroneous estimate is large enough that it "skews" the smoothed
achieved_rate_hz
estimate to 137846 Hz, which means that ArduCopter will intentionally slow down its simulation rate to compensate for this and return to the desired rate of 1200 Hz.Initially, I suspected that this is some kind of a thread-safety issue; one of the threads might be increasing the
frame_counter
from 40 to 41 while another one tries to reset it to zero, and the first thread "wins". However, sometimes I see much larger differences, like this:Some more information: this does not happen if I run the SITL environment natively on my Mac (without Docker), neither does it happen on a Linux machine with Docker, so it's definitely caused by the combination of Docker + macOS.
What we could do on ArduPilot's side is to throw away the rate estimates that are significantly higher than the target rate we are trying to achieve.
Version
Latest master revision at the time of writing (53f8aa2).
Platform
[ ] All
[ ] AntennaTracker
[X] Copter
[ ] Plane
[ ] Rover
[ ] Submarine
I was compiling ArduCopter, but may affect other platforms.
Airframe type
Simulated quadcopter, but it's probably not relevant.
Hardware type
N/A
The text was updated successfully, but these errors were encountered: