Skip to content

Commit 8a9f24c

Browse files
committed
fix #34
1 parent eaf1a96 commit 8a9f24c

22 files changed

+104
-52
lines changed

pdu/python/drone_srv_msgs/pdu_conv_CameraCaptureImageResponse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ def binary_write_recursive_CameraCaptureImageResponse(parent_off: int, bw_contai
109109
type = "uint8"
110110
off = 4
111111

112-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
112+
offset_from_heap = bw_container.heap_allocator.size()
113+
if allocator.is_heap:
114+
offset_from_heap += 8 # 8 bytes for array_size and offset
113115
array_size = len(py_obj.data)
114116
a_b = array_size.to_bytes(4, byteorder='little')
115117
o_b = offset_from_heap.to_bytes(4, byteorder='little')
116-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
118+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
117119
binary = binary_io.typeTobin_array(type, py_obj.data, 1)
118120
bw_container.heap_allocator.add(binary, expected_offset=0)
119121

pdu/python/hako_msgs/pdu_conv_DisturbanceUserCustom.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ def binary_write_recursive_DisturbanceUserCustom(parent_off: int, bw_container:
7373
type = "float64"
7474
off = 0
7575

76-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
76+
offset_from_heap = bw_container.heap_allocator.size()
77+
if allocator.is_heap:
78+
offset_from_heap += 8 # 8 bytes for array_size and offset
7779
array_size = len(py_obj.data)
7880
a_b = array_size.to_bytes(4, byteorder='little')
7981
o_b = offset_from_heap.to_bytes(4, byteorder='little')
80-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
82+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
8183
binary = binary_io.typeTobin_array(type, py_obj.data, 8)
8284
bw_container.heap_allocator.add(binary, expected_offset=0)
8385

pdu/python/hako_msgs/pdu_conv_SimpleStructVarray.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ def binary_write_recursive_SimpleStructVarray(parent_off: int, bw_container: Bin
164164
type = "string"
165165
off = 260
166166

167-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
167+
offset_from_heap = bw_container.heap_allocator.size()
168+
if allocator.is_heap:
169+
offset_from_heap += 8 # 8 bytes for array_size and offset
168170
array_size = len(py_obj.varray_str)
169171
a_b = array_size.to_bytes(4, byteorder='little')
170172
o_b = offset_from_heap.to_bytes(4, byteorder='little')
171-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
173+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
172174
binary = binary_io.typeTobin_array(type, py_obj.varray_str, 128)
173175
bw_container.heap_allocator.add(binary, expected_offset=0)
174176

pdu/python/hako_msgs/pdu_conv_SimpleVarray.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ def binary_write_recursive_SimpleVarray(parent_off: int, bw_container: BinaryWri
9595
type = "int8"
9696
off = 0
9797

98-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
98+
offset_from_heap = bw_container.heap_allocator.size()
99+
if allocator.is_heap:
100+
offset_from_heap += 8 # 8 bytes for array_size and offset
99101
array_size = len(py_obj.data)
100102
a_b = array_size.to_bytes(4, byteorder='little')
101103
o_b = offset_from_heap.to_bytes(4, byteorder='little')
102-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
104+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
103105
binary = binary_io.typeTobin_array(type, py_obj.data, 1)
104106
bw_container.heap_allocator.add(binary, expected_offset=0)
105107

pdu/python/sensor_msgs/pdu_conv_CameraInfo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@ def binary_write_recursive_CameraInfo(parent_off: int, bw_container: BinaryWrite
238238
type = "float64"
239239
off = 272
240240

241-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
241+
offset_from_heap = bw_container.heap_allocator.size()
242+
if allocator.is_heap:
243+
offset_from_heap += 8 # 8 bytes for array_size and offset
242244
array_size = len(py_obj.d)
243245
a_b = array_size.to_bytes(4, byteorder='little')
244246
o_b = offset_from_heap.to_bytes(4, byteorder='little')
245-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
247+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
246248
binary = binary_io.typeTobin_array(type, py_obj.d, 8)
247249
bw_container.heap_allocator.add(binary, expected_offset=0)
248250

pdu/python/sensor_msgs/pdu_conv_CompressedImage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ def binary_write_recursive_CompressedImage(parent_off: int, bw_container: Binary
121121
type = "uint8"
122122
off = 264
123123

124-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
124+
offset_from_heap = bw_container.heap_allocator.size()
125+
if allocator.is_heap:
126+
offset_from_heap += 8 # 8 bytes for array_size and offset
125127
array_size = len(py_obj.data)
126128
a_b = array_size.to_bytes(4, byteorder='little')
127129
o_b = offset_from_heap.to_bytes(4, byteorder='little')
128-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
130+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
129131
binary = binary_io.typeTobin_array(type, py_obj.data, 1)
130132
bw_container.heap_allocator.add(binary, expected_offset=0)
131133

pdu/python/sensor_msgs/pdu_conv_Image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ def binary_write_recursive_Image(parent_off: int, bw_container: BinaryWriterCont
221221
type = "uint8"
222222
off = 280
223223

224-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
224+
offset_from_heap = bw_container.heap_allocator.size()
225+
if allocator.is_heap:
226+
offset_from_heap += 8 # 8 bytes for array_size and offset
225227
array_size = len(py_obj.data)
226228
a_b = array_size.to_bytes(4, byteorder='little')
227229
o_b = offset_from_heap.to_bytes(4, byteorder='little')
228-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
230+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
229231
binary = binary_io.typeTobin_array(type, py_obj.data, 1)
230232
bw_container.heap_allocator.add(binary, expected_offset=0)
231233

pdu/python/sensor_msgs/pdu_conv_JointState.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ def binary_write_recursive_JointState(parent_off: int, bw_container: BinaryWrite
135135
type = "string"
136136
off = 136
137137

138-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
138+
offset_from_heap = bw_container.heap_allocator.size()
139+
if allocator.is_heap:
140+
offset_from_heap += 8 # 8 bytes for array_size and offset
139141
array_size = len(py_obj.name)
140142
a_b = array_size.to_bytes(4, byteorder='little')
141143
o_b = offset_from_heap.to_bytes(4, byteorder='little')
142-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
144+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
143145
binary = binary_io.typeTobin_array(type, py_obj.name, 128)
144146
bw_container.heap_allocator.add(binary, expected_offset=0)
145147

@@ -152,11 +154,13 @@ def binary_write_recursive_JointState(parent_off: int, bw_container: BinaryWrite
152154
type = "float64"
153155
off = 144
154156

155-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
157+
offset_from_heap = bw_container.heap_allocator.size()
158+
if allocator.is_heap:
159+
offset_from_heap += 8 # 8 bytes for array_size and offset
156160
array_size = len(py_obj.position)
157161
a_b = array_size.to_bytes(4, byteorder='little')
158162
o_b = offset_from_heap.to_bytes(4, byteorder='little')
159-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
163+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
160164
binary = binary_io.typeTobin_array(type, py_obj.position, 8)
161165
bw_container.heap_allocator.add(binary, expected_offset=0)
162166

@@ -169,11 +173,13 @@ def binary_write_recursive_JointState(parent_off: int, bw_container: BinaryWrite
169173
type = "float64"
170174
off = 152
171175

172-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
176+
offset_from_heap = bw_container.heap_allocator.size()
177+
if allocator.is_heap:
178+
offset_from_heap += 8 # 8 bytes for array_size and offset
173179
array_size = len(py_obj.velocity)
174180
a_b = array_size.to_bytes(4, byteorder='little')
175181
o_b = offset_from_heap.to_bytes(4, byteorder='little')
176-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
182+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
177183
binary = binary_io.typeTobin_array(type, py_obj.velocity, 8)
178184
bw_container.heap_allocator.add(binary, expected_offset=0)
179185

@@ -186,11 +192,13 @@ def binary_write_recursive_JointState(parent_off: int, bw_container: BinaryWrite
186192
type = "float64"
187193
off = 160
188194

189-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
195+
offset_from_heap = bw_container.heap_allocator.size()
196+
if allocator.is_heap:
197+
offset_from_heap += 8 # 8 bytes for array_size and offset
190198
array_size = len(py_obj.effort)
191199
a_b = array_size.to_bytes(4, byteorder='little')
192200
o_b = offset_from_heap.to_bytes(4, byteorder='little')
193-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
201+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
194202
binary = binary_io.typeTobin_array(type, py_obj.effort, 8)
195203
bw_container.heap_allocator.add(binary, expected_offset=0)
196204

pdu/python/sensor_msgs/pdu_conv_LaserScan.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,13 @@ def binary_write_recursive_LaserScan(parent_off: int, bw_container: BinaryWriter
284284
type = "float32"
285285
off = 164
286286

287-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
287+
offset_from_heap = bw_container.heap_allocator.size()
288+
if allocator.is_heap:
289+
offset_from_heap += 8 # 8 bytes for array_size and offset
288290
array_size = len(py_obj.ranges)
289291
a_b = array_size.to_bytes(4, byteorder='little')
290292
o_b = offset_from_heap.to_bytes(4, byteorder='little')
291-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
293+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
292294
binary = binary_io.typeTobin_array(type, py_obj.ranges, 4)
293295
bw_container.heap_allocator.add(binary, expected_offset=0)
294296

@@ -301,11 +303,13 @@ def binary_write_recursive_LaserScan(parent_off: int, bw_container: BinaryWriter
301303
type = "float32"
302304
off = 172
303305

304-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
306+
offset_from_heap = bw_container.heap_allocator.size()
307+
if allocator.is_heap:
308+
offset_from_heap += 8 # 8 bytes for array_size and offset
305309
array_size = len(py_obj.intensities)
306310
a_b = array_size.to_bytes(4, byteorder='little')
307311
o_b = offset_from_heap.to_bytes(4, byteorder='little')
308-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
312+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
309313
binary = binary_io.typeTobin_array(type, py_obj.intensities, 4)
310314
bw_container.heap_allocator.add(binary, expected_offset=0)
311315

pdu/python/sensor_msgs/pdu_conv_PointCloud2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,13 @@ def binary_write_recursive_PointCloud2(parent_off: int, bw_container: BinaryWrit
272272
type = "uint8"
273273
off = 164
274274

275-
offset_from_heap = bw_container.heap_allocator.size() + 8 # 8 bytes for array_size and offset
275+
offset_from_heap = bw_container.heap_allocator.size()
276+
if allocator.is_heap:
277+
offset_from_heap += 8 # 8 bytes for array_size and offset
276278
array_size = len(py_obj.data)
277279
a_b = array_size.to_bytes(4, byteorder='little')
278280
o_b = offset_from_heap.to_bytes(4, byteorder='little')
279-
bw_container.heap_allocator.add(a_b + o_b, expected_offset=parent_off + off)
281+
allocator.add(a_b + o_b, expected_offset=parent_off + off)
280282
binary = binary_io.typeTobin_array(type, py_obj.data, 1)
281283
bw_container.heap_allocator.add(binary, expected_offset=0)
282284

0 commit comments

Comments
 (0)