安装python-pcl
- 成功安装
- 错误尝试
- 尝试一
- 尝试二
- 尝试三
本人环境
Ubuntu 22.04.4LTS
ros2-humble
cpython 3.0.11
python 3.10.12
libpcl-dev 1.12.1+dfsg-3build1
pcl-tools 1.12.1+dfsg-3build1
代码摘抄来源:Breadcrumbsouster-ros-extras/scripts/ros2_pcl_filters.py
def convert_pointcloud2_to_pcl(self, msg):data = pc2.read_points(msg, field_names="xyz")points = np.array(list(data), dtype=np.float32)cloud = pcl.PointCloud()cloud.from_array(points)return cloud
def convert_pcl_to_pointcloud2(self, pcl_cloud, header):points = pcl_cloud.to_array()fields = [PointField(name='x', offset=0,datatype=PointField.FLOAT32, count=1),PointField(name='y', offset=4,datatype=PointField.FLOAT32, count=1),PointField(name='z', offset=8,datatype=PointField.FLOAT32, count=1)]return pc2.create_cloud(header, fields, points)
成功安装
sudo apt install python3-pcl
参考链接:Python 3.8 compatibility issue
成功运行截图
错误尝试
尝试一
pip3 install pcl
函数调用报错
[lidar_3d_detector.py-1] cloud = pcl.PointCloud()
[lidar_3d_detector.py-1] AttributeError: module 'pcl' has no attribute 'PointCloud'
尝试二
pip3 install python-pcl -i https://pypi.mirrors.ustc.edu.cn/simple/
尝试三
git clone https://github.com/strawlab/python-pcl.git
cd python-pcl/