ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Turtlebot Netbook Battery Error

asked 2013-02-13 12:21:54 -0500

LCROBOT gravatar image

updated 2014-01-28 17:15:13 -0500

ngrennan gravatar image


While launching the turtlebot_bringup minimal.launch that generally uses the "info" and "state" files to check the turtlebot laptop battery I get the following Error:

[WARN] [WallTime: 1360800362.124919] Battery : unable to check laptop battery info [[Errno 2] No such file or directory: '/proc/acpi/battery/BAT0/info']

However in Ubuntu Quantal 12.10 these files no longer exist. Now they've broken the data into several different files located in /sys/class/power_supply/BAT0.

So I'm wondering if there is an updated script (which I haven't been able to find) or if the file needs to be changed in order to get it working, however I'm kind of new at this and that would take longer. =S


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-13 20:22:44 -0500

fergs gravatar image has evolved over time, as laptop vendors and driver developers don't follow any sort of standard for how they expose those stats. If you aren't using an official turtlebot laptop from either iHeartEngineering or Clearpath Robotics, chances are that your specific laptop isn't exactly supported. I would suggest posting a ticket on with as much details as you have about the layout of your ACPI -- and of course, if you do get around to fixing it, please submit a pull request with your changes!

edit flag offensive delete link more

answered 2013-03-18 00:55:02 -0500

Melvin gravatar image


I experienced the same problem and was now able to solve it (at least for my configuration). Since I'm no Python programmer and the changes are really quick and dirty, I don't feel able to post a ticket. But maybe this helps some people.

Setup: ROS Fuerte on Laptop Lenovo Thinkpad X130e (which was delivered with my TurtleBot) running Ubunto 12.04 (fresh install). My battery information is located in /sys/class/power_supply/BAT1. I found some information here: My system provided power_now, energy_now and voltage_now that I could use to calculate the values. Since all such entries just contain a single value, you don't need to parse anything, just devide it by 1.000.000 because values are supplied in micro-A/W/V. Also remember to change the path to the battery in minimal.launch!

Attached see my changed (you can identify modified lines by the commented original lines next to them).

from __future__ import division

import roslib; roslib.load_manifest('turtlebot_node')

from   collections import deque
import threading
import copy
import yaml
import math
import rospy

from turtlebot_node.msg import LaptopChargeStatus
from diagnostic_msgs.msg import DiagnosticStatus, DiagnosticArray, KeyValue

def _strip_Ah(raw_val):
    if 'mAh' in raw_val:
        rv = float(raw_val.rstrip('mAh').strip()) / 1000.0
    elif 'Ah' in raw_val:
        rv = float(raw_val.rstrip('Ah').strip())
    elif 'mWh' in raw_val:
        rv = float(raw_val.rstrip('mWh').strip()) / 1000.0
    elif 'Wh' in raw_val:
        rv = float(raw_val.rstrip('Wh').strip())
        raise Exception('Value %s did not have supported units. (mAh,Ah,mWh,Wh)' % raw_val)
    return rv

def _strip_V(raw_val):
    if 'mV' in raw_val:
        rv = float(raw_val.rstrip('mV').strip()) / 1000.0
    elif 'V' in raw_val:
        rv = float(raw_val.rstrip('V').strip())
        raise Exception('Value %s did not have "V" or "mV"' % raw_val)
    return rv

def _strip_A(raw_val):
    if 'mA' in raw_val:
        rv = float(raw_val.rstrip('mA').strip()) / 1000.0
    elif 'A' in raw_val:
        rv = float(raw_val.rstrip('A').strip())
    elif 'mW' in raw_val:
        rv = float(raw_val.rstrip('mW').strip()) / 1000.0
    elif 'W' in raw_val:
        rv = float(raw_val.rstrip('W').strip())
        raise Exception('Value %s did not have supported units. (A,mA,W,mW)' % raw_val)
    return rv

def slerp(filename):
    f = open(filename, 'r')
    data =
    data = data.replace('\t', '  ')
    return data

def _check_battery_info(_battery_acpi_path):
    o = slerp(_battery_acpi_path+'/energy_full_design')

#    batt_info = yaml.load(o)
    design_capacity = float(o) / 1000000.0
    o = slerp(_battery_acpi_path+'/energy_full')
    last_full_capacity = float(o) / 1000000.0
#    design_capacity    = _strip_Ah(batt_info.get('design capacity',    '0 mAh'))
#    last_full_capacity = _strip_Ah(batt_info.get('last full capacity', '0 mAh'))

    return (design_capacity, last_full_capacity)

state_to_val = {'Full':     LaptopChargeStatus.CHARGED, 
                'Charging':    LaptopChargeStatus.CHARGING, 
                'Discharging': LaptopChargeStatus.DISCHARGING }

diag_level_to_msg = { DiagnosticStatus.OK:    'OK', 
                      DiagnosticStatus.WARN:  'Warning',
                      DiagnosticStatus.ERROR: 'Error'    }

def _check_battery_state(_battery_acpi_path):
    @return LaptopChargeStatus
    o = slerp(_battery_acpi_path+'/status')

#    batt_info = yaml.load(o)

    rv = LaptopChargeStatus()

#    state = batt_info.get('charging state', 'discharging')
    state = o
    rv.charge_state = state_to_val.get(state, 0)
    o = slerp(_battery_acpi_path+'/power_now')
    rv.rate = float(o) / 1000000.0
#    rv.rate     = _strip_A(batt_info.get ...
edit flag offensive delete link more

Question Tools


Asked: 2013-02-13 12:21:54 -0500

Seen: 1,329 times

Last updated: Jan 28 '14