DefaultViewportPoint.hpp
Go to the documentation of this file.
1 
20 #ifndef DEFAULTVIEWPORTPOINT_HPP_
21 #define DEFAULTVIEWPORTPOINT_HPP_
22 
23 #define PCL_NO_PRECOMPILE
24 #include "typedef.hpp"
25 #include <boost/foreach.hpp>
27 #include <geometry_msgs/Pose.h>
28 #include <string>
29 #include <pcl/point_types.h>
30 #include <pcl/impl/point_types.hpp>
31 #include <pcl/search/search.h>
32 #include <pcl/search/organized.h>
33 #include <pcl/search/impl/organized.hpp>
34 #include <pcl/search/kdtree.h>
35 #include <pcl/search/impl/kdtree.hpp>
36 #include <pcl/kdtree/kdtree_flann.h>
37 #include <pcl/kdtree/impl/kdtree_flann.hpp>
38 #include <pcl/segmentation/conditional_euclidean_clustering.h>
39 #include <pcl/segmentation/impl/conditional_euclidean_clustering.hpp>
40 #include <pcl/pcl_base.h>
41 #include <pcl/impl/pcl_base.hpp>
43 
44 namespace next_best_view {
45  namespace gm = geometry_msgs;
46 
56  /*
57  * Struct with functions.
58  * Stand for one datapoint of the pointcloud. Describe the position and orientation of one Point in the viewport.
59  */
61  public:
63 
64  union {
65  struct {
66  float qw;
67  float qx;
68  float qy;
69  float qz;
70  };
71  };
72 
74 
75  // point cloud containing the object points in the viewport
77  // the whole point cloud
79  // indices of the object points in the viewport
83  // old idx in the saved datastructure to reorder
84  unsigned int oldIdx;
85  public:
86  /*
87  * Constructor, with set the quaterion of the current orientation of the point.
88  */
89  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
90  DefaultViewportPoint(const gm::Pose &pose = gm::Pose()) : DefaultViewportPoint(SimpleVector3(pose.position.x, pose.position.y, pose.position.z)) {
91  child_indices = IndicesPtr(new Indices());
92 
93  qw = pose.orientation.w;
94  qx = pose.orientation.x;
95  qy = pose.orientation.y;
96  qz = pose.orientation.z;
97  }
98 
99  /*
100  * Sets the position paramerts, based on the current point position.
101  */
102  DefaultViewportPoint(const SimpleVector3 &vector, const SimpleQuaternion &orientation = SimpleQuaternion(1.0, 0.0, 0.0, 0.0)) : qw(orientation.w()), qx(orientation.x()), qy(orientation.y()), qz(orientation.z()) {
103  x = vector[0];
104  y = vector[1];
105  z = vector[2];
106 
107  mDebugHelperPtr = DebugHelper::getInstance();
108  }
109 
110  gm::Point getPoint() const {
111  gm::Point pt;
112  pt.x = x;
113  pt.y = y;
114  pt.z = z;
115  return pt;
116  }
117 
118  gm::Quaternion getQuaternion() const {
119  gm::Quaternion qt;
120  qt.w = qw;
121  qt.x = qx;
122  qt.y = qy;
123  qt.z = qz;
124  return qt;
125  }
126 
127  gm::Pose getPose() const {
128  gm::Pose pose;
129  pose.position = this->getPoint();
130  pose.orientation = this->getQuaternion();
131  return pose;
132  }
133 
135  return SimpleVector3(x, y, z);
136  }
137 
139  return SimpleQuaternion(qw, qx, qy, qz);
140  }
141 
142  void setOrientation(const SimpleQuaternion &orientation) {
143  qw = orientation.w();
144  qx = orientation.x();
145  qy = orientation.y();
146  qz = orientation.z();
147  }
148 
155  bool filterObjectPointCloudByTypes(const ObjectTypeSetPtr &objectTypeSetPtr, ViewportPoint &viewportPoint) {
156  IndicesPtr objectTypeIndicesPtr(new Indices());
157  BOOST_FOREACH(std::size_t index, *(this->child_indices)) {
158  ObjectPoint &point = point_cloud->at(index);
159 
160  // check if object type is in objectTypeSet
161  ObjectTypeSet::iterator iter = std::find(objectTypeSetPtr->begin(), objectTypeSetPtr->end(), point.type);
162  if (iter != objectTypeSetPtr->end()) {
163  objectTypeIndicesPtr->push_back(index);
164  }
165  }
166 
167  // we might want to define a copy constructor for this and call it
168  viewportPoint = ViewportPoint(this->getPosition(), this->getSimpleQuaternion());
169  viewportPoint.child_indices = objectTypeIndicesPtr;
170  viewportPoint.child_point_cloud = this->child_point_cloud;
171  viewportPoint.point_cloud = this->point_cloud;
172  viewportPoint.object_type_set = objectTypeSetPtr;
173  viewportPoint.oldIdx = this->oldIdx;
174 
175  if (objectTypeIndicesPtr->size() == 0) {
176  return false;
177  }
178 
179 
180  return true;
181  }
182  } EIGEN_ALIGN16;
184 
185  std::ostream& operator<<(std::ostream &strm, const next_best_view::DefaultViewportPoint &p);
186  std::ostream& operator<<(std::ostream &strm, const next_best_view::DefaultViewportPointPtr &p);
187 }
188 //Comment?
189 POINT_CLOUD_REGISTER_POINT_STRUCT (next_best_view::ViewportPoint,
190  (float, x, x)
191  (float, y, y)
192  (float, z, z)
193 )
194 
195 
196 #endif /* DEFAULTVIEWPORTPOINT_HPP_ */
void setOrientation(const SimpleQuaternion &orientation)
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DefaultViewportPoint(const gm::Pose &pose=gm::Pose())
TFSIMD_FORCE_INLINE const tfScalar & y() const
std::vector< int > Indices
Definition: typedef.hpp:117
SimpleQuaternion getSimpleQuaternion() const
DefaultViewportPoint(const SimpleVector3 &vector, const SimpleQuaternion &orientation=SimpleQuaternion(1.0, 0.0, 0.0, 0.0))
this namespace contains all generally usable classes.
static boost::shared_ptr< DebugHelper > getInstance()
Definition: DebugHelper.cpp:29
boost::shared_ptr< Indices > IndicesPtr
Definition: typedef.hpp:118
TFSIMD_FORCE_INLINE const tfScalar & x() const
bool filterObjectPointCloudByTypes(const ObjectTypeSetPtr &objectTypeSetPtr, ViewportPoint &viewportPoint)
filters all the objects in this viewport with one of the given types and puts them in a new viewport...
DefaultViewportPoint ViewportPoint
Definition: typedef.hpp:81
TFSIMD_FORCE_INLINE const tfScalar & z() const
TFSIMD_FORCE_INLINE const tfScalar & w() const
struct next_best_view::DefaultViewportPoint EIGEN_ALIGN16
ObjectPointCloud::Ptr ObjectPointCloudPtr
Definition: typedef.hpp:86
std::ostream & operator<<(std::ostream &strm, const next_best_view::DefaultViewportPoint &p)
Eigen::Quaternion< Precision > SimpleQuaternion
Definition: typedef.hpp:67
boost::shared_ptr< DefaultViewportPoint > DefaultViewportPointPtr


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