Go to the documentation of this file.00001
00002 #include <pcl/io/pcd_io.h>
00003 #include <pcl/io/impl/pcd_io.hpp>
00004 #include <pcl_ros/point_cloud.h>
00005 #include <ros/ros.h>
00006
00007 #include "point_cloud_color/point_cloud_accessor.h"
00008
00009 namespace point_cloud_color {
00010 class PclInfo {
00011 private:
00012 ros::NodeHandle nh;
00013 ros::NodeHandle pnh;
00014 std::string pclPath;
00015 sensor_msgs::PointCloud2::Ptr cloudPtr;
00016 public:
00017 PclInfo();
00018
00019 };
00020
00021 PclInfo::PclInfo() : nh(), pnh("~"), pclPath(), cloudPtr(new sensor_msgs::PointCloud2) {
00022 pnh.param("pcl_path", pclPath, pclPath);
00023 ROS_INFO("PCL path: %s.", pclPath.c_str());
00024 pcl::io::loadPCDFile(pclPath, *cloudPtr);
00025 std::vector<std::string> fieldNames;
00026 fieldNames.push_back("x");
00027 fieldNames.push_back("y");
00028 fieldNames.push_back("z");
00029 PointCloudAccessor cloudIter(cloudPtr, fieldNames);
00030 uint32_t numPoints = cloudPtr->width * cloudPtr->height;
00031 int debug = 0;
00032 for (uint32_t iPoint = 0; iPoint < numPoints && debug++ < 10; iPoint++) {
00033 for (uint32_t iField = 0; iField < fieldNames.size(); iField++) {
00034 ROS_INFO("Point %i, field %i: %.2f.", iPoint, iField, cloudIter.getField<float>(iPoint, iField));
00035 }
00036 }
00037 }
00038
00039 }
00040
00041 int main(int argc, char **argv) {
00042 ros::init(argc, argv, "pcl_info");
00043 point_cloud_color::PclInfo node;
00044 ros::spin();
00045 }