hpp-affordance  4.9.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  {
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
hpp::affordance::Triangle::TriangleNormal
void TriangleNormal(TrianglePoints &tri)
Definition: affordance-extraction.hh:59
hpp::affordance::Triangle::area
double area
The area of a triangle.
Definition: affordance-extraction.hh:67
hpp::affordance::Triangle::TriangleArea
void TriangleArea(TrianglePoints &tri)
Definition: affordance-extraction.hh:47
hpp::affordance::OperationBasePtr_t
boost::shared_ptr< OperationBase > OperationBasePtr_t
Definition: fwd.hh:47
hpp::affordance::SemanticsData::SemanticsData
SemanticsData()
Definition: affordance-extraction.hh:111
hpp::affordance::GetModel
BVHModelOBConst_Ptr_t GetModel(FclConstCollisionObjectPtr_t object)
hpp::affordance::SemanticsData::affordances_
std::vector< std::vector< AffordancePtr_t > > affordances_
Definition: affordance-extraction.hh:116
hpp::affordance::SemanticsDataPtr_t
boost::shared_ptr< SemanticsData > SemanticsDataPtr_t
Definition: fwd.hh:49
hpp::affordance::Triangle::Triangle
Triangle(const TrianglePoints &inPoints)
Constructor that takes in a TrianglePoints object.
Definition: affordance-extraction.hh:39
hpp::affordance::TrianglePoints::p2
fcl::Vec3f p2
Definition: affordance-extraction.hh:32
fwd.hh
hpp::affordance::Triangle
Helper class to save triangle information.
Definition: affordance-extraction.hh:35
hpp::affordance::Affordance::Affordance
Affordance()
Definition: affordance-extraction.hh:86
hpp::affordance::FclConstCollisionObjectPtr_t
const typedef fcl::CollisionObject * FclConstCollisionObjectPtr_t
Definition: fwd.hh:54
hpp::affordance::Affordance::indices_
std::vector< unsigned int > indices_
Definition: affordance-extraction.hh:98
hpp::affordance::Affordance
Definition: affordance-extraction.hh:82
hpp::affordance::searchLinkedTriangles
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)
hpp::affordance::Triangle::Triangle
Triangle()
Definition: affordance-extraction.hh:37
hpp::affordance::Affordance::Affordance
Affordance(const std::vector< unsigned int > &idxVec, FclConstCollisionObjectPtr_t colObj)
Definition: affordance-extraction.hh:93
hpp
Definition: affordance-extraction.hh:25
hpp::affordance::getReducedAffordanceObjects
std::vector< CollisionObjects_t > getReducedAffordanceObjects(const SemanticsDataPtr_t &sData, std::vector< double > reduceSizes)
hpp::affordance::affordanceAnalysis
SemanticsDataPtr_t affordanceAnalysis(FclConstCollisionObjectPtr_t colObj, const OperationBases_t &opVec)
hpp::affordance::Affordance::colObj_
FclConstCollisionObjectPtr_t colObj_
Definition: affordance-extraction.hh:101
hpp::affordance::Triangle::points
TrianglePoints points
The global position of a triangles vertices.
Definition: affordance-extraction.hh:65
hpp::affordance::TrianglePoints
Definition: affordance-extraction.hh:30
hpp::affordance::BVHModelOBConst_Ptr_t
boost::shared_ptr< const BVHModelOB > BVHModelOBConst_Ptr_t
Definition: fwd.hh:41
hpp::affordance::OperationBases_t
std::vector< OperationBasePtr_t > OperationBases_t
Definition: fwd.hh:48
hpp::affordance::SemanticsData
Definition: affordance-extraction.hh:107
hpp::affordance::Triangle::normal
fcl::Vec3f normal
The normal vector of a triangle.
Definition: affordance-extraction.hh:69
hpp::affordance::getAffordanceObjects
std::vector< CollisionObjects_t > getAffordanceObjects(const SemanticsDataPtr_t &sData)
hpp::affordance::TrianglePoints::p3
fcl::Vec3f p3
Definition: affordance-extraction.hh:32
config.hh
hpp::affordance::TrianglePoints::p1
fcl::Vec3f p1
Definition: affordance-extraction.hh:32