hpp-rbprm  4.14.0
Implementation of RB-PRM planner using hpp.
algorithms.h
Go to the documentation of this file.
1 
2 #ifndef GEOM__ALGORITHMS
3 #define GEOM__ALGORITHMS
4 
5 #include <iostream>
6 #include <pinocchio/fwd.hpp>
7 #include <vector>
8 // include pinocchio first
9 
10 #include <Eigen/src/Core/util/Macros.h>
11 #include <hpp/fcl/BVH/BVH_model.h>
12 #include <hpp/fcl/collision_data.h>
13 #include <hpp/fcl/collision_object.h>
14 
15 #include <Eigen/Dense>
16 #include <hpp/pinocchio/collision-object.hh>
17 
18 namespace geom {
19 
20 typedef Eigen::Vector3d Point;
21 typedef std::vector<Point> T_Point;
22 typedef T_Point::const_iterator CIT_Point;
23 typedef T_Point::iterator IT_Point;
24 typedef const Eigen::Ref<const Point>& CPointRef;
25 
26 /*
27 typedef fcl::Vec3f Point;
28 typedef std::vector<Point> T_Point;
29 typedef T_Point::const_iterator CIT_Point;
30 typedef const Point& CPointRef;
31 
32 */
33 typedef std::vector<Eigen::Vector2d> T_Point2D;
34 typedef T_Point2D::const_iterator CIT_Point2D;
35 
39  hpp::fcl::Vec3f p1, p2, p3;
40 };
41 
42 const double EPSILON = 1e-5;
43 const double ZJUMP = 0.001; // value t for the floor in jump_easy_map
44 
45 typedef hpp::fcl::BVHModel<hpp::fcl::OBBRSS> BVHModelOB;
46 typedef hpp::fcl::shared_ptr<const BVHModelOB> BVHModelOBConst_Ptr_t;
47 
48 BVHModelOBConst_Ptr_t GetModel(
49  const hpp::pinocchio::CollisionObjectConstPtr_t object,
50  hpp::pinocchio::DeviceData& deviceData);
51 
52 void projectZ(IT_Point pointsBegin, IT_Point pointsEnd);
53 
63 
64 T_Point convexHull(CIT_Point pointsBegin, CIT_Point pointsEnd);
65 
75 bool containsHull(T_Point hull, CPointRef aPoint, const double epsilon = 10e-6);
76 
84 bool contains(T_Point points, CPointRef aPoint, const double epsilon = 10e-6);
85 
92 T_Point compute2DIntersection(CIT_Point aPointsBegin, CIT_Point aPointsEnd,
93  CIT_Point bPointsBegin, CIT_Point bPointsEnd);
94 
100 T_Point compute2DIntersection(T_Point subPolygon, T_Point clipPolygon);
101 
107 T_Point compute3DIntersection(T_Point subPolygon, T_Point clipPolygon);
108 
117 
118 double isLeft(CPointRef lA, CPointRef lB, CPointRef p2);
119 
122 CIT_Point leftMost(CIT_Point pointsBegin, CIT_Point pointsEnd);
123 
130 double area(CIT_Point pointsBegin, CIT_Point pointsEnd);
131 
140 Point centerPlanar(T_Point points, const hpp::fcl::Vec3f& n, double t);
141 
147 Point center(CIT_Point pointsBegin, CIT_Point pointsEnd);
148 
149 Point centroid(CIT_Point pointsBegin, CIT_Point pointsEnd, double& area);
150 
158 double distanceToPlane(const hpp::fcl::Vec3f& n, double t,
159  const hpp::fcl::Vec3f& v);
160 
169 double distanceToPlane(CPointRef point, CPointRef Pn, CPointRef P0);
170 
178 Point projectPointOnPlane(CPointRef point, CPointRef Pn, CPointRef P0);
179 
190 double projectPointInsidePlan(T_Point plan, CPointRef point, CPointRef Pn,
191  CPointRef P0, Eigen::Ref<Point> res);
192 
202 void computeTrianglePlaneDistance(hpp::fcl::Vec3f* tri_point,
203  const hpp::fcl::Vec3f& n, double t,
204  hpp::fcl::Vec3f* distance,
205  unsigned int* num_penetrating_points);
206 
215 bool insideTriangle(const hpp::fcl::Vec3f& a, const hpp::fcl::Vec3f& b,
216  const hpp::fcl::Vec3f& c, const hpp::fcl::Vec3f& p);
217 
224 void intersect3DGeoms(BVHModelOBConst_Ptr_t model1,
225  BVHModelOBConst_Ptr_t model2,
226  hpp::fcl::CollisionResult result);
227 
240 // T_Point intersectPolygonePlane(BVHModelOBConst_Ptr_t polygone,
241 // BVHModelOBConst_Ptr_t model2, fcl::Vec3f n , double t, fcl::CollisionResult
242 // result, bool useT = true, double epsilon = EPSILON);
243 
252 T_Point intersectTriangles(hpp::fcl::Vec3f* tri, hpp::fcl::Vec3f* tri2,
253  std::ostringstream* ss = 0);
254 
266 T_Point intersectSegmentPlane(Point s0, Point s1, Eigen::Vector3d pn, Point p0);
267 
277 T_Point intersectPolygonePlane(BVHModelOBConst_Ptr_t polygone,
278  BVHModelOBConst_Ptr_t plane,
279  Eigen::Ref<Point> Pn);
280 
281 T_Point convertBVH(BVHModelOBConst_Ptr_t obj);
282 
290 void computePlanEquation(BVHModelOBConst_Ptr_t plane, Eigen::Ref<Point> Pn,
291  Eigen::Ref<Point> P0);
292 
293 } // namespace geom
294 
295 #endif //_FILE_ALGORITHMS
const Eigen::Ref< const Point > & CPointRef
Definition: algorithms.h:24
bool containsHull(T_Point hull, CPointRef aPoint, const double epsilon=10e-6)
Point centerPlanar(T_Point points, const hpp::fcl::Vec3f &n, double t)
center compute the center of the polygon (planar)
std::vector< Eigen::Vector2d > T_Point2D
Definition: algorithms.h:33
double distanceToPlane(const hpp::fcl::Vec3f &n, double t, const hpp::fcl::Vec3f &v)
distanceToPlane Distance point plan
T_Point intersectTriangles(hpp::fcl::Vec3f *tri, hpp::fcl::Vec3f *tri2, std::ostringstream *ss=0)
intersectPolygonePlane Compute the intersection of a polygon and a plane The returned point belongs t...
const double ZJUMP
Definition: algorithms.h:43
T_Point compute3DIntersection(T_Point subPolygon, T_Point clipPolygon)
void projectZ(IT_Point pointsBegin, IT_Point pointsEnd)
BVHModelOBConst_Ptr_t GetModel(const hpp::pinocchio::CollisionObjectConstPtr_t object, hpp::pinocchio::DeviceData &deviceData)
void computeTrianglePlaneDistance(hpp::fcl::Vec3f *tri_point, const hpp::fcl::Vec3f &n, double t, hpp::fcl::Vec3f *distance, unsigned int *num_penetrating_points)
computeTrianglePlaneDistance compute distance between each vertice of the triangle and a plane ...
CIT_Point leftMost(CIT_Point pointsBegin, CIT_Point pointsEnd)
double area(CIT_Point pointsBegin, CIT_Point pointsEnd)
area compute the area of a 2D polygon
Eigen::Vector3d Point
Definition: algorithms.h:20
void computePlanEquation(BVHModelOBConst_Ptr_t plane, Eigen::Ref< Point > Pn, Eigen::Ref< Point > P0)
computePlanEquation compute a plan normal and a point in the plan from the first triangle of a BVHMod...
pinocchio::value_type distance(pinocchio::ConfigurationIn_t q1, pinocchio::ConfigurationIn_t q2)
Point projectPointOnPlane(CPointRef point, CPointRef Pn, CPointRef P0)
projectPointOnPlane othrogonal projection of a given point on the plan
T_Point compute2DIntersection(CIT_Point aPointsBegin, CIT_Point aPointsEnd, CIT_Point bPointsBegin, CIT_Point bPointsEnd)
hpp::fcl::Vec3f p3
Definition: algorithms.h:39
std::vector< Point > T_Point
Definition: algorithms.h:21
Definition: algorithms.h:38
T_Point convexHull(CIT_Point pointsBegin, CIT_Point pointsEnd)
const double EPSILON
Definition: algorithms.h:42
Point center(CIT_Point pointsBegin, CIT_Point pointsEnd)
center compute the center using average method
void intersect3DGeoms(BVHModelOBConst_Ptr_t model1, BVHModelOBConst_Ptr_t model2, hpp::fcl::CollisionResult result)
intersectGeoms compute intersection between 2 OBBRSS geometries
hpp::fcl::Vec3f p2
Definition: algorithms.h:39
bool insideTriangle(const hpp::fcl::Vec3f &a, const hpp::fcl::Vec3f &b, const hpp::fcl::Vec3f &c, const hpp::fcl::Vec3f &p)
insideTriangle check if a point is inside a triangle
T_Point::iterator IT_Point
Definition: algorithms.h:23
Definition: algorithms.h:18
hpp::fcl::Vec3f p1
Definition: algorithms.h:39
T_Point2D::const_iterator CIT_Point2D
Definition: algorithms.h:34
T_Point intersectPolygonePlane(BVHModelOBConst_Ptr_t polygone, BVHModelOBConst_Ptr_t plane, Eigen::Ref< Point > Pn)
intersectPolygonePlane compute the intersection between a polygone and an (infinite) plane ...
T_Point intersectSegmentPlane(Point s0, Point s1, Eigen::Vector3d pn, Point p0)
intersectSegmentPlane compute the intersection between a segment and a plane (infinite) ...
T_Point::const_iterator CIT_Point
Definition: algorithms.h:22
Point centroid(CIT_Point pointsBegin, CIT_Point pointsEnd, double &area)
double isLeft(CPointRef lA, CPointRef lB, CPointRef p2)
double projectPointInsidePlan(T_Point plan, CPointRef point, CPointRef Pn, CPointRef P0, Eigen::Ref< Point > res)
projectPointInsidePlan project a point inside on the given plan, inside the given convex hull ...
hpp::fcl::shared_ptr< const BVHModelOB > BVHModelOBConst_Ptr_t
Definition: algorithms.h:46
T_Point convertBVH(BVHModelOBConst_Ptr_t obj)
bool contains(T_Point points, CPointRef aPoint, const double epsilon=10e-6)
hpp::fcl::BVHModel< hpp::fcl::OBBRSS > BVHModelOB
Definition: algorithms.h:45