5
5
#ifndef MPL_ELLIPSOID_UTIL_H
6
6
#define MPL_ELLIPSOID_UTIL_H
7
7
#include < mpl_external_planner/ellipsoid_planner/primitive_ellipsoid_utils.h>
8
-
9
8
#include < pcl/kdtree/kdtree_flann.h>
9
+
10
10
#include < boost/make_shared.hpp>
11
11
12
12
typedef pcl::PointXYZ PCLPoint;
@@ -18,97 +18,99 @@ typedef pcl::KdTreeFLANN<PCLPoint> KDTree;
18
18
*
19
19
*/
20
20
class EllipsoidUtil {
21
- public:
22
- /* *
23
- * @brief Simple constructor
24
- * @param r robot radius
25
- * @param h robot height, default as 0.1m
26
- */
27
- EllipsoidUtil (decimal_t r, decimal_t h = 0.1 ) { axe_ = Vec3f (r, r, h); }
28
-
29
- // /Set obstacles
30
- void setObstacles (const vec_Vec3f& obs) {
31
- obs_.clear ();
32
- for (const auto &it : obs) {
33
- if (bbox_.inside (it))
34
- obs_.push_back (it);
35
- }
21
+ public:
22
+ /* *
23
+ * @brief Simple constructor
24
+ * @param r robot radius
25
+ * @param h robot height, default as 0.1m
26
+ */
27
+ EllipsoidUtil (decimal_t r, decimal_t h = 0.1 ) { axe_ = Vec3f (r, r, h); }
36
28
37
- PCLPointCloud::Ptr cloud_ptr = boost::make_shared<PCLPointCloud>(toPCL (obs_));
38
- kdtree_.setInputCloud (cloud_ptr);
39
- }
40
- // /Set bounding box
41
- void setBoundingBox (const Vec3f& ori, const Vec3f& dim) {
42
- Polyhedron3D Vs;
43
- Vs.add (Hyperplane3D (ori + Vec3f (0 , dim (1 ) / 2 , dim (2 ) / 2 ), -Vec3f::UnitX ()));
44
- Vs.add (Hyperplane3D (ori + Vec3f (dim (0 ) / 2 , 0 , dim (2 ) / 2 ), -Vec3f::UnitY ()));
45
- Vs.add (Hyperplane3D (ori + Vec3f (dim (0 ) / 2 , dim (2 ) / 2 , 0 ), -Vec3f::UnitZ ()));
46
- Vs.add (Hyperplane3D (ori + dim - Vec3f (0 , dim (1 ) / 2 , dim (2 ) / 2 ), Vec3f::UnitX ()));
47
- Vs.add (Hyperplane3D (ori + dim - Vec3f (dim (0 ) / 2 , 0 , dim (2 ) / 2 ), Vec3f::UnitY ()));
48
- Vs.add (Hyperplane3D (ori + dim - Vec3f (dim (0 ) / 2 , dim (1 ) / 2 , 0 ), Vec3f::UnitZ ()));
49
- bbox_ = Vs;
29
+ // / Set obstacles
30
+ void setObstacles (const vec_Vec3f &obs) {
31
+ obs_.clear ();
32
+ for (const auto &it : obs) {
33
+ if (bbox_.inside (it)) obs_.push_back (it);
50
34
}
51
35
52
- // /Get polyhedra
53
- Polyhedron3D getBoundingBox () const {
54
- return bbox_;
55
- }
36
+ PCLPointCloud::Ptr cloud_ptr =
37
+ boost::make_shared<PCLPointCloud>(toPCL (obs_));
38
+ kdtree_.setInputCloud (cloud_ptr);
39
+ }
40
+ // / Set bounding box
41
+ void setBoundingBox (const Vec3f &ori, const Vec3f &dim) {
42
+ Polyhedron3D Vs;
43
+ Vs.add (
44
+ Hyperplane3D (ori + Vec3f (0 , dim (1 ) / 2 , dim (2 ) / 2 ), -Vec3f::UnitX ()));
45
+ Vs.add (
46
+ Hyperplane3D (ori + Vec3f (dim (0 ) / 2 , 0 , dim (2 ) / 2 ), -Vec3f::UnitY ()));
47
+ Vs.add (
48
+ Hyperplane3D (ori + Vec3f (dim (0 ) / 2 , dim (2 ) / 2 , 0 ), -Vec3f::UnitZ ()));
49
+ Vs.add (Hyperplane3D (ori + dim - Vec3f (0 , dim (1 ) / 2 , dim (2 ) / 2 ),
50
+ Vec3f::UnitX ()));
51
+ Vs.add (Hyperplane3D (ori + dim - Vec3f (dim (0 ) / 2 , 0 , dim (2 ) / 2 ),
52
+ Vec3f::UnitY ()));
53
+ Vs.add (Hyperplane3D (ori + dim - Vec3f (dim (0 ) / 2 , dim (1 ) / 2 , 0 ),
54
+ Vec3f::UnitZ ()));
55
+ bbox_ = Vs;
56
+ }
56
57
57
- // /Check if a primitive is inside the SFC from \f$t: 0 \rightarrow dt\f$
58
- bool isFree (const Primitive3D &pr) {
59
- vec_E<Waypoint3D> ps = pr.sample (2 );
60
- for (const auto &it : ps) {
61
- if (!bbox_.inside (it.pos ))
62
- return false ;
63
- }
64
- decimal_t max_v =
58
+ // / Get polyhedra
59
+ Polyhedron3D getBoundingBox () const { return bbox_; }
60
+
61
+ // / Check if a primitive is inside the SFC from \f$t: 0 \rightarrow dt\f$
62
+ bool isFree (const Primitive3D &pr) {
63
+ vec_E<Waypoint3D> ps = pr.sample (2 );
64
+ for (const auto &it : ps) {
65
+ if (!bbox_.inside (it.pos )) return false ;
66
+ }
67
+ decimal_t max_v =
65
68
std::max (std::max (pr.max_vel (0 ), pr.max_vel (1 )), pr.max_vel (2 ));
66
- int n = std::ceil (max_v * pr.t () / axe_ (0 ));
67
- auto Es = sample_ellipsoids (pr, axe_, n);
69
+ int n = std::ceil (max_v * pr.t () / axe_ (0 ));
70
+ auto Es = sample_ellipsoids (pr, axe_, n);
68
71
69
- for (const auto &E : Es) {
70
- float radius = axe_ (0 );
71
- pcl::PointXYZ searchPoint;
72
- std::vector<int > pointIdxRadiusSearch;
73
- std::vector<float > pointRadiusSquaredDistance;
72
+ for (const auto &E : Es) {
73
+ float radius = axe_ (0 );
74
+ pcl::PointXYZ searchPoint;
75
+ std::vector<int > pointIdxRadiusSearch;
76
+ std::vector<float > pointRadiusSquaredDistance;
74
77
75
- searchPoint.x = E.d ()(0 );
76
- searchPoint.y = E.d ()(1 );
77
- searchPoint.z = E.d ()(2 );
78
+ searchPoint.x = E.d ()(0 );
79
+ searchPoint.y = E.d ()(1 );
80
+ searchPoint.z = E.d ()(2 );
78
81
79
- if (kdtree_.radiusSearch (searchPoint, radius, pointIdxRadiusSearch,
80
- pointRadiusSquaredDistance) > 0 ) {
81
- for (size_t i = 0 ; i < pointIdxRadiusSearch.size (); ++i)
82
- if (E.inside (Vec3f (obs_[pointIdxRadiusSearch[i]])))
83
- return false ;
84
- }
82
+ if (kdtree_.radiusSearch (searchPoint, radius, pointIdxRadiusSearch,
83
+ pointRadiusSquaredDistance) > 0 ) {
84
+ for (size_t i = 0 ; i < pointIdxRadiusSearch.size (); ++i)
85
+ if (E.inside (Vec3f (obs_[pointIdxRadiusSearch[i]]))) return false ;
85
86
}
86
-
87
- return true ;
88
87
}
89
- // /Convert obstacle points into pcl point cloud
90
- PCLPointCloud toPCL (const vec_Vec3f &obs) {
91
- PCLPointCloud cloud;
92
- cloud.width = obs.size ();
93
- cloud.height = 1 ;
94
- cloud.points .resize (cloud.width * cloud.height );
95
- for (unsigned int i = 0 ; i < obs.size (); i++) {
96
- cloud.points [i].x = obs[i](0 );
97
- cloud.points [i].y = obs[i](1 );
98
- cloud.points [i].z = obs[i](2 );
99
- }
100
- return cloud;
88
+
89
+ return true ;
90
+ }
91
+ // / Convert obstacle points into pcl point cloud
92
+ PCLPointCloud toPCL (const vec_Vec3f &obs) {
93
+ PCLPointCloud cloud;
94
+ cloud.width = obs.size ();
95
+ cloud.height = 1 ;
96
+ cloud.points .resize (cloud.width * cloud.height );
97
+ for (unsigned int i = 0 ; i < obs.size (); i++) {
98
+ cloud.points [i].x = obs[i](0 );
99
+ cloud.points [i].y = obs[i](1 );
100
+ cloud.points [i].z = obs[i](2 );
101
101
}
102
- private:
103
- // /robot size: axe = (r, r, h)
104
- Vec3f axe_;
105
- // /obstacle points
106
- vec_Vec3f obs_;
107
- // /obstacles in kd tree form
108
- KDTree kdtree_;
109
- // /Bounding box
110
- Polyhedron3D bbox_;
102
+ return cloud;
103
+ }
104
+
105
+ private:
106
+ // / robot size: axe = (r, r, h)
107
+ Vec3f axe_;
108
+ // / obstacle points
109
+ vec_Vec3f obs_;
110
+ // / obstacles in kd tree form
111
+ KDTree kdtree_;
112
+ // / Bounding box
113
+ Polyhedron3D bbox_;
111
114
};
112
115
#endif
113
116
114
-
0 commit comments