hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
interval-validation.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_INTERVAL_VALIDATION_HH
20 #define HPP_CORE_CONTINUOUS_VALIDATION_INTERVAL_VALIDATION_HH
21 
22 #include <limits>
23 #include <iterator>
24 
25 #include <boost/icl/continuous_interval.hpp>
26 #include <boost/icl/interval_set.hpp>
27 
28 #include <hpp/fcl/collision_data.h>
29 #include <hpp/fcl/collision.h>
30 #include <hpp/pinocchio/body.hh>
31 #include <hpp/pinocchio/collision-object.hh>
32 #include <hpp/pinocchio/joint.hh>
33 #include <hpp/core/deprecated.hh>
34 #include <hpp/core/fwd.hh>
35 
36 namespace hpp {
37  namespace core {
38  namespace continuousValidation {
58  {
59  public:
68  virtual bool validateConfiguration(const value_type &t, interval_t &interval,
69  ValidationReportPtr_t &report,
70  const pinocchio::DeviceData& data) = 0;
71 
75  void path(const PathPtr_t &path, bool reverse)
76  {
77  path_ = path;
78  reverse_ = reverse;
79  valid_ = false;
81  setupPath();
82  }
83 
86  {
87  return path_;
88  }
89 
91  {
92  return tolerance_;
93  }
94 
95  virtual std::string name () const = 0;
96  virtual std::ostream& print (std::ostream& os) const = 0;
97  virtual IntervalValidationPtr_t copy () const = 0;
98 
99  protected:
100  typedef boost::icl::continuous_interval<value_type> continuous_interval;
101  typedef boost::icl::interval_set<value_type> interval_set;
104  bool reverse_;
105  bool refine_;
106  bool valid_;
107  interval_set validInterval_;
111  IntervalValidation (value_type tolerance) : tolerance_(tolerance),
112  reverse_(false), refine_(true)
113  {
114  if (tolerance < 0) {
115  throw std::runtime_error ("tolerance should be non-negative.");
116  }
117  }
118 
120  tolerance_(other.tolerance_), refine_(true)
121  {
122  if (tolerance_ < 0) {
123  throw std::runtime_error ("tolerance should be non-negative.");
124  }
125  }
126 
127  private:
128  virtual void setupPath() = 0;
129  }; // class IntervalValidation
130 
131  inline std::ostream &operator<<(std::ostream &os,
132  const IntervalValidation& b)
133  {
134  return b.print(os);
135  }
136  } // namespace continuousValidation
137  } // namespace core
138 } // namespace hpp
139 #endif // HPP_CORE_CONTINUOUS_VALIDATION_INTERVAL_VALIDATION_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
interval_set validInterval_
Definition: interval-validation.hh:107
boost::shared_ptr< ValidationReport > ValidationReportPtr_t
Definition: fwd.hh:206
value_type tolerance_
Definition: interval-validation.hh:103
value_type tolerance() const
Definition: interval-validation.hh:90
Vec3f b
boost::shared_ptr< IntervalValidation > IntervalValidationPtr_t
Definition: fwd.hh:242
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
virtual std::ostream & print(std::ostream &os) const =0
virtual IntervalValidationPtr_t copy() const =0
void path(const PathPtr_t &path, bool reverse)
Definition: interval-validation.hh:75
boost::icl::continuous_interval< value_type > continuous_interval
Definition: interval-validation.hh:100
PathPtr_t path_
Definition: interval-validation.hh:102
boost::shared_ptr< const Path > PathConstPtr_t
Definition: fwd.hh:171
PathConstPtr_t path() const
Get path.
Definition: interval-validation.hh:85
Definition: interval-validation.hh:57
bool reverse_
Definition: interval-validation.hh:104
pinocchio::value_type value_type
Definition: fwd.hh:157
IntervalValidation(value_type tolerance)
Definition: interval-validation.hh:111
boost::icl::interval_set< value_type > interval_set
Definition: interval-validation.hh:101
bool refine_
Definition: interval-validation.hh:105
IntervalValidation(const IntervalValidation &other)
Definition: interval-validation.hh:119
Transform3f t
virtual bool validateConfiguration(const value_type &t, interval_t &interval, ValidationReportPtr_t &report, const pinocchio::DeviceData &data)=0
bool valid_
Definition: interval-validation.hh:106
std::ostream & operator<<(std::ostream &os, const BodyPairCollision &pair)
Definition: body-pair-collision.hh:178