hpp-affordance  4.12.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/fwd.hh>
23 #include <hpp/affordance/config.hh>
24 
25 namespace hpp {
26  namespace affordance {
27 
31  {
32  fcl::Vec3f p1, p2, p3;
33  };
35  struct Triangle
36  {
37  Triangle () {}
39  Triangle (const TrianglePoints& inPoints):
40  points (inPoints)
41  {
42  TriangleArea (points);
43  TriangleNormal (points);
44  }
48  {
49  double a, b, c;
50  a = (tri.p1 - tri.p2).norm();
51  b = (tri.p2 - tri.p3).norm();
52  c = (tri.p3 - tri.p1).norm();
53  double s = 0.5 * (a + b + c);
54  area = sqrt(s * (s-a) * (s-b) * (s-c));
55  }
60  {
61  normal = (tri.p2 - tri.p1).cross(tri.p3 - tri.p1);
62  normal.normalize();
63  }
67  double area;
69  fcl::Vec3f normal;
70  };
71 
72  // helper function to extract mesh model of an fcl::collisionObstacle
74 
77 
82  class Affordance
83  {
84  public:
85 
86  Affordance () {}
93  Affordance (const std::vector<unsigned int>& idxVec,
95  indices_(idxVec), colObj_(colObj) {}
98  std::vector<unsigned int> indices_;
102  };
108  {
109  public:
110 
116  std::vector<std::vector<AffordancePtr_t> > affordances_;
117  private:
118  SemanticsData(const SemanticsData&); // Prevent copy-construction
119  SemanticsData& operator=(const SemanticsData&);
120  };
121 
122 
152  void searchLinkedTriangles(std::vector<unsigned int>& listPotential,
153  const OperationBasePtr_t& refOp,
154  const std::vector<Triangle>& allTris,
155  std::vector<unsigned int>& searchableTris,
156  const unsigned int& refTriIdx, double& area);
157 
167  const OperationBases_t & opVec);
168 
173  std::vector<CollisionObjects_t> getAffordanceObjects
174  (const SemanticsDataPtr_t& sData);
175 
184  std::vector<CollisionObjects_t> getReducedAffordanceObjects
185  (const SemanticsDataPtr_t& sData, std::vector<double> reduceSizes);
186 
188  } // namespace affordance
189 } // namespace hpp
190 
191 #endif // HPP_AFFORDANCE_AFFORDANCE_EXTRACTION_HH
boost::shared_ptr< const BVHModelOB > BVHModelOBConst_Ptr_t
Definition: fwd.hh:41
boost::shared_ptr< SemanticsData > SemanticsDataPtr_t
Definition: fwd.hh:49
Definition: affordance-extraction.hh:107
SemanticsDataPtr_t affordanceAnalysis(FclConstCollisionObjectPtr_t colObj, const OperationBases_t &opVec)
Definition: affordance-extraction.hh:82
Triangle(const TrianglePoints &inPoints)
Constructor that takes in a TrianglePoints object.
Definition: affordance-extraction.hh:39
boost::shared_ptr< OperationBase > OperationBasePtr_t
Definition: fwd.hh:47
Definition: affordance-extraction.hh:25
TrianglePoints points
The global position of a triangles vertices.
Definition: affordance-extraction.hh:65
fcl::Vec3f p3
Definition: affordance-extraction.hh:32
std::vector< OperationBasePtr_t > OperationBases_t
Definition: fwd.hh:48
Triangle()
Definition: affordance-extraction.hh:37
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:59
fcl::Vec3f normal
The normal vector of a triangle.
Definition: affordance-extraction.hh:69
fcl::Vec3f p1
Definition: affordance-extraction.hh:32
std::vector< unsigned int > indices_
Definition: affordance-extraction.hh:98
std::vector< CollisionObjects_t > getAffordanceObjects(const SemanticsDataPtr_t &sData)
FclConstCollisionObjectPtr_t colObj_
Definition: affordance-extraction.hh:101
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:93
fcl::Vec3f p2
Definition: affordance-extraction.hh:32
SemanticsData()
Definition: affordance-extraction.hh:111
double area
The area of a triangle.
Definition: affordance-extraction.hh:67
void TriangleArea(TrianglePoints &tri)
Definition: affordance-extraction.hh:47
Helper class to save triangle information.
Definition: affordance-extraction.hh:35
Affordance()
Definition: affordance-extraction.hh:86
std::vector< std::vector< AffordancePtr_t > > affordances_
Definition: affordance-extraction.hh:116