_BatteryServer2.py
Go to the documentation of this file.
00001 """autogenerated by genpy from pr2_msgs/BatteryServer2.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 import pr2_msgs.msg
00009 import std_msgs.msg
00010 
00011 class BatteryServer2(genpy.Message):
00012   _md5sum = "5f2cec7d06c312d756189db96c1f3819"
00013   _type = "pr2_msgs/BatteryServer2"
00014   _has_header = True #flag to mark the presence of a Header object
00015   _full_text = """# This message communicates the state of a battery server, which controls
00016 # multiple batteries.
00017 Header header
00018 int32 MAX_BAT_COUNT=4
00019 int32 MAX_BAT_REG=48
00020 int32 id  # unique ID for each battery server
00021 # Battery System Stats
00022 time last_system_update  # last time the system stats where updated
00023 duration time_left       # in seconds (hardware resolution is 1 minute)
00024 int32 average_charge     # in percent
00025 string message           # message from the ocean server
00026 time last_controller_update # last time a battery status flag was updated
00027 # for each battery
00028 pr2_msgs/BatteryState2[] battery
00029 
00030 ================================================================================
00031 MSG: std_msgs/Header
00032 # Standard metadata for higher-level stamped data types.
00033 # This is generally used to communicate timestamped data 
00034 # in a particular coordinate frame.
00035 # 
00036 # sequence ID: consecutively increasing ID 
00037 uint32 seq
00038 #Two-integer timestamp that is expressed as:
00039 # * stamp.secs: seconds (stamp_secs) since epoch
00040 # * stamp.nsecs: nanoseconds since stamp_secs
00041 # time-handling sugar is provided by the client library
00042 time stamp
00043 #Frame this data is associated with
00044 # 0: no frame
00045 # 1: global frame
00046 string frame_id
00047 
00048 ================================================================================
00049 MSG: pr2_msgs/BatteryState2
00050 # This message communicates the state of a single battery.
00051 # Battery Controller Flags, one per battery
00052 bool present       # is this pack present
00053 bool charging      # is this pack charging
00054 bool discharging   # is this pack discharging
00055 bool power_present # is there an input voltage
00056 bool power_no_good # is there a fault (No Good)
00057 bool inhibited     # is this pack disabled for some reason
00058 # These registers are per battery
00059 time      last_battery_update     # last time any battery update occurred
00060 int16[48] battery_register        # value of this register in the battery
00061 bool[48]  battery_update_flag     # Has this register ever been updated
00062 time[48]  battery_register_update # last time this specific register was updated
00063 
00064 """
00065   # Pseudo-constants
00066   MAX_BAT_COUNT = 4
00067   MAX_BAT_REG = 48
00068 
00069   __slots__ = ['header','id','last_system_update','time_left','average_charge','message','last_controller_update','battery']
00070   _slot_types = ['std_msgs/Header','int32','time','duration','int32','string','time','pr2_msgs/BatteryState2[]']
00071 
00072   def __init__(self, *args, **kwds):
00073     """
00074     Constructor. Any message fields that are implicitly/explicitly
00075     set to None will be assigned a default value. The recommend
00076     use is keyword arguments as this is more robust to future message
00077     changes.  You cannot mix in-order arguments and keyword arguments.
00078 
00079     The available fields are:
00080        header,id,last_system_update,time_left,average_charge,message,last_controller_update,battery
00081 
00082     :param args: complete set of field values, in .msg order
00083     :param kwds: use keyword arguments corresponding to message field names
00084     to set specific fields.
00085     """
00086     if args or kwds:
00087       super(BatteryServer2, self).__init__(*args, **kwds)
00088       #message fields cannot be None, assign default values for those that are
00089       if self.header is None:
00090         self.header = std_msgs.msg.Header()
00091       if self.id is None:
00092         self.id = 0
00093       if self.last_system_update is None:
00094         self.last_system_update = genpy.Time()
00095       if self.time_left is None:
00096         self.time_left = genpy.Duration()
00097       if self.average_charge is None:
00098         self.average_charge = 0
00099       if self.message is None:
00100         self.message = ''
00101       if self.last_controller_update is None:
00102         self.last_controller_update = genpy.Time()
00103       if self.battery is None:
00104         self.battery = []
00105     else:
00106       self.header = std_msgs.msg.Header()
00107       self.id = 0
00108       self.last_system_update = genpy.Time()
00109       self.time_left = genpy.Duration()
00110       self.average_charge = 0
00111       self.message = ''
00112       self.last_controller_update = genpy.Time()
00113       self.battery = []
00114 
00115   def _get_types(self):
00116     """
00117     internal API method
00118     """
00119     return self._slot_types
00120 
00121   def serialize(self, buff):
00122     """
00123     serialize message into buffer
00124     :param buff: buffer, ``StringIO``
00125     """
00126     try:
00127       _x = self
00128       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00129       _x = self.header.frame_id
00130       length = len(_x)
00131       if python3 or type(_x) == unicode:
00132         _x = _x.encode('utf-8')
00133         length = len(_x)
00134       buff.write(struct.pack('<I%ss'%length, length, _x))
00135       _x = self
00136       buff.write(_struct_i2I3i.pack(_x.id, _x.last_system_update.secs, _x.last_system_update.nsecs, _x.time_left.secs, _x.time_left.nsecs, _x.average_charge))
00137       _x = self.message
00138       length = len(_x)
00139       if python3 or type(_x) == unicode:
00140         _x = _x.encode('utf-8')
00141         length = len(_x)
00142       buff.write(struct.pack('<I%ss'%length, length, _x))
00143       _x = self
00144       buff.write(_struct_2I.pack(_x.last_controller_update.secs, _x.last_controller_update.nsecs))
00145       length = len(self.battery)
00146       buff.write(_struct_I.pack(length))
00147       for val1 in self.battery:
00148         _x = val1
00149         buff.write(_struct_6B.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited))
00150         _v1 = val1.last_battery_update
00151         _x = _v1
00152         buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00153         buff.write(_struct_48h.pack(*val1.battery_register))
00154         buff.write(_struct_48B.pack(*val1.battery_update_flag))
00155         for val2 in val1.battery_register_update:
00156           _x = val2
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(self, str):
00162     """
00163     unpack serialized message in str into this message instance
00164     :param str: byte array of serialized message, ``str``
00165     """
00166     try:
00167       if self.header is None:
00168         self.header = std_msgs.msg.Header()
00169       if self.last_system_update is None:
00170         self.last_system_update = genpy.Time()
00171       if self.time_left is None:
00172         self.time_left = genpy.Duration()
00173       if self.last_controller_update is None:
00174         self.last_controller_update = genpy.Time()
00175       if self.battery is None:
00176         self.battery = None
00177       end = 0
00178       _x = self
00179       start = end
00180       end += 12
00181       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00182       start = end
00183       end += 4
00184       (length,) = _struct_I.unpack(str[start:end])
00185       start = end
00186       end += length
00187       if python3:
00188         self.header.frame_id = str[start:end].decode('utf-8')
00189       else:
00190         self.header.frame_id = str[start:end]
00191       _x = self
00192       start = end
00193       end += 24
00194       (_x.id, _x.last_system_update.secs, _x.last_system_update.nsecs, _x.time_left.secs, _x.time_left.nsecs, _x.average_charge,) = _struct_i2I3i.unpack(str[start:end])
00195       start = end
00196       end += 4
00197       (length,) = _struct_I.unpack(str[start:end])
00198       start = end
00199       end += length
00200       if python3:
00201         self.message = str[start:end].decode('utf-8')
00202       else:
00203         self.message = str[start:end]
00204       _x = self
00205       start = end
00206       end += 8
00207       (_x.last_controller_update.secs, _x.last_controller_update.nsecs,) = _struct_2I.unpack(str[start:end])
00208       start = end
00209       end += 4
00210       (length,) = _struct_I.unpack(str[start:end])
00211       self.battery = []
00212       for i in range(0, length):
00213         val1 = pr2_msgs.msg.BatteryState2()
00214         _x = val1
00215         start = end
00216         end += 6
00217         (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited,) = _struct_6B.unpack(str[start:end])
00218         val1.present = bool(val1.present)
00219         val1.charging = bool(val1.charging)
00220         val1.discharging = bool(val1.discharging)
00221         val1.power_present = bool(val1.power_present)
00222         val1.power_no_good = bool(val1.power_no_good)
00223         val1.inhibited = bool(val1.inhibited)
00224         _v2 = val1.last_battery_update
00225         _x = _v2
00226         start = end
00227         end += 8
00228         (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00229         start = end
00230         end += 96
00231         val1.battery_register = _struct_48h.unpack(str[start:end])
00232         start = end
00233         end += 48
00234         val1.battery_update_flag = _struct_48B.unpack(str[start:end])
00235         val1.battery_update_flag = map(bool, val1.battery_update_flag)
00236         val1.battery_register_update = []
00237         for i in range(0, 48):
00238           val2 = genpy.Time()
00239           _x = val2
00240           start = end
00241           end += 8
00242           (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00243           val1.battery_register_update.append(val2)
00244         self.battery.append(val1)
00245       self.last_system_update.canon()
00246       self.time_left.canon()
00247       self.last_controller_update.canon()
00248       return self
00249     except struct.error as e:
00250       raise genpy.DeserializationError(e) #most likely buffer underfill
00251 
00252 
00253   def serialize_numpy(self, buff, numpy):
00254     """
00255     serialize message with numpy array types into buffer
00256     :param buff: buffer, ``StringIO``
00257     :param numpy: numpy python module
00258     """
00259     try:
00260       _x = self
00261       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00262       _x = self.header.frame_id
00263       length = len(_x)
00264       if python3 or type(_x) == unicode:
00265         _x = _x.encode('utf-8')
00266         length = len(_x)
00267       buff.write(struct.pack('<I%ss'%length, length, _x))
00268       _x = self
00269       buff.write(_struct_i2I3i.pack(_x.id, _x.last_system_update.secs, _x.last_system_update.nsecs, _x.time_left.secs, _x.time_left.nsecs, _x.average_charge))
00270       _x = self.message
00271       length = len(_x)
00272       if python3 or type(_x) == unicode:
00273         _x = _x.encode('utf-8')
00274         length = len(_x)
00275       buff.write(struct.pack('<I%ss'%length, length, _x))
00276       _x = self
00277       buff.write(_struct_2I.pack(_x.last_controller_update.secs, _x.last_controller_update.nsecs))
00278       length = len(self.battery)
00279       buff.write(_struct_I.pack(length))
00280       for val1 in self.battery:
00281         _x = val1
00282         buff.write(_struct_6B.pack(_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited))
00283         _v3 = val1.last_battery_update
00284         _x = _v3
00285         buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00286         buff.write(val1.battery_register.tostring())
00287         buff.write(val1.battery_update_flag.tostring())
00288         for val2 in val1.battery_register_update:
00289           _x = val2
00290           buff.write(_struct_2I.pack(_x.secs, _x.nsecs))
00291     except struct.error as se: self._check_types(se)
00292     except TypeError as te: self._check_types(te)
00293 
00294   def deserialize_numpy(self, str, numpy):
00295     """
00296     unpack serialized message in str into this message instance using numpy for array types
00297     :param str: byte array of serialized message, ``str``
00298     :param numpy: numpy python module
00299     """
00300     try:
00301       if self.header is None:
00302         self.header = std_msgs.msg.Header()
00303       if self.last_system_update is None:
00304         self.last_system_update = genpy.Time()
00305       if self.time_left is None:
00306         self.time_left = genpy.Duration()
00307       if self.last_controller_update is None:
00308         self.last_controller_update = genpy.Time()
00309       if self.battery is None:
00310         self.battery = None
00311       end = 0
00312       _x = self
00313       start = end
00314       end += 12
00315       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00316       start = end
00317       end += 4
00318       (length,) = _struct_I.unpack(str[start:end])
00319       start = end
00320       end += length
00321       if python3:
00322         self.header.frame_id = str[start:end].decode('utf-8')
00323       else:
00324         self.header.frame_id = str[start:end]
00325       _x = self
00326       start = end
00327       end += 24
00328       (_x.id, _x.last_system_update.secs, _x.last_system_update.nsecs, _x.time_left.secs, _x.time_left.nsecs, _x.average_charge,) = _struct_i2I3i.unpack(str[start:end])
00329       start = end
00330       end += 4
00331       (length,) = _struct_I.unpack(str[start:end])
00332       start = end
00333       end += length
00334       if python3:
00335         self.message = str[start:end].decode('utf-8')
00336       else:
00337         self.message = str[start:end]
00338       _x = self
00339       start = end
00340       end += 8
00341       (_x.last_controller_update.secs, _x.last_controller_update.nsecs,) = _struct_2I.unpack(str[start:end])
00342       start = end
00343       end += 4
00344       (length,) = _struct_I.unpack(str[start:end])
00345       self.battery = []
00346       for i in range(0, length):
00347         val1 = pr2_msgs.msg.BatteryState2()
00348         _x = val1
00349         start = end
00350         end += 6
00351         (_x.present, _x.charging, _x.discharging, _x.power_present, _x.power_no_good, _x.inhibited,) = _struct_6B.unpack(str[start:end])
00352         val1.present = bool(val1.present)
00353         val1.charging = bool(val1.charging)
00354         val1.discharging = bool(val1.discharging)
00355         val1.power_present = bool(val1.power_present)
00356         val1.power_no_good = bool(val1.power_no_good)
00357         val1.inhibited = bool(val1.inhibited)
00358         _v4 = val1.last_battery_update
00359         _x = _v4
00360         start = end
00361         end += 8
00362         (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00363         start = end
00364         end += 96
00365         val1.battery_register = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=48)
00366         start = end
00367         end += 48
00368         val1.battery_update_flag = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=48)
00369         val1.battery_update_flag = map(bool, val1.battery_update_flag)
00370         val1.battery_register_update = []
00371         for i in range(0, 48):
00372           val2 = genpy.Time()
00373           _x = val2
00374           start = end
00375           end += 8
00376           (_x.secs, _x.nsecs,) = _struct_2I.unpack(str[start:end])
00377           val1.battery_register_update.append(val2)
00378         self.battery.append(val1)
00379       self.last_system_update.canon()
00380       self.time_left.canon()
00381       self.last_controller_update.canon()
00382       return self
00383     except struct.error as e:
00384       raise genpy.DeserializationError(e) #most likely buffer underfill
00385 
00386 _struct_I = genpy.struct_I
00387 _struct_6B = struct.Struct("<6B")
00388 _struct_i2I3i = struct.Struct("<i2I3i")
00389 _struct_48h = struct.Struct("<48h")
00390 _struct_48B = struct.Struct("<48B")
00391 _struct_3I = struct.Struct("<3I")
00392 _struct_2I = struct.Struct("<2I")


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