MapBasedHexagonSpaceSampler.cpp
Go to the documentation of this file.
1 
21 
22 namespace next_best_view {
23  MapBasedHexagonSpaceSampler::MapBasedHexagonSpaceSampler(const MapHelperPtr &mapUtilityPtr) : mMapHelperPtr(mapUtilityPtr), mHexagonRadius(1.0) {
25  }
26 
28 
31 
32  SamplePoint currentSamplePoint;
33  currentSamplePoint.x = currentSpacePosition[0];
34  currentSamplePoint.y = currentSpacePosition[1];
35  pointCloud->push_back(currentSamplePoint);
36 
37  mDebugHelperPtr->write(std::stringstream() << "MapBasedHexagonSpaceSampler::getSampledSpacePointCloud contractor " << contractor,
39 
40  double width = mMapHelperPtr->getMetricWidth();
41  double height = mMapHelperPtr->getMetricHeight();
42 
43  // calculate radius and horizontalSpacing of a hexagon
44  float radius = pow(contractor,.382) * mHexagonRadius;
45  float horizontalSpacing = radius * cos(M_PI / 6.0);
46  float interPointSpacing = radius;
47 
48  // calculate width/height of sampling depending on contractor
49  int spanX = ceil(contractor * .5 * width / horizontalSpacing);
50  int spanY = ceil(contractor * .25 * height / radius);
51  int span = std::max(spanX, spanY);
52 
53  // bounding box of all samples
54  xtop = 0;
55  ytop = 0;
56  xbot = width;
57  ybot = height;
58 
59  for (int x = -span; x < span; x++) {
60  for (int y = -span; y <= span; y++) {
61  /*
62  every second row we add horizontalSpacing/offsetting to our x Value so we get the following pattern:
63  x x x x
64  x x x
65  x x x x
66  while each "x" consists of 2 points, the most upper and the most lower point of a hexagon (this hexagon is rotated by 90° clockwise):
67  ______________
68  / | \
69  / | \
70  / |hs \ hs = horizontalSpacing ^= length of half width
71  / | \
72  / | \
73  lower Point / | \ most upper Point
74  \ /
75  \ /
76  \ /
77  \ /
78  \ /
79  \______________/
80 
81 
82  1 1 1 1 upper 1
83 
84 
85 
86  _/2\_ _/2\_ _/2\_ upper 2
87  1/ \1/ \1/ \1 lower 1
88  | | | |
89  | | | |
90  3\_ _/3\_ _/3\_ _/3 upper 3
91  \2/ \2/ \2/ lower 2
92  | | |
93  | | |
94  4\_ _/4\_ _/4
95  3 \3/ \3/ 3 lower 3
96 
97  1, 2, 3, 4 are the vertical sample points if we iterate over y with fixed x, the horizontal ones are iterated over x with a fixed y
98  */
99  double offsetting = std::abs(y) % 2 == 0 ? horizontalSpacing : 0.0;
100  // upperPoint
101  SimpleVector3 upperPoint(x * 2.0 * horizontalSpacing + offsetting, .5 * interPointSpacing + y * 1.5 * radius, 0);
102  upperPoint[0] += currentSpacePosition[0];
103  upperPoint[1] += currentSpacePosition[1];
104 
105  //lower Point
106  SimpleVector3 lowerPoint(x * 2.0 * horizontalSpacing + offsetting, -.5 * interPointSpacing + y * 1.5 * radius, 0);
107  lowerPoint[0] += currentSpacePosition[0];
108  lowerPoint[1] += currentSpacePosition[1];
109 
110  // get occupancy value of upper/lower point
111  int8_t upperOccupancyValue = mMapHelperPtr->getRaytracingMapOccupancyValue(upperPoint);
112  int8_t lowerOccupancyValue = mMapHelperPtr->getRaytracingMapOccupancyValue(lowerPoint);
113 
114  // update bounding box
115  if(lowerPoint[0] < xbot) xbot = lowerPoint[0];
116  if(lowerPoint[1] < ybot) ybot = lowerPoint[1];
117  if(upperPoint[0] > xtop) xtop = upperPoint[0];
118  if(upperPoint[1] > ytop) ytop = upperPoint[1];
119 
120  // check for occupancy value and add to pointcloud
121  if (mMapHelperPtr->isOccupancyValueAcceptable(upperOccupancyValue)) {
122  SamplePoint samplePoint(upperPoint);
123  pointCloud->push_back(samplePoint);
124  }
125 
126  if (mMapHelperPtr->isOccupancyValueAcceptable(lowerOccupancyValue)) {
127  SamplePoint samplePoint(lowerPoint);
128  pointCloud->push_back(samplePoint);
129  }
130  }
131  }
132  mDebugHelperPtr->write(std::stringstream() << "MapBasedHexagonSpaceSampler::size " << pointCloud->size(),
134  return pointCloud;
135  }
136 
138  mHexagonRadius = radius;
139  }
140 
142  return mHexagonRadius;
143  }
144 }
145 
146 
SamplePointCloudPtr getSampledSpacePointCloud(SimpleVector3 currentSpacePosition=SimpleVector3(), float contractor=1.0)
MapBasedHexagonSpaceSampler(const MapHelperPtr &mapHelperPtr)
constructor for CostmapBasedSpaceSampler object
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
TFSIMD_FORCE_INLINE const tfScalar & y() const
virtual ~MapBasedHexagonSpaceSampler()
destructor for CostmapBasedSpaceSampler object
SamplePointCloud::Ptr SamplePointCloudPtr
Definition: typedef.hpp:93
pcl::PointCloud< SamplePoint > SamplePointCloud
Definition: typedef.hpp:92
this namespace contains all generally usable classes.
static boost::shared_ptr< DebugHelper > getInstance()
Definition: DebugHelper.cpp:29
TFSIMD_FORCE_INLINE const tfScalar & x() const


asr_next_best_view
Author(s): Aumann Florian, Borella Jocelyn, Heller Florian, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Stroh Daniel, Trautmann Jeremias, Walter Milena, Wittenbeck Valerij
autogenerated on Thu Jan 9 2020 07:20:18