Closed dwiel closed 3 years ago
actually, just realized that SITL was running from master and I was running 4.0.3 on the real hardware. I'll try to run a 4.0.3 SITL test later today.
Just confirmed that this problem appears on SITL in version 4.0.3
Thanks for the investigation. @peterbarker is more the expert than I am but I wonder if increasing the priority of the gcs().update_recieve and update_send() would help. That can be done quite easily by moving it up in the scheduler tasks list. In a testing environment at least moving it right to the top would be interesting.
https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/Copter.cpp#L147
I already tried that. I also tried increasing the maximum us. No luck
I've also tried disabling a large number of the components I am not using in APM_Config.h
such as the sprayer, etc.
@dwiel, ok, the scheduler tasks list actually runs after the fast_loop, so the next test I would recommend is removing those two lines from the task list and then putting the equivalent two calls at the top of the fast_loop. https://github.com/ArduPilot/ardupilot/blob/master/ArduCopter/Copter.cpp#L222
I'm not sure exactly what the two lines will look like but probably something like:
gcs().update_receive() gcs().update_send()
On Tue, 9 Jun 2020, Zach Dwiel wrote:
Just confirmed that this problem appears on SITL in version 4.0.3
So SITL's clock isn't wall-clock.
You might try with a linux binary instead.
I was wondering how SITL dealt with simulating the difference between a multi gigahertz host processor vs multi hundred megahertz flight controller processor.
What do you mean a linux binary instead? I did a quick search but I'm not finding much.
What I would really like to do is test high frequency control loops over mavlink. It sounds like the SITL probably isn't a good way to do this in either case?
On Tue, 9 Jun 2020, Zach Dwiel wrote:
I was wondering how SITL dealt with simulating the difference between a multi gigahertz host processor vs multi hundred megahertz flight controller processor.
We do not attempt to emulate processors.
What do you mean a linux binary instead? I did a quick search but I'm not finding much.
SITL compiles for Linux. But ArduPilot also runs on Linux-based flight controllers (navio2, bbbmini, ...)
Linux runs real-time on those processors, so may be suitable for your purposes. No simulated sensors or whatnot, 'though, so this might not be suitable for your use-case.
What I would really like to do is test high frequency control loops over mavlink. It sounds like the SITL probably isn't a good way to do this in either case?
As in running off-board control loops?
SITL will be useful for testing the code basically works - but communicating over an actual serial port to an actual autopilot will probably be your best test.
On Tue, 9 Jun 2020, Zach Dwiel wrote: I was wondering how SITL dealt with simulating the difference between a multi gigahertz host processor vs multi hundred megahertz flight controller processor. We do not attempt to emulate processors.
make sense
What do you mean a linux binary instead? I did a quick search but I'm not finding much. SITL compiles for Linux. But ArduPilot also runs on Linux-based flight controllers (navio2, bbbmini, ...) Linux runs real-time on those processors, so may be suitable for your purposes. No simulated sensors or whatnot, 'though, so this might not be suitable for your use-case. What I would really like to do is test high frequency control loops over mavlink. It sounds like the SITL probably isn't a good way to do this in either case? As in running off-board control loops? SITL will be useful for testing the code basically works - but communicating over an actual serial port to an actual autopilot will probably be your best test.
yeah, running off-board control loops. I was hoping to use SITL to optimize the communication latency and avoid the manual firmware upgrade process. It sounds like that is the best path forward.
Sounds like this is just a problem with the SITL not running real time not a inherent AP code issue. I'm going to close, but please re-open if this is a problem on none SITL builds, they certainly should be real time.
Bug report
Issue details
@pietrodn wrote a simple script to measure the round trip mavlink latency using the TIMESYNC message available here. It sends a TIMESYNC message at 100hz and measures the time until the flight controller responds with its corresponding TIMESYNC. What I measure on my set up is very similar to the plots here. This script was originally written to measure mavlink latency which was being inflated by dronekit, a python library used to wrap the mavlink library. That original bug has since been removed, but the same pattern is now visible in the arducopter SITL. I have ruled out dronekit itself as the source of my problem by measuring latency on the same firmware, in one case on real hardware, and another case in SITL. The problem only appears in SITL.
Here's the pattern when running on SITL:
a plot of a separate run
Notice how the round trip time is much larger than it should be (this is SITL running on a 24-core cpu and communicating over mavlink on the same host) and additionally, each round trip time decreases by almost exactly 10 ms every 10 ms. The original bug this script was written for was caused by
time.sleep(0.05)
and has since been replaced withselect()
. Perhaps there is an analogous sleep in the SITL UART/mavlink code somewhere?Version 4.0.3
Platform [ ] All [ ] AntennaTracker [X] Copter [ ] Plane [ ] Rover [ ] Submarine
Airframe type hexa
Hardware type mRo x2.1