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

Source Code for Module eddiebot_node.msg._BatteryState

  1  """autogenerated by genpy from eddiebot_node/BatteryState.msg. Do not edit.""" 
  2  import sys 
  3  python3 = True if sys.hexversion > 0x03000000 else False 
  4  import genpy 
  5  import struct 
  6   
  7  import std_msgs.msg 
  8   
9 -class BatteryState(genpy.Message):
10 _md5sum = "481447a4e24f212e7b403e4f04aa2ac9" 11 _type = "eddiebot_node/BatteryState" 12 _has_header = True #flag to mark the presence of a Header object 13 _full_text = """Header header 14 int8 temperature 15 uint16 charge 16 uint16 capacity 17 18 ================================================================================ 19 MSG: std_msgs/Header 20 # Standard metadata for higher-level stamped data types. 21 # This is generally used to communicate timestamped data 22 # in a particular coordinate frame. 23 # 24 # sequence ID: consecutively increasing ID 25 uint32 seq 26 #Two-integer timestamp that is expressed as: 27 # * stamp.secs: seconds (stamp_secs) since epoch 28 # * stamp.nsecs: nanoseconds since stamp_secs 29 # time-handling sugar is provided by the client library 30 time stamp 31 #Frame this data is associated with 32 # 0: no frame 33 # 1: global frame 34 string frame_id 35 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(_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(_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(_x)))) 94 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
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,) = _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,) = _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(_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(_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(_x)))) 145 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
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,) = _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,) = _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 _struct_3I = struct.Struct("<3I") 180 _struct_b2H = struct.Struct("<b2H") 181