hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
path-vector.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Florent Lamiraux
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_PATH_VECTOR_HH
20 # define HPP_CORE_PATH_VECTOR_HH
21 
22 # include <hpp/pinocchio/device.hh>
23 # include <hpp/core/fwd.hh>
24 # include <hpp/core/path.hh>
25 
26 namespace hpp {
27  namespace core {
30 
32  class HPP_CORE_DLLAPI PathVector : public Path
33  {
34  public:
35  typedef Path parent_t;
38 
40  static PathVectorPtr_t create (size_type outputSize,
41  size_type outputDerivativeSize)
42  {
43  PathVector* ptr = new PathVector (outputSize, outputDerivativeSize);
44  PathVectorPtr_t shPtr (ptr);
45  ptr->init (shPtr);
46  return shPtr;
47  }
48 
50  static PathVectorPtr_t createCopy (const PathVectorPtr_t& original)
51  {
52  PathVector* ptr = new PathVector (*original);
53  PathVectorPtr_t shPtr (ptr);
54  ptr->init (shPtr);
55  return shPtr;
56  }
57 
59  static PathVectorPtr_t createCopy (const PathVectorPtr_t& original,
60  const ConstraintSetPtr_t& constraints)
61  {
62  PathVector* ptr = new PathVector (*original, constraints);
63  PathVectorPtr_t shPtr (ptr);
64  ptr->init (shPtr);
65  return shPtr;
66  }
67 
69  virtual PathPtr_t copy () const
70  {
71  return createCopy (weak_.lock ());
72  }
73 
77  virtual PathPtr_t copy (const ConstraintSetPtr_t& constraints) const
78  {
79  return createCopy (weak_.lock (), constraints);
80  }
81 
83  virtual ~PathVector ()
84  {
85  }
87 
89  std::size_t numberPaths () const
90  {
91  return paths_.size ();
92  }
93 
100  PathPtr_t pathAtRank (std::size_t rank) const;
101 
107  std::size_t rankAtParam (const value_type& param, value_type& localParam) const;
108 
110  void appendPath (const PathPtr_t& path);
111 
115  void concatenate (const PathVector& path) HPP_CORE_DEPRECATED;
116 
121  void concatenate (const PathVectorPtr_t& path);
122 
124  virtual Configuration_t initial () const
125  {
126  return paths_.front ()->initial ();
127  }
128 
130  virtual Configuration_t end () const
131  {
132  return paths_.back()->end ();
133  }
134 
137  void flatten (PathVectorPtr_t flattenedPath) const;
138 
139  protected:
141  virtual std::ostream& print (std::ostream &os) const
142  {
143  os << "PathVector:" << std::endl;
144  Path::print (os);
145  for (Paths_t::const_iterator itPath = paths_.begin ();
146  itPath != paths_.end (); ++itPath) {
147  os << (**itPath) << std::endl;
148  }
149  return os;
150  }
152  PathVector (std::size_t outputSize, std::size_t outputDerivativeSize) :
153  parent_t (std::make_pair (0, 0), outputSize, outputDerivativeSize),
154  paths_ ()
155  {
156  }
158  PathVector (const PathVector& path) : parent_t (path),
159  paths_ ()
160  {
161  assert (timeRange() == path.timeRange());
162  for (Paths_t::const_iterator it = path.paths_.begin ();
163  it != path.paths_.end (); it++) {
164  paths_.push_back ((*it)->copy ());
165  }
166  }
167 
169  PathVector (const PathVector& path,
170  const ConstraintSetPtr_t& constraints) :
171  parent_t (path, constraints), paths_ ()
172  {
173  assert (timeRange() == path.timeRange());
174  for (Paths_t::const_iterator it = path.paths_.begin ();
175  it != path.paths_.end (); it++) {
176  paths_.push_back ((*it)->copy ());
177  }
178  }
179 
180  void init (PathVectorPtr_t self)
181  {
182  parent_t::init (self);
183  weak_ = self;
184  }
185  virtual bool impl_compute (ConfigurationOut_t result, value_type t) const;
187  virtual void impl_derivative (vectorOut_t result, const value_type& t,
188  size_type order) const;
191  virtual PathPtr_t impl_extract (const interval_t& subInterval) const;
192 
193  private:
194  Paths_t paths_;
195  PathVectorWkPtr_t weak_;
196  }; // class PathVector
198  } // namespace core
199 } // namespace hpp
200 #endif // HPP_CORE_PATH_VECTOR_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
PathVector(const PathVector &path)
Copy constructor.
Definition: path-vector.hh:158
static PathVectorPtr_t createCopy(const PathVectorPtr_t &original, const ConstraintSetPtr_t &constraints)
Create instance and return shared pointer.
Definition: path-vector.hh:59
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: path-vector.hh:77
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
std::pair< value_type, value_type > interval_t
Definition: fwd.hh:158
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: path-vector.hh:141
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
pinocchio::size_type size_type
Definition: fwd.hh:156
Path parent_t
Definition: path-vector.hh:35
std::vector< PathPtr_t > Paths_t
Definition: fwd.hh:195
PathVector(const PathVector &path, const ConstraintSetPtr_t &constraints)
Copy constructor with constraints.
Definition: path-vector.hh:169
std::size_t numberPaths() const
Get the number of sub paths.
Definition: path-vector.hh:89
virtual ~PathVector()
Destructor.
Definition: path-vector.hh:83
virtual Configuration_t initial() const
Get the initial configuration.
Definition: path-vector.hh:124
assert(d.lhs()._blocks()==d.rhs()._blocks())
virtual PathPtr_t copy() const
Return a shared pointer to a copy of this.
Definition: path-vector.hh:69
const interval_t & timeRange() const
Get interval of definition.
Definition: path.hh:209
pinocchio::value_type value_type
Definition: fwd.hh:157
Concatenation of several paths.
Definition: path-vector.hh:32
virtual std::ostream & print(std::ostream &os) const
static PathVectorPtr_t createCopy(const PathVectorPtr_t &original)
Create instance and return shared pointer.
Definition: path-vector.hh:50
boost::shared_ptr< PathVector > PathVectorPtr_t
Definition: fwd.hh:176
Transform3f t
constraints::Implicit NumericalConstraint HPP_CORE_DEPRECATED
Definition: fwd.hh:347
virtual Configuration_t end() const
Get the final configuration.
Definition: path-vector.hh:130
PathVector(std::size_t outputSize, std::size_t outputDerivativeSize)
Constructor.
Definition: path-vector.hh:152
pinocchio::vectorOut_t vectorOut_t
Definition: fwd.hh:203
void init(PathVectorPtr_t self)
Definition: path-vector.hh:180
Definition: path.hh:60
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96
static PathVectorPtr_t create(size_type outputSize, size_type outputDerivativeSize)
Create instance and return shared pointer.
Definition: path-vector.hh:40