MEPP2 Project
pcd_write.cpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #include <iostream>
12 
13 #include <pcl/io/pcd_io.h>
14 #include <pcl/point_types.h>
15 
16 int
17 main(void)
18 {
19  pcl::PointCloud< pcl::PointXYZ > cloud;
20 
21  // Fill in the cloud data
22  cloud.width = 5;
23  cloud.height = 1;
24  cloud.is_dense = false;
25  cloud.points.resize(cloud.width * cloud.height);
26 
27  for(size_t i = 0; i < cloud.points.size(); ++i)
28  {
29  cloud.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
30  cloud.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
31  cloud.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
32  }
33 
34  pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);
35  std::cerr << "Saved " << cloud.points.size()
36  << " data points to test_pcd.pcd." << std::endl;
37 
38  for(size_t i = 0; i < cloud.points.size(); ++i)
39  std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " "
40  << cloud.points[i].z << std::endl;
41 
42  return (0);
43 }
main
int main(void)
Definition: pcd_write.cpp:17