wu_xinjun
2022-03-09 44ecd09af35a006f28fedfcec49ae40e973b10c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from .components import *
from .constants import *
from ctypes import sizeof, string_at
 
 
 
class MicroWaveParser:
    @classmethod
    def ParserFrame(cls, buffer: bytes) -> list:
        """
        解析完整的一帧数据,数据包括数据头,数据体,数据尾,返回点云数组
        """
        header = HeaderBlock(buffer[:sizeof(HeaderBlock)])
        if HEADER_MAGIC == string_at(header.Magic, 8):
            footer = FooterBlock(buffer[-sizeof(FooterBlock):])
            point_cloud = []
            for i in range(header.NumberOfDetection):
                detection = DetectionBlock(header, footer, buffer[i * 8 + sizeof(HeaderBlock): (i + 1) * 8 + sizeof(HeaderBlock)])
                point = (detection.X, detection.Y, detection.Z)
                point_cloud.append(point)
            return point_cloud
        else:
            return []