00001 """autogenerated by genmsg_py from BatteryState.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import std_msgs.msg
00006
00007 class BatteryState(roslib.message.Message):
00008 _md5sum = "df2a7089f2b6c7d531f3fa587a65bbf2"
00009 _type = "erratic_player/BatteryState"
00010 _has_header = True
00011 _full_text = """Header header
00012 float32 charge
00013 float32 capacity
00014
00015 ================================================================================
00016 MSG: std_msgs/Header
00017 # Standard metadata for higher-level stamped data types.
00018 # This is generally used to communicate timestamped data
00019 # in a particular coordinate frame.
00020 #
00021 # sequence ID: consecutively increasing ID
00022 uint32 seq
00023 #Two-integer timestamp that is expressed as:
00024 # * stamp.secs: seconds (stamp_secs) since epoch
00025 # * stamp.nsecs: nanoseconds since stamp_secs
00026 # time-handling sugar is provided by the client library
00027 time stamp
00028 #Frame this data is associated with
00029 # 0: no frame
00030 # 1: global frame
00031 string frame_id
00032
00033 """
00034 __slots__ = ['header','charge','capacity']
00035 _slot_types = ['Header','float32','float32']
00036
00037 def __init__(self, *args, **kwds):
00038 """
00039 Constructor. Any message fields that are implicitly/explicitly
00040 set to None will be assigned a default value. The recommend
00041 use is keyword arguments as this is more robust to future message
00042 changes. You cannot mix in-order arguments and keyword arguments.
00043
00044 The available fields are:
00045 header,charge,capacity
00046
00047 @param args: complete set of field values, in .msg order
00048 @param kwds: use keyword arguments corresponding to message field names
00049 to set specific fields.
00050 """
00051 if args or kwds:
00052 super(BatteryState, self).__init__(*args, **kwds)
00053
00054 if self.header is None:
00055 self.header = std_msgs.msg._Header.Header()
00056 if self.charge is None:
00057 self.charge = 0.
00058 if self.capacity is None:
00059 self.capacity = 0.
00060 else:
00061 self.header = std_msgs.msg._Header.Header()
00062 self.charge = 0.
00063 self.capacity = 0.
00064
00065 def _get_types(self):
00066 """
00067 internal API method
00068 """
00069 return self._slot_types
00070
00071 def serialize(self, buff):
00072 """
00073 serialize message into buffer
00074 @param buff: buffer
00075 @type buff: StringIO
00076 """
00077 try:
00078 _x = self
00079 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00080 _x = self.header.frame_id
00081 length = len(_x)
00082 buff.write(struct.pack('<I%ss'%length, length, _x))
00083 _x = self
00084 buff.write(_struct_2f.pack(_x.charge, _x.capacity))
00085 except struct.error, se: self._check_types(se)
00086 except TypeError, te: self._check_types(te)
00087
00088 def deserialize(self, str):
00089 """
00090 unpack serialized message in str into this message instance
00091 @param str: byte array of serialized message
00092 @type str: str
00093 """
00094 try:
00095 if self.header is None:
00096 self.header = std_msgs.msg._Header.Header()
00097 end = 0
00098 _x = self
00099 start = end
00100 end += 12
00101 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00102 start = end
00103 end += 4
00104 (length,) = _struct_I.unpack(str[start:end])
00105 start = end
00106 end += length
00107 self.header.frame_id = str[start:end]
00108 _x = self
00109 start = end
00110 end += 8
00111 (_x.charge, _x.capacity,) = _struct_2f.unpack(str[start:end])
00112 return self
00113 except struct.error, e:
00114 raise roslib.message.DeserializationError(e)
00115
00116
00117 def serialize_numpy(self, buff, numpy):
00118 """
00119 serialize message with numpy array types into buffer
00120 @param buff: buffer
00121 @type buff: StringIO
00122 @param numpy: numpy python module
00123 @type numpy module
00124 """
00125 try:
00126 _x = self
00127 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00128 _x = self.header.frame_id
00129 length = len(_x)
00130 buff.write(struct.pack('<I%ss'%length, length, _x))
00131 _x = self
00132 buff.write(_struct_2f.pack(_x.charge, _x.capacity))
00133 except struct.error, se: self._check_types(se)
00134 except TypeError, te: self._check_types(te)
00135
00136 def deserialize_numpy(self, str, numpy):
00137 """
00138 unpack serialized message in str into this message instance using numpy for array types
00139 @param str: byte array of serialized message
00140 @type str: str
00141 @param numpy: numpy python module
00142 @type numpy: module
00143 """
00144 try:
00145 if self.header is None:
00146 self.header = std_msgs.msg._Header.Header()
00147 end = 0
00148 _x = self
00149 start = end
00150 end += 12
00151 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00152 start = end
00153 end += 4
00154 (length,) = _struct_I.unpack(str[start:end])
00155 start = end
00156 end += length
00157 self.header.frame_id = str[start:end]
00158 _x = self
00159 start = end
00160 end += 8
00161 (_x.charge, _x.capacity,) = _struct_2f.unpack(str[start:end])
00162 return self
00163 except struct.error, e:
00164 raise roslib.message.DeserializationError(e)
00165
00166 _struct_I = roslib.message.struct_I
00167 _struct_3I = struct.Struct("<3I")
00168 _struct_2f = struct.Struct("<2f")