Package create_node :: Package msg :: Module _BatteryState
[frames] | no frames]

Source Code for Module create_node.msg._BatteryState

  1  # This Python file uses the following encoding: utf-8 
  2  """autogenerated by genpy from create_node/BatteryState.msg. Do not edit.""" 
  3  import sys 
  4  python3 = True if sys.hexversion > 0x03000000 else False 
  5  import genpy 
  6  import struct 
  7   
  8  import std_msgs.msg 
  9   
10 -class BatteryState(genpy.Message):
11 _md5sum = "481447a4e24f212e7b403e4f04aa2ac9" 12 _type = "create_node/BatteryState" 13 _has_header = True #flag to mark the presence of a Header object 14 _full_text = """Header header 15 int8 temperature 16 uint16 charge 17 uint16 capacity 18 19 ================================================================================ 20 MSG: std_msgs/Header 21 # Standard metadata for higher-level stamped data types. 22 # This is generally used to communicate timestamped data 23 # in a particular coordinate frame. 24 # 25 # sequence ID: consecutively increasing ID 26 uint32 seq 27 #Two-integer timestamp that is expressed as: 28 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs') 29 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs') 30 # time-handling sugar is provided by the client library 31 time stamp 32 #Frame this data is associated with 33 # 0: no frame 34 # 1: global frame 35 string frame_id 36 """ 37 __slots__ = ['header','temperature','charge','capacity'] 38 _slot_types = ['std_msgs/Header','int8','uint16','uint16'] 39
40 - def __init__(self, *args, **kwds):
41 """ 42 Constructor. Any message fields that are implicitly/explicitly 43 set to None will be assigned a default value. The recommend 44 use is keyword arguments as this is more robust to future message 45 changes. You cannot mix in-order arguments and keyword arguments. 46 47 The available fields are: 48 header,temperature,charge,capacity 49 50 :param args: complete set of field values, in .msg order 51 :param kwds: use keyword arguments corresponding to message field names 52 to set specific fields. 53 """ 54 if args or kwds: 55 super(BatteryState, self).__init__(*args, **kwds) 56 #message fields cannot be None, assign default values for those that are 57 if self.header is None: 58 self.header = std_msgs.msg.Header() 59 if self.temperature is None: 60 self.temperature = 0 61 if self.charge is None: 62 self.charge = 0 63 if self.capacity is None: 64 self.capacity = 0 65 else: 66 self.header = std_msgs.msg.Header() 67 self.temperature = 0 68 self.charge = 0 69 self.capacity = 0
70
71 - def _get_types(self):
72 """ 73 internal API method 74 """ 75 return self._slot_types
76
77 - def serialize(self, buff):
78 """ 79 serialize message into buffer 80 :param buff: buffer, ``StringIO`` 81 """ 82 try: 83 _x = self 84 buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 85 _x = self.header.frame_id 86 length = len(_x) 87 if python3 or type(_x) == unicode: 88 _x = _x.encode('utf-8') 89 length = len(_x) 90 buff.write(struct.pack('<I%ss'%length, length, _x)) 91 _x = self 92 buff.write(_get_struct_b2H().pack(_x.temperature, _x.charge, _x.capacity)) 93 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) 94 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
95
96 - def deserialize(self, str):
97 """ 98 unpack serialized message in str into this message instance 99 :param str: byte array of serialized message, ``str`` 100 """ 101 try: 102 if self.header is None: 103 self.header = std_msgs.msg.Header() 104 end = 0 105 _x = self 106 start = end 107 end += 12 108 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end]) 109 start = end 110 end += 4 111 (length,) = _struct_I.unpack(str[start:end]) 112 start = end 113 end += length 114 if python3: 115 self.header.frame_id = str[start:end].decode('utf-8') 116 else: 117 self.header.frame_id = str[start:end] 118 _x = self 119 start = end 120 end += 5 121 (_x.temperature, _x.charge, _x.capacity,) = _get_struct_b2H().unpack(str[start:end]) 122 return self 123 except struct.error as e: 124 raise genpy.DeserializationError(e) #most likely buffer underfill
125 126
127 - def serialize_numpy(self, buff, numpy):
128 """ 129 serialize message with numpy array types into buffer 130 :param buff: buffer, ``StringIO`` 131 :param numpy: numpy python module 132 """ 133 try: 134 _x = self 135 buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs)) 136 _x = self.header.frame_id 137 length = len(_x) 138 if python3 or type(_x) == unicode: 139 _x = _x.encode('utf-8') 140 length = len(_x) 141 buff.write(struct.pack('<I%ss'%length, length, _x)) 142 _x = self 143 buff.write(_get_struct_b2H().pack(_x.temperature, _x.charge, _x.capacity)) 144 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self))))) 145 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
146
147 - def deserialize_numpy(self, str, numpy):
148 """ 149 unpack serialized message in str into this message instance using numpy for array types 150 :param str: byte array of serialized message, ``str`` 151 :param numpy: numpy python module 152 """ 153 try: 154 if self.header is None: 155 self.header = std_msgs.msg.Header() 156 end = 0 157 _x = self 158 start = end 159 end += 12 160 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _get_struct_3I().unpack(str[start:end]) 161 start = end 162 end += 4 163 (length,) = _struct_I.unpack(str[start:end]) 164 start = end 165 end += length 166 if python3: 167 self.header.frame_id = str[start:end].decode('utf-8') 168 else: 169 self.header.frame_id = str[start:end] 170 _x = self 171 start = end 172 end += 5 173 (_x.temperature, _x.charge, _x.capacity,) = _get_struct_b2H().unpack(str[start:end]) 174 return self 175 except struct.error as e: 176 raise genpy.DeserializationError(e) #most likely buffer underfill
177 178 _struct_I = genpy.struct_I
179 -def _get_struct_I():
180 global _struct_I 181 return _struct_I
182 _struct_3I = None
183 -def _get_struct_3I():
184 global _struct_3I 185 if _struct_3I is None: 186 _struct_3I = struct.Struct("<3I") 187 return _struct_3I
188 _struct_b2H = None
189 -def _get_struct_b2H():
190 global _struct_b2H 191 if _struct_b2H is None: 192 _struct_b2H = struct.Struct("<b2H") 193 return _struct_b2H
194