-
Notifications
You must be signed in to change notification settings - Fork 17.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
AP_Stats: update flight time on disarm #25778
Conversation
Why not add the flush to the I think you could just add ardupilot/libraries/AP_Stats/AP_Stats.cpp Lines 134 to 135 in 61b3ad3
It just seems a little odd to trigger the save on arming when the stat is based on flying. |
@IamPete1 Thank you for your suggestion.
If we add update_runtime() and flush() in there, also updating last_flush_ms, runtime is updated whenever the drone is not flying. It could lead to frequent updates of the runtime value. I thought it would be better to update once only when disarming. |
Right, you would have to check
Having broken out the millis fetch from the other branch of the if to populate "now". |
This method adds up to less than 30 seconds. The notification to GCS is in 30-second increments. I think that by executing flush() in this method, we can update the flash memory and repair the 30 seconds short of the GCS. void AP_Stats::set_flying(const bool is_flying) |
Concur with Peter and Muramura here; move the update of |
0934587
to
1d66653
Compare
1d66653
to
b8967a7
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.
LGTM
Merged, thanks! |
This PR fixes an issue where flight time was not being updated if the power was shut down immediately after flight.
Since the update occurs in 30-second cycles, turning off the power before the update process means the last flight time is not added.
I have modified update function so that the flight time updates upon disarming, in addition to the regular updates every 30 seconds.
I have confirmed that the flight time is updated immediately after disarming in SITL.