-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Add calibration parameters for multiple batteries #12551
Conversation
5bc65f7
to
9803216
Compare
@ItsTimmy This will have a docs impact and possibly quite a complex QGC UI change. Please ping me when you think it is time to engage re docs. The main doc to change would be : http://docs.px4.io/master/en/config/battery.html And presumably we may need to change the failsafe behaviour too: http://docs.px4.io/master/en/config/safety.html#low-battery-failsafe |
66b4f3d
to
ed137a4
Compare
This is looking good, but I think we should briefly take a step back and try to sketch out a rough overall design that factors in all the current requirements.
|
Related #12033 |
db2b8ff
to
48034ca
Compare
89f127b
to
06d774f
Compare
Even though we don't have the multi-battery requirements worked out completely, I think this PR is still ready for review and merge. It does not affect the safety-critical decisions like low-battery failsafe behavior and reporting of overall system battery percentage. These are still open issues, but they can be addressed in a separate PR. The only outstanding issue is that this PR is failing CI because it is overflowing the flash on |
06d774f
to
6346943
Compare
I have updated this with 3 important differences:
I still have some cleanup and testing to do on this. There are still some relics of the old way this was written. @hamishwillee I don't know if this is the final behavior of this parameter migration (@dagar will have to weigh in), but once we have it nailed down, where should it be documented? Is it sufficient to only document it in the parameter descriptions? |
d00c2d2
to
612ae0c
Compare
_warning(battery_status_s::BATTERY_WARNING_NONE), | ||
_last_timestamp(0) | ||
{ | ||
if (index > 9 || index < 1) { | ||
PX4_ERR("Battery index must be between 1 and 9 (inclusive). Received %d. Defaulting to 1.", index); |
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.
I guess the alternative would just be an assert
.
c1ebd6f
to
638f4c9
Compare
e78b8c7
to
bfdc9fd
Compare
bfdc9fd
to
a3febb9
Compare
@dagar @julianoes @bkueng This is ready for review. |
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.
Reviewed again, I would say this is good to go in.
I did some more testing on this latest version. The following tests all worked as intended:
|
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.
Nice work.
How do you want to handle updating QGC to the new params?
class Battery : public ModuleParams | ||
{ | ||
public: | ||
Battery(); | ||
Battery(int index = 1, ModuleParams *parent = nullptr); |
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.
I would not default to NULL for the parent
, to ensure it's set.
Describe problem solved by the proposed pull request
Support for multiple batteries was improved in #12034 , but there is still the issue that different batteries all use the same calibration parameters.
Test data / coverage
On Pixhawk 4, multiple batteries with different levels of charge and numbers of cells were tested.
This PR makes changes that affect all different boards, so more testing should be done on different hardware.
Describe your preferred solution
Improved the Battery library by adding the ability to instantiate different batteries with different sets of parameters. Split power reading in
sensors
module into a separate class for readability.Additional context
In the near future, support for digital power meters will be expanded, continuing the work done in #11755. This refactoring should make supporting this new source of battery data, as well as any future new sources, easier.