python 解析 velodyne 16线雷达 pcap 文件,并保存为pcd文件

按照 velodyne 的协议解析 pcap 数据,window运行,不依赖ros, 最后把每帧保存为pcd 文件(这里只保存了一帧,可以根据自己需要改为保存每一帧),话不多说,直接上代码吧,修正了之前代码的bug, 确保可以运行。完全自己写的代码,非抄袭

# -*- coding: UTF-8 -*-


import dpkt
import collections  # 有序字典需要的模块
import time
import numpy as np
import struct
import open3d as o3d



# pip install dpkt



point_cloud = o3d.geometry.PointCloud()





# vlp 16 的参数
DISTANCE_RESOLUTION = 0.002   # 距离数值分辨率 转换为单位米
udp_package_num = 1
line_per_udp = 12        # 每个UDP 有多少列
point_per_udp_line = 32  # 每个UDP 的每列包含有多少个点
point_num_per_udp = point_per_udp_line * line_per_udp  # 32*12=384

thetas_lines = [-15, 1, -13, 3, -11, 5, -9, 7, -7, 9, -5, 11, -3, 13, -1, 15]

thetas_point = thetas_lines * 2 * line_per_udp * udp_package_num
thetas_point = np.radians(thetas_point)
thetas_point_cos = np.cos(thetas_point)
thetas_point_sin = np.sin(thetas_point)

你可能感兴趣的:(点云-激光雷达处理代码合集,python,开发语言,numpy,机器学习)