_BatteryServer.py
Go to the documentation of this file.
00001 """autogenerated by genpy from pr2_msgs/BatteryServer.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 pr2_msgs.msg
00008 import std_msgs.msg
00009 
00010 class BatteryServer(genpy.Message):
00011   _md5sum = "4f6d6e54c9581beb1df7ea408c0727be"
00012   _type = "pr2_msgs/BatteryServer"
00013   _has_header = True #flag to mark the presence of a Header object
00014   _full_text = """# DEPRECATED. Use pr2_msgs/BatteryServer2 instead.
00015 Header header
00016 uint32 MAX_BAT_COUNT=4
00017 uint32 MAX_BAT_REG=48
00018 int32 id  # unique ID for each battery server
00019 # Battery System Stats
00020 int32 lastTimeSystem #epoch time
00021 uint16 timeLeft      # in minutes
00022 uint16 averageCharge # in percent
00023 string message
00024 # Battery Controller Flags
00025 int32 lastTimeController #epoch time
00026 uint16 present
00027 uint16 charging
00028 uint16 discharging
00029 uint16 reserved
00030 uint16 powerPresent
00031 uint16 powerNG
00032 uint16 inhibited
00033 # for each battery
00034 pr2_msgs/BatteryState[] battery
00035 
00036 ================================================================================
00037 MSG: std_msgs/Header
00038 # Standard metadata for higher-level stamped data types.
00039 # This is generally used to communicate timestamped data 
00040 # in a particular coordinate frame.
00041 # 
00042 # sequence ID: consecutively increasing ID 
00043 uint32 seq
00044 #Two-integer timestamp that is expressed as:
00045 # * stamp.secs: seconds (stamp_secs) since epoch
00046 # * stamp.nsecs: nanoseconds since stamp_secs
00047 # time-handling sugar is provided by the client library
00048 time stamp
00049 #Frame this data is associated with
00050 # 0: no frame
00051 # 1: global frame
00052 string frame_id
00053 
00054 ================================================================================
00055 MSG: pr2_msgs/BatteryState
00056 # DEPRECATED.  Use pr2_msgs/BatteryState2 instead.
00057 # Each batteries registers
00058 int32 lastTimeBattery #epoch time
00059 uint16[48] batReg
00060 uint16[48] batRegFlag
00061 int32[48] batRegTime
00062 
00063 """
00064   # Pseudo-constants
00065   MAX_BAT_COUNT = 4
00066   MAX_BAT_REG = 48
00067 
00068   __slots__ = ['header','id','lastTimeSystem','timeLeft','averageCharge','message','lastTimeController','present','charging','discharging','reserved','powerPresent','powerNG','inhibited','battery']
00069   _slot_types = ['std_msgs/Header','int32','int32','uint16','uint16','string','int32','uint16','uint16','uint16','uint16','uint16','uint16','uint16','pr2_msgs/BatteryState[]']
00070 
00071   def __init__(self, *args, **kwds):
00072     """
00073     Constructor. Any message fields that are implicitly/explicitly
00074     set to None will be assigned a default value. The recommend
00075     use is keyword arguments as this is more robust to future message
00076     changes.  You cannot mix in-order arguments and keyword arguments.
00077 
00078     The available fields are:
00079        header,id,lastTimeSystem,timeLeft,averageCharge,message,lastTimeController,present,charging,discharging,reserved,powerPresent,powerNG,inhibited,battery
00080 
00081     :param args: complete set of field values, in .msg order
00082     :param kwds: use keyword arguments corresponding to message field names
00083     to set specific fields.
00084     """
00085     if args or kwds:
00086       super(BatteryServer, self).__init__(*args, **kwds)
00087       #message fields cannot be None, assign default values for those that are
00088       if self.header is None:
00089         self.header = std_msgs.msg.Header()
00090       if self.id is None:
00091         self.id = 0
00092       if self.lastTimeSystem is None:
00093         self.lastTimeSystem = 0
00094       if self.timeLeft is None:
00095         self.timeLeft = 0
00096       if self.averageCharge is None:
00097         self.averageCharge = 0
00098       if self.message is None:
00099         self.message = ''
00100       if self.lastTimeController is None:
00101         self.lastTimeController = 0
00102       if self.present is None:
00103         self.present = 0
00104       if self.charging is None:
00105         self.charging = 0
00106       if self.discharging is None:
00107         self.discharging = 0
00108       if self.reserved is None:
00109         self.reserved = 0
00110       if self.powerPresent is None:
00111         self.powerPresent = 0
00112       if self.powerNG is None:
00113         self.powerNG = 0
00114       if self.inhibited is None:
00115         self.inhibited = 0
00116       if self.battery is None:
00117         self.battery = []
00118     else:
00119       self.header = std_msgs.msg.Header()
00120       self.id = 0
00121       self.lastTimeSystem = 0
00122       self.timeLeft = 0
00123       self.averageCharge = 0
00124       self.message = ''
00125       self.lastTimeController = 0
00126       self.present = 0
00127       self.charging = 0
00128       self.discharging = 0
00129       self.reserved = 0
00130       self.powerPresent = 0
00131       self.powerNG = 0
00132       self.inhibited = 0
00133       self.battery = []
00134 
00135   def _get_types(self):
00136     """
00137     internal API method
00138     """
00139     return self._slot_types
00140 
00141   def serialize(self, buff):
00142     """
00143     serialize message into buffer
00144     :param buff: buffer, ``StringIO``
00145     """
00146     try:
00147       _x = self
00148       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00149       _x = self.header.frame_id
00150       length = len(_x)
00151       if python3 or type(_x) == unicode:
00152         _x = _x.encode('utf-8')
00153         length = len(_x)
00154       buff.write(struct.pack('<I%ss'%length, length, _x))
00155       _x = self
00156       buff.write(_struct_2i2H.pack(_x.id, _x.lastTimeSystem, _x.timeLeft, _x.averageCharge))
00157       _x = self.message
00158       length = len(_x)
00159       if python3 or type(_x) == unicode:
00160         _x = _x.encode('utf-8')
00161         length = len(_x)
00162       buff.write(struct.pack('<I%ss'%length, length, _x))
00163       _x = self
00164       buff.write(_struct_i7H.pack(_x.lastTimeController, _x.present, _x.charging, _x.discharging, _x.reserved, _x.powerPresent, _x.powerNG, _x.inhibited))
00165       length = len(self.battery)
00166       buff.write(_struct_I.pack(length))
00167       for val1 in self.battery:
00168         buff.write(_struct_i.pack(val1.lastTimeBattery))
00169         buff.write(_struct_48H.pack(*val1.batReg))
00170         buff.write(_struct_48H.pack(*val1.batRegFlag))
00171         buff.write(_struct_48i.pack(*val1.batRegTime))
00172     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00173     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00174 
00175   def deserialize(self, str):
00176     """
00177     unpack serialized message in str into this message instance
00178     :param str: byte array of serialized message, ``str``
00179     """
00180     try:
00181       if self.header is None:
00182         self.header = std_msgs.msg.Header()
00183       if self.battery is None:
00184         self.battery = None
00185       end = 0
00186       _x = self
00187       start = end
00188       end += 12
00189       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00190       start = end
00191       end += 4
00192       (length,) = _struct_I.unpack(str[start:end])
00193       start = end
00194       end += length
00195       if python3:
00196         self.header.frame_id = str[start:end].decode('utf-8')
00197       else:
00198         self.header.frame_id = str[start:end]
00199       _x = self
00200       start = end
00201       end += 12
00202       (_x.id, _x.lastTimeSystem, _x.timeLeft, _x.averageCharge,) = _struct_2i2H.unpack(str[start:end])
00203       start = end
00204       end += 4
00205       (length,) = _struct_I.unpack(str[start:end])
00206       start = end
00207       end += length
00208       if python3:
00209         self.message = str[start:end].decode('utf-8')
00210       else:
00211         self.message = str[start:end]
00212       _x = self
00213       start = end
00214       end += 18
00215       (_x.lastTimeController, _x.present, _x.charging, _x.discharging, _x.reserved, _x.powerPresent, _x.powerNG, _x.inhibited,) = _struct_i7H.unpack(str[start:end])
00216       start = end
00217       end += 4
00218       (length,) = _struct_I.unpack(str[start:end])
00219       self.battery = []
00220       for i in range(0, length):
00221         val1 = pr2_msgs.msg.BatteryState()
00222         start = end
00223         end += 4
00224         (val1.lastTimeBattery,) = _struct_i.unpack(str[start:end])
00225         start = end
00226         end += 96
00227         val1.batReg = _struct_48H.unpack(str[start:end])
00228         start = end
00229         end += 96
00230         val1.batRegFlag = _struct_48H.unpack(str[start:end])
00231         start = end
00232         end += 192
00233         val1.batRegTime = _struct_48i.unpack(str[start:end])
00234         self.battery.append(val1)
00235       return self
00236     except struct.error as e:
00237       raise genpy.DeserializationError(e) #most likely buffer underfill
00238 
00239 
00240   def serialize_numpy(self, buff, numpy):
00241     """
00242     serialize message with numpy array types into buffer
00243     :param buff: buffer, ``StringIO``
00244     :param numpy: numpy python module
00245     """
00246     try:
00247       _x = self
00248       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00249       _x = self.header.frame_id
00250       length = len(_x)
00251       if python3 or type(_x) == unicode:
00252         _x = _x.encode('utf-8')
00253         length = len(_x)
00254       buff.write(struct.pack('<I%ss'%length, length, _x))
00255       _x = self
00256       buff.write(_struct_2i2H.pack(_x.id, _x.lastTimeSystem, _x.timeLeft, _x.averageCharge))
00257       _x = self.message
00258       length = len(_x)
00259       if python3 or type(_x) == unicode:
00260         _x = _x.encode('utf-8')
00261         length = len(_x)
00262       buff.write(struct.pack('<I%ss'%length, length, _x))
00263       _x = self
00264       buff.write(_struct_i7H.pack(_x.lastTimeController, _x.present, _x.charging, _x.discharging, _x.reserved, _x.powerPresent, _x.powerNG, _x.inhibited))
00265       length = len(self.battery)
00266       buff.write(_struct_I.pack(length))
00267       for val1 in self.battery:
00268         buff.write(_struct_i.pack(val1.lastTimeBattery))
00269         buff.write(val1.batReg.tostring())
00270         buff.write(val1.batRegFlag.tostring())
00271         buff.write(val1.batRegTime.tostring())
00272     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00273     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00274 
00275   def deserialize_numpy(self, str, numpy):
00276     """
00277     unpack serialized message in str into this message instance using numpy for array types
00278     :param str: byte array of serialized message, ``str``
00279     :param numpy: numpy python module
00280     """
00281     try:
00282       if self.header is None:
00283         self.header = std_msgs.msg.Header()
00284       if self.battery is None:
00285         self.battery = None
00286       end = 0
00287       _x = self
00288       start = end
00289       end += 12
00290       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00291       start = end
00292       end += 4
00293       (length,) = _struct_I.unpack(str[start:end])
00294       start = end
00295       end += length
00296       if python3:
00297         self.header.frame_id = str[start:end].decode('utf-8')
00298       else:
00299         self.header.frame_id = str[start:end]
00300       _x = self
00301       start = end
00302       end += 12
00303       (_x.id, _x.lastTimeSystem, _x.timeLeft, _x.averageCharge,) = _struct_2i2H.unpack(str[start:end])
00304       start = end
00305       end += 4
00306       (length,) = _struct_I.unpack(str[start:end])
00307       start = end
00308       end += length
00309       if python3:
00310         self.message = str[start:end].decode('utf-8')
00311       else:
00312         self.message = str[start:end]
00313       _x = self
00314       start = end
00315       end += 18
00316       (_x.lastTimeController, _x.present, _x.charging, _x.discharging, _x.reserved, _x.powerPresent, _x.powerNG, _x.inhibited,) = _struct_i7H.unpack(str[start:end])
00317       start = end
00318       end += 4
00319       (length,) = _struct_I.unpack(str[start:end])
00320       self.battery = []
00321       for i in range(0, length):
00322         val1 = pr2_msgs.msg.BatteryState()
00323         start = end
00324         end += 4
00325         (val1.lastTimeBattery,) = _struct_i.unpack(str[start:end])
00326         start = end
00327         end += 96
00328         val1.batReg = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=48)
00329         start = end
00330         end += 96
00331         val1.batRegFlag = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=48)
00332         start = end
00333         end += 192
00334         val1.batRegTime = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=48)
00335         self.battery.append(val1)
00336       return self
00337     except struct.error as e:
00338       raise genpy.DeserializationError(e) #most likely buffer underfill
00339 
00340 _struct_I = genpy.struct_I
00341 _struct_2i2H = struct.Struct("<2i2H")
00342 _struct_48i = struct.Struct("<48i")
00343 _struct_48H = struct.Struct("<48H")
00344 _struct_i = struct.Struct("<i")
00345 _struct_i7H = struct.Struct("<i7H")
00346 _struct_3I = struct.Struct("<3I")


pr2_msgs
Author(s): Eric Berger and many others
autogenerated on Mon Oct 6 2014 03:30:41