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

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

Loading...
Searching...
No Matches
operations.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_OPERATIONS_HH
20#define HPP_AFFORDANCE_OPERATIONS_HH
21
22#include <coal/data_types.h>
23
24 namespace hpp {
25 namespace affordance {
28
32 class OperationBase {
33 public:
38 OperationBase()
39 : zWorld_(0, 0, 1),
40 margin_(0.3),
41 neighbouringTriangleMargin_(0.3),
42 minArea_(0.05),
43 affordance_("noAffordance") {}
53 explicit OperationBase(const double margin = 0.3,
54 const double nbTriMargin = 0.3,
55 const double minArea = 0.05,
56 const char* affordanceName = "noAffordance")
57 : zWorld_(0, 0, 1),
58 margin_(margin),
59 neighbouringTriangleMargin_(nbTriMargin),
60 minArea_(minArea),
61 affordance_(affordanceName) {}
66 virtual bool requirement(const coal::Vec3s& normal) = 0;
69 const coal::Vec3s zWorld_;
71 const double margin_;
74 const double neighbouringTriangleMargin_;
77 const double minArea_;
79 const char* affordance_;
80}; // class OperationBase
83 class SupportOperation : public OperationBase {
84 public:
93 explicit SupportOperation(const double margin = 0.3,
94 const double nbTriMargin = 0.3,
95 const double minArea = 0.05,
96 const char* affordanceName = "Support")
97 : OperationBase(margin, nbTriMargin, minArea, affordanceName) {}
101 bool requirement(const coal::Vec3s& normal) {
102 return ((zWorld_ - normal).squaredNorm() < margin_);
103 }
104}; // class SupportOperation
107 class LeanOperation : public OperationBase {
108 public:
117 explicit LeanOperation(const double margin = 0.3,
118 const double nbTriMargin = 0.3,
119 const double minArea = 0.05,
120 const char* affordanceName = "Lean")
121 : OperationBase(margin, nbTriMargin, minArea, affordanceName) {}
125 bool requirement(const coal::Vec3s& normal) {
126 return (fabs(normal.dot(zWorld_)) < margin_);
127 }
128}; // class LeanOperation
129
132 class Support45Operation : public OperationBase {
133 public:
142 explicit Support45Operation(const double margin = 0.3,
143 const double nbTriMargin = 0.3,
144 const double minArea = 0.05,
145 const char* affordanceName = "Support45")
146 : OperationBase(margin, 0.05, minArea, affordanceName),
147 axis45_(coal::Vec3s(1. / sqrt(2.), 0, 1. / sqrt(2.))) {}
148
149 private:
150 const coal::Vec3s axis45_;
151
156 bool requirement(const coal::Vec3s& normal) {
157 coal::Vec3s projectedNormal(0, 0, normal[2]); // project normal in x,z plan
158 projectedNormal[0] = sqrt(normal[0] * normal[0] + normal[1] * normal[1]);
159 return ((axis45_ - projectedNormal).squaredNorm() < margin_);
160 }
161}; // class LeanOperation
162
164} // namespace affordance
165} // namespace hpp
166
167#endif // HPP_AFFORDANCE_OPERATIONS_HH
hpp::affordance::LeanOperation
Definition operations.hh:107
hpp::affordance::LeanOperation::requirement
bool requirement(const coal::Vec3s &normal)
Definition operations.hh:125
hpp::affordance::LeanOperation::LeanOperation
LeanOperation(const double margin=0.3, const double nbTriMargin=0.3, const double minArea=0.05, const char *affordanceName="Lean")
Definition operations.hh:117
hpp::affordance::OperationBase
Definition operations.hh:32
hpp::affordance::OperationBase::minArea_
const double minArea_
Definition operations.hh:77
hpp::affordance::OperationBase::OperationBase
OperationBase(const double margin=0.3, const double nbTriMargin=0.3, const double minArea=0.05, const char *affordanceName="noAffordance")
Definition operations.hh:53
hpp::affordance::OperationBase::requirement
virtual bool requirement(const coal::Vec3s &normal)=0
hpp::affordance::OperationBase::OperationBase
OperationBase()
Definition operations.hh:38
hpp::affordance::OperationBase::zWorld_
const coal::Vec3s zWorld_
Definition operations.hh:69
hpp::affordance::OperationBase::margin_
const double margin_
The error margin within which the requirement function must be fullfilled.
Definition operations.hh:71
hpp::affordance::OperationBase::affordance_
const char * affordance_
Name of the affordance type for which te requirement exists.
Definition operations.hh:79
hpp::affordance::OperationBase::neighbouringTriangleMargin_
const double neighbouringTriangleMargin_
Definition operations.hh:74
hpp::affordance::Support45Operation
Definition operations.hh:132
hpp::affordance::Support45Operation::Support45Operation
Support45Operation(const double margin=0.3, const double nbTriMargin=0.3, const double minArea=0.05, const char *affordanceName="Support45")
Definition operations.hh:142
hpp::affordance::SupportOperation
Definition operations.hh:83
hpp::affordance::SupportOperation::requirement
bool requirement(const coal::Vec3s &normal)
Definition operations.hh:101
hpp::affordance::SupportOperation::SupportOperation
SupportOperation(const double margin=0.3, const double nbTriMargin=0.3, const double minArea=0.05, const char *affordanceName="Support")
Definition operations.hh:93
hpp
Definition affordance-extraction.hh:25