Intermodalics / tango_ros

ROS related software for Tango
Apache License 2.0
67 stars 22 forks source link

Publish battery state #379

Open meyerj opened 6 years ago

meyerj commented 6 years ago

...as sensor_msgs/BatteryState. Not really related to Tango, but it might be useful for applications where a self-powered Tango device is used as a localization sensor.

I am not familiar with the Android API, but the BatteryManager seems to provide the necessary information.

jubeira commented 6 years ago

JFYI: this is what Android apps use to display the battery level: https://github.com/rosjava/android_remocons/blob/kinetic/common_tools/src/main/java/com/github/rosjava/android_remocons/common_tools/dashboards/DefaultDashboard.java#L102. It does the quotient between the battery capacity and the charge to display the percentage (it is a bit awful, but that's how it works).

We wrote a battery publisher for Tangobot that publishes the battery level according to that, in case you want to take a look: https://github.com/ekumenlabs/tangobot/blob/master/tangobot_app/app/src/main/java/com/ekumen/tangobot/nodes/DeviceBatteryPublisherNode.java. Note that this doesn't use BatteryState messages, but it works with android client apps like map nav. Anyway, you can check a possible usage of the battery manager there.