hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
hermite.hh
Go to the documentation of this file.
1 // Copyright (c) 2016 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_PATH_HERMITE_HH
19 # define HPP_CORE_PATH_HERMITE_HH
20 
21 # include <hpp/core/fwd.hh>
22 # include <hpp/core/config.hh>
23 # include <hpp/core/path/spline.hh>
24 
25 namespace hpp {
26  namespace core {
27  namespace path {
30 
31  class HPP_CORE_DLLAPI Hermite : public Spline<BernsteinBasis, 3>
32  {
33  public:
35 
37  virtual ~Hermite () {}
38 
39  static HermitePtr_t create (const DevicePtr_t& device,
40  ConfigurationIn_t init,
42  ConstraintSetPtr_t constraints)
43  {
44  Hermite* ptr = new Hermite (device, init, end, constraints);
45  HermitePtr_t shPtr (ptr);
46  ptr->init (shPtr);
47  return shPtr;
48  }
49 
52  static HermitePtr_t createCopy (const HermitePtr_t& path)
53  {
54  Hermite* ptr = new Hermite (*path);
55  HermitePtr_t shPtr (ptr);
56  ptr->init (shPtr);
57  return shPtr;
58  }
59 
63  static HermitePtr_t createCopy
64  (const HermitePtr_t& path, const ConstraintSetPtr_t& constraints)
65  {
66  Hermite* ptr = new Hermite (*path, constraints);
67  HermitePtr_t shPtr (ptr);
68  ptr->init (shPtr);
69  return shPtr;
70  }
71 
76  virtual PathPtr_t copy () const
77  {
78  return createCopy (weak_.lock ());
79  }
80 
85  virtual PathPtr_t copy (const ConstraintSetPtr_t& constraints) const
86  {
87  return createCopy (weak_.lock (), constraints);
88  }
89 
91  DevicePtr_t device () const;
92 
93  void v0 (const vectorIn_t& speed)
94  {
95  parameters_.row(1) = parameters_.row(0) + speed.transpose() / 3;
96  hermiteLength_ = -1;
97  }
98 
99  void v1 (const vectorIn_t& speed)
100  {
101  parameters_.row(2) = parameters_.row(3) - speed.transpose() / 3;
102  hermiteLength_ = -1;
103  }
104 
105  vector_t v0 () const
106  {
107  return 3 * (parameters_.row(1) - parameters_.row(0));
108  // TODO Should be equivalent to
109  // vector_t res (outputDerivativeSize());
110  // derivative (res, timeRange().first, 1);
111  // return res;
112  }
113 
114  vector_t v1 () const
115  {
116  return 3 * (parameters_.row(3) - parameters_.row(2));
117  }
118 
119  virtual Configuration_t initial () const
120  {
121  return init_;
122  }
123 
124  virtual Configuration_t end () const
125  {
126  return end_;
127  }
128 
129  const value_type& hermiteLength () const
130  {
131  return hermiteLength_;
132  }
133 
134  void computeHermiteLength ();
135 
136  vector_t velocity (const value_type& t) const;
137 
138  protected:
140  virtual std::ostream& print (std::ostream &os) const
141  {
142  os << "Hermite:" << std::endl;
143  Path::print (os);
144  os << "initial configuration: " << initial().transpose () << std::endl;
145  os << "final configuration: " << end().transpose () << std::endl;
146  return os;
147  }
148 
150  Hermite (const DevicePtr_t& robot, ConfigurationIn_t init,
151  ConfigurationIn_t end);
152 
154  Hermite (const DevicePtr_t& robot, ConfigurationIn_t init,
155  ConfigurationIn_t end, ConstraintSetPtr_t constraints);
156 
158  Hermite (const Hermite& path);
159 
161  Hermite (const Hermite& path,
162  const ConstraintSetPtr_t& constraints);
163 
164  void init (HermitePtr_t self);
165 
166  private:
167  // void computeVelocities ();
168  void projectVelocities (ConfigurationIn_t qi, ConfigurationIn_t qe);
169 
170  DevicePtr_t device_;
171  Configuration_t init_, end_;
172  value_type hermiteLength_;
173 
174  HermiteWkPtr_t weak_;
175  }; // class Hermite
177  } // namespace path
178  } // namespace core
179 } // namespace hpp
180 #endif // HPP_CORE_PATH_HERMITE_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
boost::shared_ptr< Hermite > HermitePtr_t
Definition: fwd.hh:226
vector_t v1() const
Definition: hermite.hh:114
void init(HermitePtr_t self)
const value_type & hermiteLength() const
Definition: hermite.hh:129
void v0(const vectorIn_t &speed)
Definition: hermite.hh:93
void v1(const vectorIn_t &speed)
Definition: hermite.hh:99
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
static HermitePtr_t create(const DevicePtr_t &device, ConfigurationIn_t init, ConfigurationIn_t end, ConstraintSetPtr_t constraints)
Definition: hermite.hh:39
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
virtual Configuration_t initial() const
Get the initial configuration.
Definition: hermite.hh:119
static HermitePtr_t createCopy(const HermitePtr_t &path)
Definition: hermite.hh:52
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:202
Spline< BernsteinBasis, 3 > parent_t
Definition: hermite.hh:34
pinocchio::vector_t vector_t
Definition: fwd.hh:201
pinocchio::value_type value_type
Definition: fwd.hh:157
virtual std::ostream & print(std::ostream &os) const
virtual ~Hermite()
Destructor.
Definition: hermite.hh:37
Definition: hermite.hh:31
Definition: fwd.hh:224
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: hermite.hh:140
Transform3f t
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: hermite.hh:85
virtual PathPtr_t copy() const
Definition: hermite.hh:76
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96
virtual Configuration_t end() const
Get the final configuration.
Definition: hermite.hh:124
vector_t v0() const
Definition: hermite.hh:105