hpp-affordance  4.9.0
Implementation to Extract Whole-Body Affordances for Mutli-Contact Planning.
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 <hpp/fcl/data_types.h>
23 
24 namespace hpp {
25  namespace affordance {
28 
33  {
34  public:
40  minArea_(0.05), affordance_("noAffordance") {}
50  explicit OperationBase (const double margin = 0.3, const double nbTriMargin = 0.3,
51  const double minArea = 0.05,
52  const char* affordanceName = "noAffordance"):
53  zWorld_(0,0,1), margin_(margin),
54  neighbouringTriangleMargin_(nbTriMargin),
55  minArea_(minArea), affordance_(affordanceName) {}
60  virtual bool requirement (const fcl::Vec3f& normal) =0;
62  const fcl::Vec3f zWorld_;
64  const double margin_;
70  const double minArea_;
72  const char* affordance_;
73  }; // class OperationBase
77  {
78  public:
87  explicit SupportOperation (const double margin = 0.3, const double nbTriMargin = 0.3,
88  const double minArea = 0.05,
89  const char* affordanceName = "Support"):
90  OperationBase(margin, nbTriMargin, minArea, affordanceName) {}
94  bool requirement (const fcl::Vec3f& normal)
95  {
96  return ((zWorld_ - normal).squaredNorm() < margin_);
97  }
98  }; // class SupportOperation
102  {
103  public:
112  explicit LeanOperation (const double margin = 0.3, const double nbTriMargin = 0.3,
113  const double minArea = 0.05,
114  const char* affordanceName = "Lean"):
115  OperationBase(margin, nbTriMargin, minArea, affordanceName) {}
119  bool requirement (const fcl::Vec3f& normal)
120  {
121  return (fabs (normal.dot(zWorld_)) < margin_);
122  }
123  }; // class LeanOperation
124 
128  {
129  public:
138  explicit Support45Operation (const double margin = 0.3, const double nbTriMargin = 0.3,
139  const double minArea = 0.05,
140  const char* affordanceName = "Support45"):
141  OperationBase(margin, 0.05, minArea, affordanceName)
142  , axis45_ (fcl::Vec3f(1./sqrt(2.),0,1./sqrt(2.))) {}
143  private:
144  const fcl::Vec3f axis45_;
145 
150  bool requirement (const fcl::Vec3f& normal)
151  {
152  fcl::Vec3f projectedNormal(0,0,normal[2]); // project normal in x,z plan
153  projectedNormal[0] = sqrt(normal[0]*normal[0] + normal[1]*normal[1]);
154  return ((axis45_ - projectedNormal).squaredNorm() < margin_);
155  }
156  }; // class LeanOperation
157 
158 
160  } // namespace affordance
161 } // namespace hpp
162 
163 #endif // HPP_AFFORDANCE_OPERATIONS_HH
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:50
hpp::affordance::OperationBase::zWorld_
const fcl::Vec3f zWorld_
The orientation of the world z axis. Needed to find potential affordance objects.
Definition: operations.hh:62
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:112
hpp::affordance::OperationBase::minArea_
const double minArea_
Definition: operations.hh:70
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:87
hpp::affordance::LeanOperation
objects of type Lean. Inherits the OperationBase class.
Definition: operations.hh:101
hpp::affordance::OperationBase::margin_
const double margin_
The error margin within which the requirement function must be fullfilled.
Definition: operations.hh:64
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:138
hpp::affordance::OperationBase::OperationBase
OperationBase()
Definition: operations.hh:39
hpp
Definition: affordance-extraction.hh:25
hpp::affordance::LeanOperation::requirement
bool requirement(const fcl::Vec3f &normal)
Definition: operations.hh:119
hpp::affordance::OperationBase::affordance_
const char * affordance_
Name of the affordance type for which te requirement exists.
Definition: operations.hh:72
hpp::affordance::OperationBase
Definition: operations.hh:32
hpp::affordance::SupportOperation::requirement
bool requirement(const fcl::Vec3f &normal)
Definition: operations.hh:94
hpp::affordance::OperationBase::neighbouringTriangleMargin_
const double neighbouringTriangleMargin_
Definition: operations.hh:67
hpp::affordance::SupportOperation
Definition: operations.hh:76
hpp::affordance::OperationBase::requirement
virtual bool requirement(const fcl::Vec3f &normal)=0
hpp::affordance::Support45Operation
objects of type Lean. Inherits the OperationBase class.
Definition: operations.hh:127