hpp-affordance  5.0.0
Implementation to Extract Whole-Body Affordances for Mutli-Contact Planning.
affordance-extraction.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016 CNRS
3 // Authors: Anna Seppala
4 //
5 // This file is part of hpp-affordance
6 // hpp-affordance is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-affordance is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-affordance If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_AFFORDANCE_AFFORDANCE_EXTRACTION_HH
20 #define HPP_AFFORDANCE_AFFORDANCE_EXTRACTION_HH
21 
22 #include <hpp/affordance/config.hh>
23 #include <hpp/affordance/fwd.hh>
24 
25 namespace hpp {
26 namespace affordance {
27 
31  fcl::Vec3f p1, p2, p3;
32 };
34 struct Triangle {
35  Triangle() {}
37  Triangle(const TrianglePoints& inPoints) : points(inPoints) {
38  TriangleArea(points);
39  TriangleNormal(points);
40  }
44  double a, b, c;
45  a = (tri.p1 - tri.p2).norm();
46  b = (tri.p2 - tri.p3).norm();
47  c = (tri.p3 - tri.p1).norm();
48  double s = 0.5 * (a + b + c);
49  area = sqrt(s * (s - a) * (s - b) * (s - c));
50  }
55  normal = (tri.p2 - tri.p1).cross(tri.p3 - tri.p1);
56  normal.normalize();
57  }
61  double area;
63  fcl::Vec3f normal;
64 };
65 
66 // helper function to extract mesh model of an fcl::collisionObstacle
68 
71 
76 class Affordance {
77  public:
85  Affordance(const std::vector<unsigned int>& idxVec,
87  : indices_(idxVec), colObj_(colObj) {}
90  std::vector<unsigned int> indices_;
94 };
100  public:
106  std::vector<std::vector<AffordancePtr_t> > affordances_;
107 
108  private:
109  SemanticsData(const SemanticsData&); // Prevent copy-construction
110  SemanticsData& operator=(const SemanticsData&);
111 };
112 
154 void searchLinkedTriangles(std::vector<unsigned int>& listPotential,
155  const OperationBasePtr_t& refOp,
156  const std::vector<Triangle>& allTris,
157  std::vector<unsigned int>& searchableTris,
158  const unsigned int& refTriIdx, double& area);
159 
172  const OperationBases_t& opVec);
173 
178 std::vector<CollisionObjects_t> getAffordanceObjects(
179  const SemanticsDataPtr_t& sData);
180 
192 std::vector<CollisionObjects_t> getReducedAffordanceObjects(
193  const SemanticsDataPtr_t& sData, std::vector<double> reduceSizes);
194 
196 } // namespace affordance
197 } // namespace hpp
198 
199 #endif // HPP_AFFORDANCE_AFFORDANCE_EXTRACTION_HH
fcl::shared_ptr< const BVHModelOB > BVHModelOBConst_Ptr_t
Definition: fwd.hh:41
Definition: affordance-extraction.hh:99
SemanticsDataPtr_t affordanceAnalysis(FclConstCollisionObjectPtr_t colObj, const OperationBases_t &opVec)
Definition: affordance-extraction.hh:76
Triangle(const TrianglePoints &inPoints)
Constructor that takes in a TrianglePoints object.
Definition: affordance-extraction.hh:37
Definition: affordance-extraction.hh:25
TrianglePoints points
The global position of a triangles vertices.
Definition: affordance-extraction.hh:59
fcl::Vec3f p3
Definition: affordance-extraction.hh:31
fcl::shared_ptr< SemanticsData > SemanticsDataPtr_t
Definition: fwd.hh:49
std::vector< OperationBasePtr_t > OperationBases_t
Definition: fwd.hh:48
Triangle()
Definition: affordance-extraction.hh:35
std::vector< CollisionObjects_t > getReducedAffordanceObjects(const SemanticsDataPtr_t &sData, std::vector< double > reduceSizes)
Definition: affordance-extraction.hh:30
void TriangleNormal(TrianglePoints &tri)
Definition: affordance-extraction.hh:54
fcl::Vec3f normal
The normal vector of a triangle.
Definition: affordance-extraction.hh:63
fcl::Vec3f p1
Definition: affordance-extraction.hh:31
std::vector< unsigned int > indices_
Definition: affordance-extraction.hh:90
fcl::shared_ptr< OperationBase > OperationBasePtr_t
Definition: fwd.hh:47
std::vector< CollisionObjects_t > getAffordanceObjects(const SemanticsDataPtr_t &sData)
FclConstCollisionObjectPtr_t colObj_
Definition: affordance-extraction.hh:93
void searchLinkedTriangles(std::vector< unsigned int > &listPotential, const OperationBasePtr_t &refOp, const std::vector< Triangle > &allTris, std::vector< unsigned int > &searchableTris, const unsigned int &refTriIdx, double &area)
const fcl::CollisionObject * FclConstCollisionObjectPtr_t
Definition: fwd.hh:54
BVHModelOBConst_Ptr_t GetModel(FclConstCollisionObjectPtr_t object)
Affordance(const std::vector< unsigned int > &idxVec, FclConstCollisionObjectPtr_t colObj)
Definition: affordance-extraction.hh:85
fcl::Vec3f p2
Definition: affordance-extraction.hh:31
SemanticsData()
Definition: affordance-extraction.hh:101
double area
The area of a triangle.
Definition: affordance-extraction.hh:61
void TriangleArea(TrianglePoints &tri)
Definition: affordance-extraction.hh:43
Helper class to save triangle information.
Definition: affordance-extraction.hh:34
Affordance()
Definition: affordance-extraction.hh:78
std::vector< std::vector< AffordancePtr_t > > affordances_
Definition: affordance-extraction.hh:106