-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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_BattMonitor: Do not report remaining battery percentage if battery capacity is set to 0 #13712
Conversation
You need to go address the associated spots that access this to cope with a return value of -1. A lot of them use it as a uint8_t and the previous behaviour was okay for them, but showing 255 will be worse/breaking for them. (Mostly it's AP_Notify/OSD and Lua bindings that need to be updated). |
9b7dbb7
to
762ccb2
Compare
762ccb2
to
09f1a50
Compare
@WickedShell updated. |
09f1a50
to
9d4b4e1
Compare
Sorry I didn't make the comment when I made my earlier one. The best change here would be to make If you don't want to take that on here we can open an issue for it, and tag it as a good first issue. |
9d4b4e1
to
6739e17
Compare
@WickedShell is this what you had in mind? I have no idea of how to fix the Lua part doing it like this |
6739e17
to
16fa4b1
Compare
f8ef898
to
ea75836
Compare
@WickedShell can you take a look now? |
ea75836
to
cdd4b63
Compare
@WickedShell rebased |
By the way, if you're having troubles getting this in you can also add the DevCallTopic tag or the DevCallEU label and then attend one of the two weekly PR meetings. The EU one is new, there's a blog post with the timing on ardupilot.org. |
cdd4b63
to
d661909
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.
Pretty sure we should change that parameter to be unsigned now. There are several cases in here where bad things are going to happen if it is negative, and making it unsigned in all the corners gives them assurances they don't need to worry about that case.
Apologies for flip-flopping on this.
cb78c65
to
a5a07b4
Compare
uint8_t percent = -1; | ||
IGNORE_RETURN(capacity_remaining_pct(percent)); |
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.
This is a change in behaviour - we're now going to log 255 rather than zero here.
I'm actually OK with that change.
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.
Yes, I think there's more information in 255 than a zero that could be mistaked by an empty battery.
send_uint16(DATA_ID_FUEL, (uint16_t)roundf(_battery.capacity_remaining_pct())); // send battery remaining | ||
uint8_t percentage = 0; | ||
IGNORE_RETURN(_battery.capacity_remaining_pct(percentage)); | ||
send_uint16(DATA_ID_FUEL, (uint16_t)roundf(percentage)); // send battery remaining |
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.
Does this strike you as a bit weird?
We convert an integer to a float, round it, then cast it back into a uint16_t.
Similarly elsewhere.
Pre-existing, so not your problem to fix.
a5a07b4
to
03d6e5d
Compare
03d6e5d
to
d7d0592
Compare
issues seem to have been addressed now
Sub had a regression from 3.5.4 where QGC now periodically complains about low battery.
According to the Mavlink specs this should be a int8_t and return -1 if there is no percentage counting:
https://mavlink.io/en/messages/common.html#BATTERY_STATUS
https://mavlink.io/en/messages/common.html#SYS_STATUS