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