Raytracing2DBasedSpaceSampler.cpp
Go to the documentation of this file.
1 
21 
22 namespace next_best_view {
23  Raytracing2DBasedSpaceSampler::Raytracing2DBasedSpaceSampler(const MapHelperPtr &mapUtilityPtr) : mMapHelperPtr(mapUtilityPtr) {
24  }
25 
27 
29  SamplePointCloudPtr sampledSpacePointCloudPtr = SamplePointCloudPtr(new SamplePointCloud());
30 
31  // Calculate maximum span
32  SimpleVector4 minVector, maxVector;
33  pcl::getMinMax3D(*this->getInputCloud(), minVector, maxVector);
34  // the surrounding cube.
35  SimpleVector3 spanCube = maxVector.block<3,1>(0,0) - minVector.block<3,1>(0,0);
36 
37  double maximumSpan = spanCube.lpNorm<Eigen::Infinity>() * contractor;
38 
39  uint32_t samples = this->getSamples();
40 
41  // add current viewport
42  SamplePoint currentSamplePoint(currentSpacePosition);
43  currentSamplePoint.x = currentSpacePosition[0];
44  currentSamplePoint.y = currentSpacePosition[1];
45  sampledSpacePointCloudPtr->push_back(currentSamplePoint);
46 
48  BOOST_FOREACH(SimpleQuaternion orientation, *spherePointsPtr) {
49  SimpleVector3 vector = maximumSpan * (orientation.toRotationMatrix() * SimpleVector3::UnitX());
50  vector[2] = 0.0;
51  vector += currentSpacePosition;
52 
53 
54  Ray ray;
55  if (!mMapHelperPtr->doRaytracing(currentSpacePosition, vector, ray)) {
56  SimpleVector3 obstacle(0,0,0);
57  for (Ray::reverse_iterator iter = ray.rbegin(); iter != ray.rend(); iter++) {
58  if (mMapHelperPtr->isOccupancyValueAcceptable(iter->occupancy)) {
59  mMapHelperPtr->mapToWorldCoordinates(iter->x, iter->y, obstacle);
60  break;
61  }
62  }
63  vector = obstacle;
64  vector[2] = currentSpacePosition[2];
65  }
66 
67  vector[2] = 0;
68  SamplePoint samplePoint(vector);
69  sampledSpacePointCloudPtr->push_back(samplePoint);
70  }
71 
72  return sampledSpacePointCloudPtr;
73  }
74 }
75 
76 
SamplePointCloudPtr getSampledSpacePointCloud(SimpleVector3 currentSpacePosition=SimpleVector3(), float contractor=1.0)
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
virtual ObjectPointCloudPtr & getInputCloud()
Definition: CommonClass.cpp:31
SamplePointCloud::Ptr SamplePointCloudPtr
Definition: typedef.hpp:93
pcl::PointCloud< SamplePoint > SamplePointCloud
Definition: typedef.hpp:92
Eigen::Matrix< Precision, 4, 1 > SimpleVector4
Definition: typedef.hpp:55
this namespace contains all generally usable classes.
std::vector< RayTracingIndex > Ray
Definition: MapHelper.hpp:62
Raytracing2DBasedSpaceSampler(const MapHelperPtr &mapHelperPtr)
constructor for CostmapBasedSpaceSampler object
virtual ~Raytracing2DBasedSpaceSampler()
destructor for CostmapBasedSpaceSampler object
Eigen::Quaternion< Precision > SimpleQuaternion
Definition: typedef.hpp:67
static SimpleQuaternionCollectionPtr getOrientationsOnUnitSphere(const int &numberOfPoints)
Definition: MathHelper.cpp:136


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