1
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
11 _md5sum = "481447a4e24f212e7b403e4f04aa2ac9"
12 _type = "create_node/BatteryState"
13 _has_header = True
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
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
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
72 """
73 internal API method
74 """
75 return self._slot_types
76
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 if python3:
91 buff.write(struct.pack('<I%sB'%length, length, *_x))
92 else:
93 buff.write(struct.pack('<I%ss'%length, length, _x))
94 _x = self
95 buff.write(_struct_b2H.pack(_x.temperature, _x.charge, _x.capacity))
96 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
97 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
98
100 """
101 unpack serialized message in str into this message instance
102 :param str: byte array of serialized message, ``str``
103 """
104 try:
105 if self.header is None:
106 self.header = std_msgs.msg.Header()
107 end = 0
108 _x = self
109 start = end
110 end += 12
111 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
112 start = end
113 end += 4
114 (length,) = _struct_I.unpack(str[start:end])
115 start = end
116 end += length
117 if python3:
118 self.header.frame_id = str[start:end].decode('utf-8')
119 else:
120 self.header.frame_id = str[start:end]
121 _x = self
122 start = end
123 end += 5
124 (_x.temperature, _x.charge, _x.capacity,) = _struct_b2H.unpack(str[start:end])
125 return self
126 except struct.error as e:
127 raise genpy.DeserializationError(e)
128
129
131 """
132 serialize message with numpy array types into buffer
133 :param buff: buffer, ``StringIO``
134 :param numpy: numpy python module
135 """
136 try:
137 _x = self
138 buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
139 _x = self.header.frame_id
140 length = len(_x)
141 if python3 or type(_x) == unicode:
142 _x = _x.encode('utf-8')
143 length = len(_x)
144 if python3:
145 buff.write(struct.pack('<I%sB'%length, length, *_x))
146 else:
147 buff.write(struct.pack('<I%ss'%length, length, _x))
148 _x = self
149 buff.write(_struct_b2H.pack(_x.temperature, _x.charge, _x.capacity))
150 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
151 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))
152
154 """
155 unpack serialized message in str into this message instance using numpy for array types
156 :param str: byte array of serialized message, ``str``
157 :param numpy: numpy python module
158 """
159 try:
160 if self.header is None:
161 self.header = std_msgs.msg.Header()
162 end = 0
163 _x = self
164 start = end
165 end += 12
166 (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
167 start = end
168 end += 4
169 (length,) = _struct_I.unpack(str[start:end])
170 start = end
171 end += length
172 if python3:
173 self.header.frame_id = str[start:end].decode('utf-8')
174 else:
175 self.header.frame_id = str[start:end]
176 _x = self
177 start = end
178 end += 5
179 (_x.temperature, _x.charge, _x.capacity,) = _struct_b2H.unpack(str[start:end])
180 return self
181 except struct.error as e:
182 raise genpy.DeserializationError(e)
183
184 _struct_I = genpy.struct_I
185 _struct_3I = struct.Struct("<3I")
186 _struct_b2H = struct.Struct("<b2H")
187