Skip to content
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

EKF2/EKF3: bugs that appear after system time wrap #14058

Open
1 of 11 tasks
rmackay9 opened this issue Apr 11, 2020 · 1 comment
Open
1 of 11 tasks

EKF2/EKF3: bugs that appear after system time wrap #14058

rmackay9 opened this issue Apr 11, 2020 · 1 comment

Comments

@rmackay9
Copy link
Contributor

rmackay9 commented Apr 11, 2020

While working on improving our handling of external position estimate I found these places in the EKF2/EKF3 where we are doing direct comparisons of the system time (instead of comparison of elapsed system time) meaning the checks probably fail after the system time wraps (which happens after 72day I think):

return MAX(bodyOdmDataDelayed.time_ms,wheelOdmDataDelayed.time_ms);

  • EKF3's writeOptFlowMeas is using MAX() on two absolute times which is likely incorrect at least for a moment during the wrap.
  • EKF3's readGPSData() function uses a MIN and MAX on absolute times that is likely incorrect.

gpsDataNew.time_ms = MIN(MAX(gpsDataNew.time_ms,imuDataDelayed.time_ms),imuDataDownSampledNew.time_ms);

  • EKF3's readBaroData uses a MAX on absolute times which is probably incorrect

baroDataNew.time_ms = MAX(baroDataNew.time_ms,imuDataDelayed.time_ms);

  • EKF2's and EKF3's writeExtNavData make the same make as above by using a MAX when setting timeStamp_ms (see here for EKF2 and here for EKF3)
  • EKF2's and EKF3's NavEKF3_core::readRangeFinder() methods have incorrect checks like below.
                // don't allow time to go backwards
                if (storedRngMeasTime_ms[sensorIndex][midIndex] > rangeDataNew.time_ms) {
                    rangeDataNew.time_ms = storedRngMeasTime_ms[sensorIndex][midIndex];
                }

System time wrap can be tested in SITL by changing SIM_Aircraft.cpp as shown below so that the time wraps about 30 seconds after starting SITL

time_now_us(4294900000ULL * 1000ULL),

These are fixed:

@rmackay9 rmackay9 changed the title EKF2/EKF3: features probably not working after system time wrap EKF2/EKF3: yaw reset probably not working after system time wrap Apr 11, 2020
@rmackay9 rmackay9 changed the title EKF2/EKF3: yaw reset probably not working after system time wrap EKF2/EKF3: bugs that appear after system time wrap May 12, 2020
@tridge
Copy link
Contributor

tridge commented May 12, 2020

very nice. We should add a SIM_ param for setting initial time, so we don't need the code change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants