hpp-manipulation  6.0.0
Classes for manipulation planning.
graph-path-validation.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_MANIPULATION_GRAPHPATHVALIDATOR_HH
30 #define HPP_MANIPULATION_GRAPHPATHVALIDATOR_HH
31 
32 #include <hpp/core/obstacle-user.hh>
33 #include <hpp/core/path-validation.hh>
35 #include <hpp/manipulation/fwd.hh>
37 
38 namespace hpp {
39 namespace manipulation {
40 using hpp::core::Path;
41 using hpp::core::PathPtr_t;
42 using hpp::core::PathValidation;
44 using hpp::core::PathVector;
45 using hpp::core::PathVectorPtr_t;
46 
49 
57  : public PathValidation,
58  public core::ObstacleUserInterface {
59  public:
71  virtual bool validate(const PathPtr_t& path, bool reverse,
72  PathPtr_t& validPart,
74 
76  void innerValidation(const PathValidationPtr_t& pathValidation) {
77  pathValidation_ = pathValidation;
78  }
79 
81  const PathValidationPtr_t& innerValidation() { return pathValidation_; }
82 
84  void constraintGraph(const graph::GraphPtr_t& graph) {
85  constraintGraph_ = graph;
86  }
87 
89  graph::GraphPtr_t constraintGraph() const { return constraintGraph_; }
90 
93  // checking.
94  // \param graph A pointer to the constraint graph.
96  const PathValidationPtr_t& pathValidation);
97 
98  template <typename T>
99  static GraphPathValidationPtr_t create(const pinocchio::DevicePtr_t& robot,
100  const value_type& stepSize);
101 
107  void addObstacle(const hpp::core::CollisionObjectConstPtr_t& object) {
108  shared_ptr<core::ObstacleUserInterface> oui =
109  HPP_DYNAMIC_PTR_CAST(core::ObstacleUserInterface, pathValidation_);
110  if (oui) oui->addObstacle(object);
111  }
112 
120  const JointPtr_t& joint,
121  const pinocchio::CollisionObjectConstPtr_t& obstacle) {
122  shared_ptr<core::ObstacleUserInterface> oui =
123  HPP_DYNAMIC_PTR_CAST(core::ObstacleUserInterface, pathValidation_);
124  if (oui) oui->removeObstacleFromJoint(joint, obstacle);
125  }
126 
134  const core::RelativeMotion::matrix_type& relMotion) {
135  shared_ptr<core::ObstacleUserInterface> oui =
136  HPP_DYNAMIC_PTR_CAST(core::ObstacleUserInterface, pathValidation_);
137  if (oui) oui->filterCollisionPairs(relMotion);
138  }
139 
146  void setSecurityMargins(const matrix_t& securityMargins) {
147  shared_ptr<core::ObstacleUserInterface> oui =
148  HPP_DYNAMIC_PTR_CAST(core::ObstacleUserInterface, pathValidation_);
149  if (oui) oui->setSecurityMargins(securityMargins);
150  }
151 
158  void setSecurityMarginBetweenBodies(const std::string& body_a,
159  const std::string& body_b,
160  const value_type& margin) {
161  shared_ptr<core::ObstacleUserInterface> oui =
162  HPP_DYNAMIC_PTR_CAST(core::ObstacleUserInterface, pathValidation_);
163  if (oui) oui->setSecurityMarginBetweenBodies(body_a, body_b, margin);
164  }
165 
166  protected:
168  GraphPathValidation(const PathValidationPtr_t& pathValidation);
169 
170  private:
172  bool impl_validate(const PathVectorPtr_t& path, bool reverse,
173  PathPtr_t& validPart, PathValidationReportPtr_t& report);
175  bool impl_validate(const PathPtr_t& path, bool reverse, PathPtr_t& validPart,
176  PathValidationReportPtr_t& report);
178  PathValidationPtr_t pathValidation_;
180  graph::GraphPtr_t constraintGraph_;
181 };
182 
183 template <typename T>
185  const pinocchio::DevicePtr_t& robot, const value_type& stepSize) {
186  return GraphPathValidation::create(T::create(robot, stepSize));
187 }
189 } // namespace manipulation
190 } // namespace hpp
191 
192 #endif // HPP_MANIPULATION_GRAPHPATHVALIDATOR_HH
Definition: graph-path-validation.hh:58
static GraphPathValidationPtr_t create(const PathValidationPtr_t &pathValidation)
void setSecurityMargins(const matrix_t &securityMargins)
Definition: graph-path-validation.hh:146
const PathValidationPtr_t & innerValidation()
Get the encapsulated path validator.
Definition: graph-path-validation.hh:81
void innerValidation(const PathValidationPtr_t &pathValidation)
Set the encapsulated path validator.
Definition: graph-path-validation.hh:76
GraphPathValidation(const PathValidationPtr_t &pathValidation)
Constructor.
void constraintGraph(const graph::GraphPtr_t &graph)
Set the graph of constraints.
Definition: graph-path-validation.hh:84
void setSecurityMarginBetweenBodies(const std::string &body_a, const std::string &body_b, const value_type &margin)
Definition: graph-path-validation.hh:158
virtual bool validate(const PathPtr_t &path, bool reverse, PathPtr_t &validPart, PathValidationReportPtr_t &report)
void addObstacle(const hpp::core::CollisionObjectConstPtr_t &object)
Definition: graph-path-validation.hh:107
void filterCollisionPairs(const core::RelativeMotion::matrix_type &relMotion)
Filter collision pairs.
Definition: graph-path-validation.hh:133
graph::GraphPtr_t constraintGraph() const
Get the graph of constraints.
Definition: graph-path-validation.hh:89
void removeObstacleFromJoint(const JointPtr_t &joint, const pinocchio::CollisionObjectConstPtr_t &obstacle)
Definition: graph-path-validation.hh:119
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:47
pinocchio::JointPtr_t JointPtr_t
Definition: fwd.hh:43
core::PathValidationPtr_t PathValidationPtr_t
Definition: fwd.hh:144
core::PathValidationReportPtr_t PathValidationReportPtr_t
Definition: fwd.hh:145
shared_ptr< GraphPathValidation > GraphPathValidationPtr_t
Definition: fwd.hh:110
core::value_type value_type
Definition: fwd.hh:89
shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:40
core::matrix_t matrix_t
Definition: fwd.hh:146
Definition: main.hh:1