hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
interpolated-path.hh
Go to the documentation of this file.
1 // Copyright (c) 2015 CNRS
2 // Authors: Joseph Mirabel
3 //
4 // This file is part of hpp-core
5 // hpp-core is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-core is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-core If not, see
16 // <http://www.gnu.org/licenses/>.
17 
18 #ifndef HPP_CORE_INTERPOLATED_PATH_HH
19 # define HPP_CORE_INTERPOLATED_PATH_HH
20 
21 # include <hpp/core/fwd.hh>
22 # include <hpp/core/config.hh>
23 # include <hpp/core/path.hh>
24 
25 namespace hpp {
26  namespace core {
29 
41  class HPP_CORE_DLLAPI InterpolatedPath : public Path
42  {
43  public:
44  typedef std::pair <const value_type, Configuration_t> InterpolationPoint_t;
45  typedef std::map <value_type, Configuration_t, std::less <value_type>,
46  Eigen::aligned_allocator <InterpolationPoint_t> > InterpolationPoints_t;
47  typedef Path parent_t;
48 
50  virtual ~InterpolatedPath () {}
51 
56  static InterpolatedPathPtr_t create (const DevicePtr_t& device,
57  ConfigurationIn_t init,
59  interval_t timeRange)
60  {
61  InterpolatedPath* ptr = new InterpolatedPath (device, init, end,
62  timeRange);
63  InterpolatedPathPtr_t shPtr (ptr);
64  ptr->init (shPtr);
65  return shPtr;
66  }
67 
73  static InterpolatedPathPtr_t create (const DevicePtr_t& device,
74  ConfigurationIn_t init,
76  interval_t timeRange,
77  ConstraintSetPtr_t constraints)
78  {
79  InterpolatedPath* ptr = new InterpolatedPath (device, init, end,
80  timeRange, constraints);
81  InterpolatedPathPtr_t shPtr (ptr);
82  ptr->init (shPtr);
83  return shPtr;
84  }
85 
90  static InterpolatedPathPtr_t create (const DevicePtr_t& device,
91  ConfigurationIn_t init,
94  {
95  return create (device, init, end, interval_t(0, length));
96  }
97 
103  static InterpolatedPathPtr_t create (const DevicePtr_t& device,
104  ConfigurationIn_t init,
105  ConfigurationIn_t end,
107  ConstraintSetPtr_t constraints)
108  {
109  return create (device, init, end, interval_t(0, length), constraints);
110  }
111 
115  {
116  InterpolatedPath* ptr = new InterpolatedPath (*path);
117  InterpolatedPathPtr_t shPtr (ptr);
118  ptr->initCopy (shPtr);
119  return shPtr;
120  }
121 
127  static InterpolatedPathPtr_t create (const PathPtr_t& path,
128  const DevicePtr_t& device, const std::size_t& nbSamples);
129 
133  static InterpolatedPathPtr_t createCopy
134  (const InterpolatedPathPtr_t& path, const ConstraintSetPtr_t& constraints)
135  {
136  InterpolatedPath* ptr = new InterpolatedPath (*path, constraints);
137  InterpolatedPathPtr_t shPtr (ptr);
138  ptr->initCopy (shPtr);
139  return shPtr;
140  }
141 
146  virtual PathPtr_t copy () const
147  {
148  return createCopy (weak_.lock ());
149  }
150 
155  virtual PathPtr_t copy (const ConstraintSetPtr_t& constraints) const
156  {
157  return createCopy (weak_.lock (), constraints);
158  }
159 
160  virtual PathPtr_t reverse () const;
161 
163  DevicePtr_t device () const;
164 
166  void insert (const value_type& time, ConfigurationIn_t config)
167  {
168  configs_.insert (InterpolationPoint_t (time, config));
169  }
170 
173  {
174  return configs_.begin ()->second;
175  }
176 
179  {
180  return configs_.rbegin ()->second;
181  }
182 
183  const InterpolationPoints_t& interpolationPoints () const
184  {
185  return configs_;
186  }
187 
188  protected:
190  virtual std::ostream& print (std::ostream &os) const
191  {
192  os << "InterpolatedPath:" << std::endl;
193  Path::print (os);
194  os << "initial configuration: " << initial().transpose () << std::endl;
195  os << "final configuration: " << end().transpose () << std::endl;
196  return os;
197  }
198 
200  InterpolatedPath (const DevicePtr_t& robot, ConfigurationIn_t init,
201  ConfigurationIn_t end, interval_t timeRange);
202 
204  InterpolatedPath (const DevicePtr_t& robot, ConfigurationIn_t init,
205  ConfigurationIn_t end, interval_t timeRange,
206  ConstraintSetPtr_t constraints);
207 
209  InterpolatedPath (const PathPtr_t& path, const DevicePtr_t& device,
210  const std::size_t& nbSamples);
211 
213  InterpolatedPath (const InterpolatedPath& path);
214 
216  InterpolatedPath (const InterpolatedPath& path,
217  const ConstraintSetPtr_t& constraints);
218 
219  void init (InterpolatedPathPtr_t self);
220 
221  void initCopy (InterpolatedPathPtr_t self);
222 
223  virtual bool impl_compute (ConfigurationOut_t result,
224  value_type param) const;
226  virtual void impl_derivative (vectorOut_t result, const value_type& t,
227  size_type order) const;
228  virtual void impl_velocityBound (vectorOut_t result,
229  const value_type& t0, const value_type& t1) const;
230 
233  PathPtr_t impl_extract (const interval_t& subInterval) const;
234  private:
235  DevicePtr_t device_;
236  InterpolationPoints_t configs_;
237  InterpolatedPathWkPtr_t weak_;
238  }; // class InterpolatedPath
240  } // namespace core
241 } // namespace hpp
242 #endif // HPP_CORE_INTERPOLATED_PATH_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
virtual ~InterpolatedPath()
Destructor.
Definition: interpolated-path.hh:50
Configuration_t initial() const
Get the initial configuration.
Definition: interpolated-path.hh:172
std::pair< const value_type, Configuration_t > InterpolationPoint_t
Definition: interpolated-path.hh:44
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: interpolated-path.hh:190
void init(InterpolatedPathPtr_t self)
static InterpolatedPathPtr_t createCopy(const InterpolatedPathPtr_t &path)
Definition: interpolated-path.hh:114
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
Definition: interpolated-path.hh:41
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
pinocchio::size_type size_type
Definition: fwd.hh:156
void initCopy(InterpolatedPathPtr_t self)
static InterpolatedPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, interval_t timeRange)
Definition: interpolated-path.hh:56
Configuration_t end() const
Get the final configuration.
Definition: interpolated-path.hh:178
Path parent_t
Definition: interpolated-path.hh:47
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: interpolated-path.hh:155
static InterpolatedPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, interval_t timeRange, ConstraintSetPtr_t constraints)
Definition: interpolated-path.hh:73
virtual PathPtr_t copy() const
Definition: interpolated-path.hh:146
boost::shared_ptr< InterpolatedPath > InterpolatedPathPtr_t
Definition: fwd.hh:192
static InterpolatedPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length)
Definition: interpolated-path.hh:90
pinocchio::value_type value_type
Definition: fwd.hh:157
std::map< value_type, Configuration_t, std::less< value_type >, Eigen::aligned_allocator< InterpolationPoint_t > > InterpolationPoints_t
Definition: interpolated-path.hh:46
virtual std::ostream & print(std::ostream &os) const
Transform3f t
FCL_REAL length[2]
void insert(const value_type &time, ConfigurationIn_t config)
Insert interpolation point.
Definition: interpolated-path.hh:166
static InterpolatedPathPtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, value_type length, ConstraintSetPtr_t constraints)
Definition: interpolated-path.hh:103
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:203
Definition: path.hh:60
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96
const InterpolationPoints_t & interpolationPoints() const
Definition: interpolated-path.hh:183