# ROS PCL MLS因点云类型转换无法工作怎么办？

> 原文链接：https://robotics.hellobike.com/pitfalls/2018-01-27-robotics-se-15044
> 频道：pitfalls | 更新日期：2018-01-27 | 标签：auto, stackexchange, ros, point-cloud
> 核心摘要：ROS MLS点云节点问题出在消息到PCL点云转换，补上pcl_conversions::toPCL()后可运行。

# ROS PCL MLS因点云类型转换无法工作怎么办？

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[ROS PCL: Help with Moving Least Squares filter](https://robotics.stackexchange.com/questions/15044/ros-pcl-help-with-moving-least-squares-filter)（Robotics Stack Exchange #15044）

**状态**：已解决

## 问题

实现ROS节点对`sensor_msgs/PointCloud2`做Moving Least Squares处理时无法正常工作；PCL教程本身可编译运行。

## 环境

Linux / ROS 机器人软件与控制通用开发环境

## 解决办法

1. 在回调中先调用`pcl_conversions::toPCL()`，将ROS的`sensor_msgs::PointCloud2`转换为PCL消息类型。
2. 再进行后续PCL点云类型转换和`pcl::MovingLeastSquares`处理。
3. 处理后按原流程转换回ROS消息并发布。

原问题作者：aaronsnoswell；采纳答案作者：aaronsnoswell。原内容依 CC BY-SA 4.0 授权，本页摘要同样依 CC BY-SA 4.0 授权。
:::

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #15044：ROS PCL: Help with Moving Least Squares filter](https://robotics.stackexchange.com/questions/15044/ros-pcl-help-with-moving-least-squares-filter)