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

Estimate remaining flight time #17828

Merged
merged 3 commits into from
Nov 15, 2021
Merged

Estimate remaining flight time #17828

merged 3 commits into from
Nov 15, 2021

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Jun 30, 2021

Describe problem solved by this pull request
It's useful to show the user an estimate how much longer he can still fly until the battery is empty.
This estimate will also be required to make an informed decision when to return to home automatically to be able to land safely before the battery is empty.

Describe your solution
Calculate the remaining flight time based on a very heavily filtered "average" current consumption and the configured battery capacity.

Test data / coverage
The algorithm was tested on an old version of PX4 this port to the new version wasn't specifically tested yet. I suggest we check logs that fly with this functionality to see if the flight time is accurate.

Additional context
This is based on the refactor #17827

@MaEtUgR MaEtUgR self-assigned this Jun 30, 2021
Base automatically changed from battery-refactor to master July 1, 2021 12:24
mcsauder
mcsauder previously approved these changes Jul 28, 2021
Copy link
Contributor

@mcsauder mcsauder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MaEtUgR , I looked through your PR after the dev call this morning and although I haven't tested it I am certainly in favor of this PR going in. CI is passing and if it goes in we can start evaluating it on hardware. I see no harm it would produce in the meantime and I think it takes things in the right direction. Thanks for your work!

-Mark

@MaEtUgR MaEtUgR marked this pull request as ready for review September 16, 2021 15:27
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Sep 17, 2021

Thank you so much for the review Mark. I would have merged but now I need to rebase 😃
I'll also add the suggestion to make an unknown time estimate getting represented by NAN because we have this change already under testing and it already resulted in confusion and a bug with the definition of -1.

@MaEtUgR MaEtUgR force-pushed the battery-remaining-flight-time branch from 2222d23 to 47329a0 Compare November 11, 2021 13:26
@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 11, 2021

I finally updated this pr with a rebase and the changes handling unknown battery time explicitly (not as zero seconds) like I wrote in my previous comment. Any final look on it? @mcsauder maybe? I'll follow up with a pr that compares return time with flight time and returns when they get close to each other.

@MaEtUgR
Copy link
Member Author

MaEtUgR commented Nov 15, 2021

Since this was approved before and a prerequisite for the functionality in #18646 I'm merging.

@MaEtUgR MaEtUgR merged commit 91c4860 into master Nov 15, 2021
@MaEtUgR MaEtUgR deleted the battery-remaining-flight-time branch November 15, 2021 14:44
@mcsauder
Copy link
Contributor

Apologies I was too slow getting to this @MaEtUgR . Everything is in great shape. Nice work, I'm really glad its in!

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

Successfully merging this pull request may close these issues.

2 participants