UbiquityRobotics / ubiquity_motor

Package that provides a ROS interface for the motors in UbiquityRobotics robots
BSD 3-Clause "New" or "Revised" License
25 stars 24 forks source link

Battery percentage calculator #138

Closed MoffKalast closed 3 years ago

MoffKalast commented 3 years ago

This PR should address the issue that one of our clients has raised and I've noticed as well: full charge voltage level is off by about 30%, and the max possible achievable percentage is like 77% which is odd for just about everyone. From what I've tested there's no way our usual 7.2Ah 12S lead acids can go above ~26.1V when not plugged into a charger.

Aside from a fix for that I've also ported my usual battery calculation system, which uses a lookup table along with level interpolation and should be much more accurate than the simple interpolation we had before. It also adds li-ion support if we ever needed that, but it'll need to be extended via a launch param when we actually need it.

There is some debate to be had if we should label 2V per cell as "empty" and 0% or 50% as it actually technically is. I think for now it may be best to keep the real values inside ROS as a baseline and then fudge it further up the line when it's displayed to layman users only.

Sources: https://files.slack.com/files-pri/T04BZFRLG-F027D2SGB4N/untitled.png http://www.solarnavigator.net/battery_charging.htm

Also closes #127 I guess, and fixes some indents because we yet again have mixed tabs and spaces for some reason.