PointcloudCreator.cpp
Go to the documentation of this file.
1 /*
2  * PointcloudCreator.cpp
3  *
4  * Created on: Nov 20, 2019
5  * Author: Edo Jelavic
6  * Institute: ETH Zurich, Robotic Systems Lab
7  */
8 
9 #include "PointcloudCreator.hpp"
10 
11 namespace grid_map {
12 namespace grid_map_pcl_test {
13 
14 Pointcloud::Ptr PointcloudCreator::createNoisyPointcloudOfStepTerrain(double* stepLocationX, double* zHigh, double* zLow, double* stdDev) {
15  std::uniform_real_distribution<double> heightDist(-2.0, 2.0);
16  const double maxXY = 3.0;
17  const double minXY = -3.0;
18  *stdDev = 0.01;
19  const unsigned int nPointsInCloud = 1000000;
20  *zHigh = heightDist(rndGenerator) + 2.1;
21  *zLow = heightDist(rndGenerator) - 2.1;
22  auto cloud = grid_map_pcl_test::createStepTerrain(nPointsInCloud, minXY, maxXY, *zHigh, *zLow, *stdDev, &rndGenerator, stepLocationX);
23 
24  return cloud;
25 }
26 
27 Pointcloud::Ptr PointcloudCreator::createBlobOfPoints(double* mean, double* stdDev) {
28  const unsigned int nPointsInCloud = 10000;
29  std::uniform_real_distribution<double> meanDist(-10.0, 10.0);
30  std::uniform_real_distribution<double> sigmaDist(0.001, 0.1);
31 
32  *mean = meanDist(rndGenerator);
33  *stdDev = sigmaDist(rndGenerator);
34 
35  auto cloud = grid_map_pcl_test::createNormallyDistributedBlobOfPoints(nPointsInCloud, *mean, *stdDev, &rndGenerator);
36 
37  return cloud;
38 }
39 
40 Pointcloud::Ptr PointcloudCreator::createVerticesOfASquare(double* x, double* y) {
41  grid_map_pcl_test::Pointcloud::Ptr cloud(new grid_map_pcl_test::Pointcloud());
42  std::uniform_real_distribution<double> zDist(-10.0, 10.0);
43  std::uniform_int_distribution<int> xDist(10, 20);
44  std::uniform_int_distribution<int> yDist(25, 40);
45  *x = xDist(rndGenerator);
46  *y = yDist(rndGenerator);
47 
48  cloud->points.emplace_back(*x, 0.0, zDist(rndGenerator));
49  cloud->points.emplace_back(-(*x), 0.0, zDist(rndGenerator));
50  cloud->points.emplace_back(0.0, *y, zDist(rndGenerator));
51  cloud->points.emplace_back(0.0, -(*y), zDist(rndGenerator));
52  cloud->is_dense = true;
53 
54  return cloud;
55 }
56 
57 Pointcloud::Ptr PointcloudCreator::createNoisyDoublePlane(double* minZ, double* stdDevZ) {
58  std::uniform_real_distribution<double> upperPlaneZDist(0.0, 10.0);
59  std::uniform_real_distribution<double> lowerPlaneZDist(-10.0, -5.0);
60  std::uniform_real_distribution<double> stdDevDist(0.001, 0.1);
61 
62  const double maxXY = 1.0;
63  const double minXY = -1.0;
64  *stdDevZ = stdDevDist(rndGenerator);
65 
66  // make it very dense such that we ensure that there is enough points
67  // that will make it into the cell
68  // todo should sample in a better way
69  const unsigned int nPointsInCloud = 1000000;
70  *minZ = lowerPlaneZDist(rndGenerator);
71  auto cloudLower = grid_map_pcl_test::createNoisyPlanePointcloud(nPointsInCloud, minXY, maxXY, *minZ, *stdDevZ, &rndGenerator);
72  auto cloudUpper =
73  grid_map_pcl_test::createNoisyPlanePointcloud(nPointsInCloud, minXY, maxXY, upperPlaneZDist(rndGenerator), *stdDevZ, &rndGenerator);
74  auto cloud = grid_map_pcl_test::concatenate(cloudUpper, cloudLower);
75 
76  return cloud;
77 }
78 
79 Pointcloud::Ptr PointcloudCreator::createNoisyPlane(double* height, double* stdDevZ) {
80  std::uniform_real_distribution<double> heightDist(-10.0, 10.0);
81  std::uniform_real_distribution<double> stdDevDist(0.001, 0.1);
82 
83  const double maxXY = 1.0;
84  const double minXY = -1.0;
85  *stdDevZ = stdDevDist(rndGenerator);
86 
87  // make it very dense such that we ensure that there is enough points
88  // that will make it into the cell
89  // todo should sample in a better way
90  const unsigned int nPointsInCloud = 1000000;
91  *height = heightDist(rndGenerator);
92 
93  auto cloud = grid_map_pcl_test::createNoisyPlanePointcloud(nPointsInCloud, minXY, maxXY, *height, *stdDevZ, &rndGenerator);
94 
95  return cloud;
96 }
97 
98 Pointcloud::Ptr PointcloudCreator::createPerfectPlane(double* height) {
99  std::uniform_real_distribution<double> heightDist(-10.0, 10.0);
100  const double maxXY = 3.0;
101  const double minXY = -3.0;
102  const unsigned int nPointsInCloud = 100000;
103  *height = heightDist(rndGenerator);
104  auto cloud = grid_map_pcl_test::createPerfectPlane(nPointsInCloud, minXY, maxXY, *height, &rndGenerator);
105 
106  return cloud;
107 }
108 
109 Pointcloud::Ptr PointcloudCreator::createNBlobsAboveEachOther(double* minZ, double* stdDevZ, int* nBlobs) {
110  const unsigned int nPointsInCloud = 1000;
111  std::uniform_real_distribution<double> sigmaDist(0.001, 0.015);
112  std::uniform_real_distribution<double> minZDist(-10.0, 10.0);
113  std::uniform_int_distribution<int> nDist(10, 20);
114  const double zStep = 2.0;
115 
116  *nBlobs = nDist(rndGenerator);
117  *minZ = minZDist(rndGenerator);
118  *stdDevZ = sigmaDist(rndGenerator);
119 
120  Pointcloud::Ptr cloud(new Pointcloud());
121 
122  for (int i = 0; i < *nBlobs; ++i) {
123  auto blob = grid_map_pcl_test::createNormallyDistributedBlobOfPoints(nPointsInCloud, *minZ + i * zStep, *stdDevZ, &rndGenerator);
124  auto temp = concatenate(cloud, blob);
125  cloud = temp;
126  }
127 
128  return cloud;
129 }
130 
131 } /* namespace grid_map_pcl_test*/
132 } /* namespace grid_map*/
static Pointcloud::Ptr createNoisyPlane(double *height, double *stdDevZ)
Pointcloud::Ptr createNoisyPlanePointcloud(unsigned int nPoints, double minXY, double maxXY, double meanZ, double stdDevZ, std::mt19937 *generator)
static Pointcloud::Ptr createNBlobsAboveEachOther(double *minZ, double *stdDevZ, int *nBlobs)
static Pointcloud::Ptr createNoisyPointcloudOfStepTerrain(double *stepLocation, double *zHigh, double *zLow, double *stdDev)
static Pointcloud::Ptr createNoisyDoublePlane(double *minZ, double *stdDevZ)
static Pointcloud::Ptr createPerfectPlane(double *height)
static Pointcloud::Ptr createVerticesOfASquare(double *x, double *y)
static Pointcloud::Ptr createBlobOfPoints(double *mean, double *stdDev)
Pointcloud::Ptr createStepTerrain(unsigned int nPoints, double minXY, double maxXY, double zHigh, double zLow, double stdDevZ, std::mt19937 *generator, double *center)
Pointcloud::Ptr concatenate(Pointcloud::Ptr cloud1, Pointcloud::Ptr cloud2)
Pointcloud::Ptr createNormallyDistributedBlobOfPoints(unsigned int nPoints, double mean, double stdDev, std::mt19937 *generator)
Pointcloud::Ptr createPerfectPlane(unsigned int nPoints, double minXY, double maxXY, double desiredHeight, std::mt19937 *generator)
pcl::PointCloud< Point > Pointcloud


grid_map_pcl
Author(s): Dominic Jud , Edo Jelavic
autogenerated on Tue Jun 1 2021 02:13:43