在ROS系统中使用PCL教程.pdfVIP

  • 76
  • 0
  • 约1.46万字
  • 约 8页
  • 2021-11-08 发布于重庆
  • 举报
在 ROS系统中使用 PCL教程 在 ROS 中点云的数据类型 在 ROS 中表示点云的数据结构有: sensor_msgs::PointCloud sensor_msgs::PointCloud2 pcl::PointCloudT 关于 PCL 在 ros 的数据的结构,具体的介绍可查 看 wiki.ros.org/pcl/Overview 关于 sensor_msgs::PointCloud2 和 pcl::PointCloudT 之间的转换 使用 pcl::fromROSMsg 和 pcl::toROSMsg sensor_msgs::PointCloud 和 sensor_msgs::PointCloud2 之间的转 换 使用 sensor_msgs::convertPointCloud2ToPointCloud 和 sensor_msgs::convertPointCloudToPointCloud2. 那么如何在 ROS 中使用 PCL 呢? (1 )在建立的包下的 CMakeLists.txt 文件下添加依赖项 在 package.xml 文件里添加: build_dependlibpcl-all-dev/build_depend run_dependlibpcl- all/run_depend 在 src 文件夹下新建 .cpp 文件 #includeros/ros.h // PCL specific includes #include sensor_msgs/PointCloud2.h #include pcl_conversions/pcl_conversions.h #include pcl/point_cloud.h #include pcl/point_types.h ros::Publisher pub; void cloud_cb ( const sensor_msgs::PointCloud2ConstPtr input) { // Create a container for the data. sensor_msgs::PointCloud2 output; // Do data processing here... output = *input; // Publish the data. pub.publish (output); } int main ( int argc, char ** argv) { // Initialize ROS ros::init (argc, argv, my_pcl_tutorial ); ros::NodeHandle nh; ros::Subscriber sub = nh.subscribe ( input , 1, cloud_cb); pub = nh.advertisesensor_msgs::PointCloud2 ( output , 1); // Spin ros::spin (); } 在 CMakeLists.txt 文件中添加 : add_executable(example src/example.cpp) target_link_libraries(example ${catkin_LIBRARIES}) catkin_make 之后生成可执行文件,运行以下命令 roslaunch openni_launch openni.launch 这是打开 kinect 发布的命令 rosrun ros_slam example input:=/camera/depth/points 运

文档评论(0)

1亿VIP精品文档

相关文档