_BatteryState2.py
Go to the documentation of this file.
00001 """autogenerated by genpy from pr2_msgs/BatteryState2.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 import genpy
00008 
00009 class BatteryState2(genpy.Message):
00010   _md5sum = "91b4acb000aa990ac3006834f9a99669"
00011   _type = "pr2_msgs/BatteryState2"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """# This message communicates the state of a single battery.
00014 # Battery Controller Flags, one per battery
00015 bool present       # is this pack present
00016 bool charging      # is this pack charging
00017 bool discharging   # is this pack discharging
00018 bool power_present # is there an input voltage
00019 bool power_no_good # is there a fault (No Good)
00020 bool inhibited     # is this pack disabled for some reason
00021 # These registers are per battery
00022 time      last_battery_update     # last time any battery update occurred
00023 int16[48] battery_register        # value of this register in the battery
00024 bool[48]  battery_update_flag     # Has this register ever been updated
00025 time[48]  battery_register_update # last time this specific register was updated
00026 
00027 """
00028   __slots__ = ['present','charging','discharging','power_present','power_no_good','inhibited','last_battery_update','battery_register','battery_update_flag','battery_register_update']
00029   _slot_types = ['bool','bool','bool','bool','bool','bool','time','int16[48]','bool[48]','time[48]']
00030 
00031   def __init__(self, *args, **kwds):
00032     """
00033     Constructor. Any message fields that are implicitly/explicitly
00034     set to None will be assigned a default value. The recommend
00035     use is keyword arguments as this is more robust to future message
00036     changes.  You cannot mix in-order arguments and keyword arguments.
00037 
00038     The available fields are:
00039        present,charging,discharging,power_present,power_no_good,inhibited,last_battery_update,battery_register,battery_update_flag,battery_register_update
00040 
00041     :param args: complete set of field values, in .msg order
00042     :param kwds: use keyword arguments corresponding to message field names
00043     to set specific fields.
00044     """
00045     if args or kwds:
00046       super(BatteryState2, self).__init__(*args, **kwds)
00047       #message fields cannot be None, assign default values for those that are
00048       if self.present is None:
00049         self.present = False
00050       if self.charging is None:
00051         self.charging = False
00052       if self.discharging is None:
00053         self.discharging = False
00054       if self.power_present is None:
00055         self.power_present = False
00056       if self.power_no_good is None:
00057         self.power_no_good = False
00058       if self.inhibited is None:
00059         self.inhibited = False
00060       if self.last_battery_update is None:
00061         self.last_battery_update = genpy.Time()
00062       if self.battery_register is None:
00063         self.battery_register = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
00064       if self.battery_update_flag is None:
00065         self.battery_update_flag = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
00066       if self.battery_register_update is None:
00067         self.battery_register_update = [genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time()]
00068     else:
00069       self.present = False
00070       self.charging = False
00071       self.discharging = False
00072       self.power_present = False
00073       self.power_no_good = False
00074       self.inhibited = False
00075       self.last_battery_update = genpy.Time()
00076       self.battery_register = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
00077       self.battery_update_flag = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
00078       self.battery_register_update = [genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time(),genpy.Time()]
00079 
00080   def _get_types(self):
00081     """
00082     internal API method
00083     """
00084     return self._slot_types
00085 
00086   def serialize(self, buff):
00087     """
00088     serialize message into buffer
00089     :param buff: buffer, ``StringIO``
00090     """
00091     try:
00092       _x = self
00093       buff.write(_struct_6B2I.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs))
00094       buff.write(_struct_48h.pack(*self.battery_register))
00095       buff.write(_struct_48B.pack(*self.battery_update_flag))
00096       for val1 in self.battery_register_update:
00097         _x = val1
00098         buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00099     except struct.error as se: self._check_types(se)
00100     except TypeError as te: self._check_types(te)
00101 
00102   def deserialize(self, str):
00103     """
00104     unpack serialized message in str into this message instance
00105     :param str: byte array of serialized message, ``str``
00106     """
00107     try:
00108       if self.last_battery_update is None:
00109         self.last_battery_update = genpy.Time()
00110       if self.battery_register_update is None:
00111         self.battery_register_update = None
00112       end = 0
00113       _x = self
00114       start = end
00115       end += 14
00116       (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs,) = _struct_6B2I.unpack(str[start:end])
00117       self.present = bool(self.present)
00118       self.charging = bool(self.charging)
00119       self.discharging = bool(self.discharging)
00120       self.power_present = bool(self.power_present)
00121       self.power_no_good = bool(self.power_no_good)
00122       self.inhibited = bool(self.inhibited)
00123       start = end
00124       end += 96
00125       self.battery_register = _struct_48h.unpack(str[start:end])
00126       start = end
00127       end += 48
00128       self.battery_update_flag = _struct_48B.unpack(str[start:end])
00129       self.battery_update_flag = map(bool, self.battery_update_flag)
00130       self.battery_register_update = []
00131       for i in range(0, 48):
00132         val1 = genpy.Time()
00133         _x = val1
00134         start = end
00135         end += 8
00136         (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00137         self.battery_register_update.append(val1)
00138       self.last_battery_update.canon()
00139       return self
00140     except struct.error as e:
00141       raise genpy.DeserializationError(e) #most likely buffer underfill
00142 
00143 
00144   def serialize_numpy(self, buff, numpy):
00145     """
00146     serialize message with numpy array types into buffer
00147     :param buff: buffer, ``StringIO``
00148     :param numpy: numpy python module
00149     """
00150     try:
00151       _x = self
00152       buff.write(_struct_6B2I.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs))
00153       buff.write(self.battery_register.tostring())
00154       buff.write(self.battery_update_flag.tostring())
00155       for val1 in self.battery_register_update:
00156         _x = val1
00157         buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00158     except struct.error as se: self._check_types(se)
00159     except TypeError as te: self._check_types(te)
00160 
00161   def deserialize_numpy(self, str, numpy):
00162     """
00163     unpack serialized message in str into this message instance using numpy for array types
00164     :param str: byte array of serialized message, ``str``
00165     :param numpy: numpy python module
00166     """
00167     try:
00168       if self.last_battery_update is None:
00169         self.last_battery_update = genpy.Time()
00170       if self.battery_register_update is None:
00171         self.battery_register_update = None
00172       end = 0
00173       _x = self
00174       start = end
00175       end += 14
00176       (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited, _x.last_battery_update.secs, _x.last_battery_update.nsecs,) = _struct_6B2I.unpack(str[start:end])
00177       self.present = bool(self.present)
00178       self.charging = bool(self.charging)
00179       self.discharging = bool(self.discharging)
00180       self.power_present = bool(self.power_present)
00181       self.power_no_good = bool(self.power_no_good)
00182       self.inhibited = bool(self.inhibited)
00183       start = end
00184       end += 96
00185       self.battery_register = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=48)
00186       start = end
00187       end += 48
00188       self.battery_update_flag = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=48)
00189       self.battery_update_flag = map(bool, self.battery_update_flag)
00190       self.battery_register_update = []
00191       for i in range(0, 48):
00192         val1 = genpy.Time()
00193         _x = val1
00194         start = end
00195         end += 8
00196         (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00197         self.battery_register_update.append(val1)
00198       self.last_battery_update.canon()
00199       return self
00200     except struct.error as e:
00201       raise genpy.DeserializationError(e) #most likely buffer underfill
00202 
00203 _struct_I = genpy.struct_I
00204 _struct_6B2I = struct.Struct("<6B2I")
00205 _struct_48B = struct.Struct("<48B")
00206 _struct_2I = struct.Struct("<2I")
00207 _struct_48h = struct.Struct("<48h")


pr2_msgs
Author(s): Eric Berger and many others
autogenerated on Mon Jan 6 2014 11:34:07