-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Advanced Time Synchronisation #9365
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! Is the gain scheduling something you tried and found to work well or is there a reference somewhere?
@RomanBapst The gain scheduling is something which worked well during testing. I found that in the initial phase of the synchronisation (without enough data to build up a good hypothesis), the derivative estimate would diverge if the gains were too tight. In the later stages, the loose gains which worked well for the initial convergence would cause the estimate to oscillate. |
@Changliu52 Could you please test this with your VIO setup? I want to make sure that everything still behaves correctly. |
#define PX4_EPOCH_SECS 1234567890ULL | ||
|
||
// Filter gains | ||
#define ALPHA_GAIN_INITIAL 0.05 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document these a bit? I.e. in which cases you need to adjust them and how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, thanks for pointing it out!
@mhkabir Yeah. Works pretty nice. I had two test in this log here: https://review.px4.io/plot_app?log=07e16bc5-7794-40e0-a716-690c2f249185. I used software sync in the first test and hardware sync (images were tagged at trigger time, and no exposure compensation) in the second test. Both tests start with slower motion, then faster, and then added more rotations. Let me know your thoughts. Chang |
@Changliu52 Looks good! Timesync performance is nominal in your logs inspite of some patches of bad latency. Maybe from killing and restarting mavros? You might want to check where that comes from.
Yes this is because of the convergence of the sync takes some time, and the derivative estimate is not good until then. I will open a PR to mavros to prevent using the synchronised timestamp until convergence is complete. TODOs based on your logs :
|
Yes I did relaunch everything including the mavros. The glitch happened at the time when killing everything. I did experience any issue caused by that. Thank you for the very nice improvement. Chang |
ab8cee0
to
877f3d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This brings in an advanced version of the current mavlink time synchronisation algorithm. It performs much better at lower synchronisation rates (< 10Hz) and on high jitter serial links. It is also much more robust to outliers and provides an accurate (sub-millisecond) clock offset estimate after only 30 seconds of synchronisation @ 10Hz rate. RMS error after a minute of synchronisation is under 50 microseconds.
The filtering algorithm itself is based on a gain-scheduled double exponential filter. The main improvement over the current lowpass filter is that the derivative of the estimate is also estimated in order to produce an estimate without steady state lag. Further reading : https://en.wikipedia.org/wiki/Exponential_smoothing#Double_exponential_smoothing
Performance :
I have tested this extensively on "typical" onboard setups, and should be good to merge. It would still be good to get some community testing with a bunch of different setups. I will also open a pull request to Flight Review so that we can view timesync performance for logs which have it. This will allow us to later improve performance based on crowdsourced data.
Note for testers (should also go into PX4 Devguide) :
sudo timedatectl set-ntp no