00001 """autogenerated by genmsg_py from BatteryState.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005
00006 class BatteryState(roslib.message.Message):
00007 _md5sum = "00e9f996c2fc26700fd25abcd8422db0"
00008 _type = "pr2_msgs/BatteryState"
00009 _has_header = False
00010 _full_text = """# DEPRECATED. Use pr2_msgs/BatteryState2 instead.
00011 # Each batteries registers
00012 int32 lastTimeBattery #epoch time
00013 uint16[48] batReg
00014 uint16[48] batRegFlag
00015 int32[48] batRegTime
00016
00017 """
00018 __slots__ = ['lastTimeBattery','batReg','batRegFlag','batRegTime']
00019 _slot_types = ['int32','uint16[48]','uint16[48]','int32[48]']
00020
00021 def __init__(self, *args, **kwds):
00022 """
00023 Constructor. Any message fields that are implicitly/explicitly
00024 set to None will be assigned a default value. The recommend
00025 use is keyword arguments as this is more robust to future message
00026 changes. You cannot mix in-order arguments and keyword arguments.
00027
00028 The available fields are:
00029 lastTimeBattery,batReg,batRegFlag,batRegTime
00030
00031 @param args: complete set of field values, in .msg order
00032 @param kwds: use keyword arguments corresponding to message field names
00033 to set specific fields.
00034 """
00035 if args or kwds:
00036 super(BatteryState, self).__init__(*args, **kwds)
00037
00038 if self.lastTimeBattery is None:
00039 self.lastTimeBattery = 0
00040 if self.batReg is None:
00041 self.batReg = [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]
00042 if self.batRegFlag is None:
00043 self.batRegFlag = [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]
00044 if self.batRegTime is None:
00045 self.batRegTime = [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]
00046 else:
00047 self.lastTimeBattery = 0
00048 self.batReg = [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]
00049 self.batRegFlag = [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]
00050 self.batRegTime = [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]
00051
00052 def _get_types(self):
00053 """
00054 internal API method
00055 """
00056 return self._slot_types
00057
00058 def serialize(self, buff):
00059 """
00060 serialize message into buffer
00061 @param buff: buffer
00062 @type buff: StringIO
00063 """
00064 try:
00065 buff.write(_struct_i.pack(self.lastTimeBattery))
00066 buff.write(_struct_48H.pack(*self.batReg))
00067 buff.write(_struct_48H.pack(*self.batRegFlag))
00068 buff.write(_struct_48i.pack(*self.batRegTime))
00069 except struct.error, se: self._check_types(se)
00070 except TypeError, te: self._check_types(te)
00071
00072 def deserialize(self, str):
00073 """
00074 unpack serialized message in str into this message instance
00075 @param str: byte array of serialized message
00076 @type str: str
00077 """
00078 try:
00079 end = 0
00080 start = end
00081 end += 4
00082 (self.lastTimeBattery,) = _struct_i.unpack(str[start:end])
00083 start = end
00084 end += 96
00085 self.batReg = _struct_48H.unpack(str[start:end])
00086 start = end
00087 end += 96
00088 self.batRegFlag = _struct_48H.unpack(str[start:end])
00089 start = end
00090 end += 192
00091 self.batRegTime = _struct_48i.unpack(str[start:end])
00092 return self
00093 except struct.error, e:
00094 raise roslib.message.DeserializationError(e)
00095
00096
00097 def serialize_numpy(self, buff, numpy):
00098 """
00099 serialize message with numpy array types into buffer
00100 @param buff: buffer
00101 @type buff: StringIO
00102 @param numpy: numpy python module
00103 @type numpy module
00104 """
00105 try:
00106 buff.write(_struct_i.pack(self.lastTimeBattery))
00107 buff.write(self.batReg.tostring())
00108 buff.write(self.batRegFlag.tostring())
00109 buff.write(self.batRegTime.tostring())
00110 except struct.error, se: self._check_types(se)
00111 except TypeError, te: self._check_types(te)
00112
00113 def deserialize_numpy(self, str, numpy):
00114 """
00115 unpack serialized message in str into this message instance using numpy for array types
00116 @param str: byte array of serialized message
00117 @type str: str
00118 @param numpy: numpy python module
00119 @type numpy: module
00120 """
00121 try:
00122 end = 0
00123 start = end
00124 end += 4
00125 (self.lastTimeBattery,) = _struct_i.unpack(str[start:end])
00126 start = end
00127 end += 96
00128 self.batReg = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=48)
00129 start = end
00130 end += 96
00131 self.batRegFlag = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=48)
00132 start = end
00133 end += 192
00134 self.batRegTime = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=48)
00135 return self
00136 except struct.error, e:
00137 raise roslib.message.DeserializationError(e)
00138
00139 _struct_I = roslib.message.struct_I
00140 _struct_i = struct.Struct("<i")
00141 _struct_48i = struct.Struct("<48i")
00142 _struct_48H = struct.Struct("<48H")