hpp-rbprm  4.11.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 <Eigen/Dense>
7 #include <Eigen/src/Core/util/Macros.h>
8 #include <vector>
9 #include <pinocchio/fwd.hpp>
10 #include <hpp/fcl/collision_object.h>
11 #include <hpp/fcl/collision_data.h>
12 #include <hpp/fcl/BVH/BVH_model.h>
13 #include <hpp/pinocchio/collision-object.hh>
14 
15 namespace geom {
16 
17 typedef Eigen::Vector3d Point;
18 typedef std::vector<Point> T_Point;
19 typedef T_Point::const_iterator CIT_Point;
20 typedef T_Point::iterator IT_Point;
21 typedef const Eigen::Ref<const Point>& CPointRef;
22 
23 /*
24 typedef fcl::Vec3f Point;
25 typedef std::vector<Point> T_Point;
26 typedef T_Point::const_iterator CIT_Point;
27 typedef const Point& CPointRef;
28 
29 */
30 typedef std::vector<Eigen::Vector2d> T_Point2D;
31 typedef T_Point2D::const_iterator CIT_Point2D;
32 
36  hpp::fcl::Vec3f p1, p2, p3;
37 };
38 
39 const double EPSILON = 1e-5;
40 const double ZJUMP = 0.001; // value t for the floor in jump_easy_map
41 
42 typedef hpp::fcl::BVHModel<hpp::fcl::OBBRSS> BVHModelOB;
43 typedef boost::shared_ptr<const BVHModelOB> BVHModelOBConst_Ptr_t;
44 
45 BVHModelOBConst_Ptr_t GetModel(const hpp::pinocchio::CollisionObjectConstPtr_t object,
46  hpp::pinocchio::DeviceData& deviceData);
47 
48 void projectZ(IT_Point pointsBegin, IT_Point pointsEnd);
49 
57 
58 T_Point convexHull(CIT_Point pointsBegin, CIT_Point pointsEnd);
59 
67 bool containsHull(T_Point hull, CPointRef aPoint, const double epsilon = 10e-6);
68 
74 bool contains(T_Point points, CPointRef aPoint, const double epsilon = 10e-6);
75 
81 T_Point compute2DIntersection(CIT_Point aPointsBegin, CIT_Point aPointsEnd, CIT_Point bPointsBegin,
82  CIT_Point bPointsEnd);
83 
89 T_Point compute2DIntersection(T_Point subPolygon, T_Point clipPolygon);
90 
96 T_Point compute3DIntersection(T_Point subPolygon, T_Point clipPolygon);
97 
106 
107 double isLeft(CPointRef lA, CPointRef lB, CPointRef p2);
108 
111 CIT_Point leftMost(CIT_Point pointsBegin, CIT_Point pointsEnd);
112 
119 double area(CIT_Point pointsBegin, CIT_Point pointsEnd);
120 
129 Point centerPlanar(T_Point points, const hpp::fcl::Vec3f& n, double t);
130 
136 Point center(CIT_Point pointsBegin, CIT_Point pointsEnd);
137 
138 Point centroid(CIT_Point pointsBegin, CIT_Point pointsEnd, double& area);
139 
147 double distanceToPlane(const hpp::fcl::Vec3f& n, double t, const hpp::fcl::Vec3f& v);
148 
156 double distanceToPlane(CPointRef point, CPointRef Pn, CPointRef P0);
157 
165 Point projectPointOnPlane(CPointRef point, CPointRef Pn, CPointRef P0);
166 
176 double projectPointInsidePlan(T_Point plan, CPointRef point, CPointRef Pn, CPointRef P0, Eigen::Ref<Point> res);
177 
186 void computeTrianglePlaneDistance(hpp::fcl::Vec3f* tri_point, const hpp::fcl::Vec3f& n, double t,
187  hpp::fcl::Vec3f* distance, unsigned int* num_penetrating_points);
188 
197 bool insideTriangle(const hpp::fcl::Vec3f& a, const hpp::fcl::Vec3f& b, const hpp::fcl::Vec3f& c,
198  const hpp::fcl::Vec3f& p);
199 
206 void intersect3DGeoms(BVHModelOBConst_Ptr_t model1, BVHModelOBConst_Ptr_t model2, hpp::fcl::CollisionResult result);
207 
218 // T_Point intersectPolygonePlane(BVHModelOBConst_Ptr_t polygone, BVHModelOBConst_Ptr_t model2, fcl::Vec3f n , double
219 // t, fcl::CollisionResult result, bool useT = true, double epsilon = EPSILON);
220 
227 T_Point intersectTriangles(hpp::fcl::Vec3f* tri, hpp::fcl::Vec3f* tri2, std::ostringstream* ss = 0);
228 
238 T_Point intersectSegmentPlane(Point s0, Point s1, Eigen::Vector3d pn, Point p0);
239 
247 T_Point intersectPolygonePlane(BVHModelOBConst_Ptr_t polygone, BVHModelOBConst_Ptr_t plane, Eigen::Ref<Point> Pn);
248 
249 T_Point convertBVH(BVHModelOBConst_Ptr_t obj);
250 
257 void computePlanEquation(BVHModelOBConst_Ptr_t plane, Eigen::Ref<Point> Pn, Eigen::Ref<Point> P0);
258 
259 } // namespace geom
260 
261 #endif //_FILE_ALGORITHMS
const Eigen::Ref< const Point > & CPointRef
Definition: algorithms.h:21
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:30
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:40
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:17
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...
boost::shared_ptr< const BVHModelOB > BVHModelOBConst_Ptr_t
Definition: algorithms.h:43
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:36
std::vector< Point > T_Point
Definition: algorithms.h:18
Definition: algorithms.h:35
T_Point convexHull(CIT_Point pointsBegin, CIT_Point pointsEnd)
const double EPSILON
Definition: algorithms.h:39
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:36
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:20
Definition: algorithms.h:15
hpp::fcl::Vec3f p1
Definition: algorithms.h:36
T_Point2D::const_iterator CIT_Point2D
Definition: algorithms.h:31
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:19
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 ...
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:42