hpp-affordance: include/hpp/affordance/affordance-extraction.hh Source File

hpp-affordance 9.0.2 Implementation to Extract Whole-Body Affordances for Mutli-Contact Planning.

Loading...
Searching...
No Matches
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
30 struct TrianglePoints {
31 coal::Vec3s p1, p2, p3;
32};
34 struct Triangle {
35 Triangle() {}
37 Triangle(const TrianglePoints& inPoints) : points(inPoints) {
38 TriangleArea(points);
39 TriangleNormal(points);
40 }
43 void TriangleArea(TrianglePoints& tri) {
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 }
54 void TriangleNormal(TrianglePoints& tri) {
55 normal = (tri.p2 - tri.p1).cross(tri.p3 - tri.p1);
56 normal.normalize();
57 }
59 TrianglePoints points;
61 double area;
63 coal::Vec3s normal;
64};
65
66// helper function to extract mesh model of an coal::collisionObstacle
67 BVHModelOBConst_Ptr_t GetModel(FclConstCollisionObjectPtr_t object);
68
71
76 class Affordance {
77 public:
78 Affordance() {}
85 Affordance(const std::vector<unsigned int>& idxVec,
86 FclConstCollisionObjectPtr_t colObj)
87 : indices_(idxVec), colObj_(colObj) {}
90 std::vector<unsigned int> indices_;
93 FclConstCollisionObjectPtr_t colObj_;
94};
99 class SemanticsData {
100 public:
101 SemanticsData() {}
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
171 SemanticsDataPtr_t affordanceAnalysis(FclConstCollisionObjectPtr_t colObj,
172 const OperationBases_t& opVec);
173
178std::vector<CollisionObjects_t> getAffordanceObjects(
179 const SemanticsDataPtr_t& sData);
180
192std::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
hpp::affordance::Affordance
Definition affordance-extraction.hh:76
hpp::affordance::Affordance::colObj_
FclConstCollisionObjectPtr_t colObj_
Definition affordance-extraction.hh:93
hpp::affordance::Affordance::indices_
std::vector< unsigned int > indices_
Definition affordance-extraction.hh:90
hpp::affordance::Affordance::Affordance
Affordance()
Definition affordance-extraction.hh:78
hpp::affordance::Affordance::Affordance
Affordance(const std::vector< unsigned int > &idxVec, FclConstCollisionObjectPtr_t colObj)
Definition affordance-extraction.hh:85
hpp::affordance::SemanticsData
Definition affordance-extraction.hh:99
hpp::affordance::SemanticsData::affordances_
std::vector< std::vector< AffordancePtr_t > > affordances_
Definition affordance-extraction.hh:106
hpp::affordance::SemanticsData::SemanticsData
SemanticsData()
Definition affordance-extraction.hh:101
config.hh
fwd.hh
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::getAffordanceObjects
std::vector< CollisionObjects_t > getAffordanceObjects(const SemanticsDataPtr_t &sData)
hpp::affordance::affordanceAnalysis
SemanticsDataPtr_t affordanceAnalysis(FclConstCollisionObjectPtr_t colObj, const OperationBases_t &opVec)
hpp::affordance::getReducedAffordanceObjects
std::vector< CollisionObjects_t > getReducedAffordanceObjects(const SemanticsDataPtr_t &sData, std::vector< double > reduceSizes)
hpp::affordance::BVHModelOBConst_Ptr_t
coal::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::FclConstCollisionObjectPtr_t
const coal::CollisionObject * FclConstCollisionObjectPtr_t
Definition fwd.hh:54
hpp::affordance::SemanticsDataPtr_t
coal::shared_ptr< SemanticsData > SemanticsDataPtr_t
Definition fwd.hh:49
hpp::affordance::GetModel
BVHModelOBConst_Ptr_t GetModel(FclConstCollisionObjectPtr_t object)
hpp::affordance::OperationBasePtr_t
coal::shared_ptr< OperationBase > OperationBasePtr_t
Definition fwd.hh:47
hpp
Definition affordance-extraction.hh:25
hpp::affordance::TrianglePoints
Definition affordance-extraction.hh:30
hpp::affordance::TrianglePoints::p2
coal::Vec3s p2
Definition affordance-extraction.hh:31
hpp::affordance::TrianglePoints::p1
coal::Vec3s p1
Definition affordance-extraction.hh:31
hpp::affordance::TrianglePoints::p3
coal::Vec3s p3
Definition affordance-extraction.hh:31
hpp::affordance::Triangle
Helper class to save triangle information.
Definition affordance-extraction.hh:34
hpp::affordance::Triangle::TriangleNormal
void TriangleNormal(TrianglePoints &tri)
Definition affordance-extraction.hh:54
hpp::affordance::Triangle::area
double area
The area of a triangle.
Definition affordance-extraction.hh:61
hpp::affordance::Triangle::normal
coal::Vec3s normal
The normal vector of a triangle.
Definition affordance-extraction.hh:63
hpp::affordance::Triangle::Triangle
Triangle()
Definition affordance-extraction.hh:35
hpp::affordance::Triangle::Triangle
Triangle(const TrianglePoints &inPoints)
Constructor that takes in a TrianglePoints object.
Definition affordance-extraction.hh:37
hpp::affordance::Triangle::points
TrianglePoints points
The global position of a triangles vertices.
Definition affordance-extraction.hh:59
hpp::affordance::Triangle::TriangleArea
void TriangleArea(TrianglePoints &tri)
Definition affordance-extraction.hh:43