Travelled Distance Calculation Fix (Update CurrentState.cs) #3455
+14
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, this is my first pull request for Mission Planner or GitHub in general. Hence, I hope I am doing this correctly.
I noticed some of the Current State (MAV.cs) parameters are calculated inside Mission Planner (Travelled Distance and Time in Air), which sometimes leads to mistakes in calculations (for example, if the link got disconnected for some time or the Mission Planner was restarted while UAV is flying).
Hopefully we can find a solution to solve this issue.
For now, I found a bug when changing the Distance Unit while the UAV is flying, the travelled distance calculation goes wrong. I found that the variable "disttravelled" is accumulated from previous value regardless of the distance unit (meters or feet).
I Updated CurrentState.cs as shown in my commit, perhaps there is a better way that you can think of.
The change for "disttravelled" value can also be done on the ConfigPlanner.cs on the CMB_distunits_SelectedIndexChanged if this was the only place where the user can change the Distance unit.