35 from python_qt_binding.QtCore
import QSize
41 Dashboard widget to display PR2 battery state.
46 :param context: the plugin context
47 :type context: qt_gui.plugin.Plugin
52 icons.append([
'ic-battery-0.svg'])
53 icons.append([
'ic-battery-20.svg'])
54 icons.append([
'ic-battery-40.svg'])
55 icons.append([
'ic-battery-60-green.svg'])
56 icons.append([
'ic-battery-80-green.svg'])
57 icons.append([
'ic-battery-100-green.svg'])
58 charge_icons.append([
'ic-battery-charge-0.svg'])
59 charge_icons.append([
'ic-battery-charge-20.svg'])
60 charge_icons.append([
'ic-battery-charge-40.svg'])
61 charge_icons.append([
'ic-battery-charge-60-green.svg'])
62 charge_icons.append([
'ic-battery-charge-80-green.svg'])
63 charge_icons.append([
'ic-battery-charge-100-green.svg'])
64 super(PR2Battery, self).
__init__(
'PR2 Battery', icons=icons, charge_icons=charge_icons)
71 self.set_charging(
False)
74 self.setFixedSize(self._icons[1].actualSize(QSize(60, 100)))
81 Sets button state based on msg
83 :param msg: message containing the power state of the PR2
84 :type msg: pr2_msgs.PowerState
90 last_charging = self._charging
95 self.
_pct = msg.relative_capacity / 100.0
97 self.set_charging(msg.AC_present)
98 if (last_pct != self.
_pct or last_charging != self._charging
or last_time_remaining != self.
_time_remaining):
99 drain_str =
"remaining"
101 drain_str =
"to full charge"
103 self.setToolTip(
"%s: %.2f%% \nTime %s: %d Minutes" % (self._name, self.
_pct * 100.0, drain_str, self.
_time_remaining.to_sec() / 60.0))
104 self.update_perc(msg.relative_capacity)