hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
body-pair-collision.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014,2015,2016,2018 CNRS
3 // Authors: Florent Lamiraux, Joseph Mirabel, Diane Bury
4 //
5 // This file is part of hpp-core
6 // hpp-core 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-core 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-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CORE_CONTINUOUS_VALIDATION_BODY_PAIR_COLLISION_HH
20 # define HPP_CORE_CONTINUOUS_VALIDATION_BODY_PAIR_COLLISION_HH
21 
22 # include <boost/icl/continuous_interval.hpp>
23 # include <boost/icl/interval_set.hpp>
24 
25 # include <hpp/fcl/collision_data.h>
26 
29 
30 namespace hpp {
31  namespace core {
32  namespace continuousValidation {
52  {
53  public:
54  typedef std::pair<CollisionObjectConstPtr_t, CollisionObjectConstPtr_t> CollisionPair_t;
55  typedef std::vector<CollisionPair_t> CollisionPairs_t;
56 
68  bool validateConfiguration (const value_type& t, interval_t& interval,
69  ValidationReportPtr_t& report,
70  const pinocchio::DeviceData& data);
71 
72  // Get pairs checked for collision
73  const CollisionPairs_t& pairs () const
74  {
75  return m_->pairs;
76  }
77 
78  // Get pairs checked for collision
79  CollisionPairs_t& pairs ()
80  {
81  return m_->pairs;
82  }
83 
84  // Get maximal velocity
86  {
87  return maximalVelocity_;
88  }
89 
91  virtual size_type indexJointA () const { return -1; }
93  virtual size_type indexJointB () const { return -1; }
94 
95  virtual bool removeObjectTo_b (const CollisionObjectConstPtr_t& /*object*/) { return false;}
96  virtual void addCollisionPair (const CollisionObjectConstPtr_t& /*left*/,
97  const CollisionObjectConstPtr_t &/*right*/) {}
98 
99  virtual std::string name () const = 0;
100  virtual std::ostream& print (std::ostream& os) const = 0;
101 
104 
107  {
108  return collisionRequest_.security_margin;
109  }
112  {
113  collisionRequest_.security_margin = securityMargin;
114  }
116  protected:
121  IntervalValidation(tolerance), m_ (new Model),
122  collisionRequest_(fcl::DISTANCE_LOWER_BOUND, 1), maximalVelocity_(0)
123  {
124  }
125 
128  IntervalValidation(other), m_(other.m_),
129  collisionRequest_(other.collisionRequest_),
130  maximalVelocity_(other.maximalVelocity_)
131  {}
132 
133  virtual void setReport (ValidationReportPtr_t& report,
134  fcl::CollisionResult result,
135  CollisionPair_t _pair) const
136  {
138  (new CollisionValidationReport (_pair, result));
139  }
140 
141  private:
142  struct Model {
143  CollisionPairs_t pairs;
144  };
145  boost::shared_ptr<Model> m_;
146  fcl::CollisionRequest collisionRequest_;
147 
148  mutable vector_t Vb_;
149  value_type maximalVelocity_;
150 
153  virtual value_type computeMaximalVelocity(vector_t& Vb) const = 0;
154 
157  virtual void setupPath();
158 
164  value_type collisionFreeInterval(const value_type &t,
165  const value_type &distanceLowerBound,
166  value_type &maxVelocity) const;
167 
172  virtual bool computeDistanceLowerBound(value_type &distanceLowerBound,
173  ValidationReportPtr_t& report,
174  const pinocchio::DeviceData& data) const;
175 
176  }; // class BodyPairCollision
177 
178  inline std::ostream& operator<< (std::ostream& os,
179  const BodyPairCollision& pair)
180  {
181  return pair.print (os);
182  }
183  } // namespace continuousValidation
184  } // namespace core
185 } // namespace hpp
186 #endif // HPP_CORE_CONTINUOUS_VALIDATION_BODY_PAIR_COLLISION_HH
std::pair< CollisionObjectConstPtr_t, CollisionObjectConstPtr_t > CollisionPair_t
Definition: body-pair-collision.hh:54
boost::shared_ptr< ValidationReport > ValidationReportPtr_t
Definition: fwd.hh:206
void securityMargin(const value_type &securityMargin)
Set security margin.
Definition: body-pair-collision.hh:111
virtual std::ostream & print(std::ostream &os) const =0
value_type tolerance() const
Definition: interval-validation.hh:90
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
virtual void addCollisionPair(const CollisionObjectConstPtr_t &, const CollisionObjectConstPtr_t &)
Definition: body-pair-collision.hh:96
::pinocchio::ModelTpl< value_type, 0, JointCollectionTpl > Model
pinocchio::size_type size_type
Definition: fwd.hh:156
virtual void setReport(ValidationReportPtr_t &report, fcl::CollisionResult result, CollisionPair_t _pair) const
Definition: body-pair-collision.hh:133
value_type securityMargin() const
Get security margin.
Definition: body-pair-collision.hh:106
CollisionPairs_t & pairs()
Definition: body-pair-collision.hh:79
BodyPairCollision(value_type tolerance)
Definition: body-pair-collision.hh:120
Definition: interval-validation.hh:57
virtual size_type indexJointA() const
Returns joint A index or -1 if no such joint exists.
Definition: body-pair-collision.hh:91
bool validateConfiguration(const value_type &t, interval_t &interval, ValidationReportPtr_t &report, const pinocchio::DeviceData &data)
pinocchio::vector_t vector_t
Definition: fwd.hh:201
pinocchio::value_type value_type
Definition: fwd.hh:157
std::vector< CollisionPair_t > CollisionPairs_t
Definition: body-pair-collision.hh:55
Definition: collision-validation-report.hh:35
virtual bool removeObjectTo_b(const CollisionObjectConstPtr_t &)
Definition: body-pair-collision.hh:95
value_type maximalVelocity() const
Definition: body-pair-collision.hh:85
Definition: body-pair-collision.hh:51
DISTANCE_LOWER_BOUND
Transform3f t
BodyPairCollision(const BodyPairCollision &other)
Copy constructor.
Definition: body-pair-collision.hh:127
const CollisionPairs_t & pairs() const
Definition: body-pair-collision.hh:73
virtual size_type indexJointB() const
Returns joint B index or -1 if no such joint exists.
Definition: body-pair-collision.hh:93
pinocchio::CollisionObjectConstPtr_t CollisionObjectConstPtr_t
Definition: fwd.hh:90
boost::shared_ptr< CollisionValidationReport > CollisionValidationReportPtr_t
Definition: fwd.hh:86
std::ostream & operator<<(std::ostream &os, const BodyPairCollision &pair)
Definition: body-pair-collision.hh:178