hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
subchain-path.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016 CNRS
3 // Authors: Joseph Mirabel
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_DOF_EXTRACTED_PATH_HH
20 # define HPP_CORE_DOF_EXTRACTED_PATH_HH
21 
22 # include <hpp/core/path.hh>
24 
25 namespace hpp {
26  namespace core {
29 
33  class SubchainPath : public Path
34  {
35  public:
36  typedef Path parent_t;
37 
38  virtual ~SubchainPath () {}
39 
41  virtual PathPtr_t copy () const
42  {
43  return createCopy (weak_.lock ());
44  }
45 
51  {
52  return createCopy (weak_.lock (), constraints);
53  }
54 
56  static SubchainPathPtr_t
57  create (const PathPtr_t& original, const segments_t& confIntervals,
58  const segments_t& velIntervals)
59  {
60  SubchainPath* ptr = new SubchainPath (original, confIntervals, velIntervals);
61  SubchainPathPtr_t shPtr (ptr);
62  ptr->init (shPtr);
63  return shPtr;
64  }
65 
66  static SubchainPathPtr_t
68  {
69  SubchainPath* ptr = new SubchainPath (*path);
70  SubchainPathPtr_t shPtr (ptr);
71  ptr->init (shPtr);
72  return shPtr;
73  }
74 
75  static SubchainPathPtr_t
78  {
79  SubchainPath* ptr = new SubchainPath (*path, constraints);
80  SubchainPathPtr_t shPtr (ptr);
81  ptr->init (shPtr);
82  return shPtr;
83  }
84 
85  virtual bool impl_compute (ConfigurationOut_t result,
86  value_type param) const
87  {
88  bool success = (*original_) (q_, param);
89  if (success) dofExtract (q_, result);
90  return success;
91  }
92 
94  inline Configuration_t initial () const
95  {
97  dofExtract(original_->initial(), q);
98  return q;
99  }
100 
102  inline Configuration_t end () const
103  {
105  dofExtract(original_->end(), q);
106  return q;
107  }
108 
110  {
111  qout = configView_.rview (qin);
112  }
113 
114  protected:
116  virtual std::ostream& print (std::ostream &os) const
117  {
118  os << "Dof Extracted Path:" << std::endl;
119  os << "intervals: " << configView_ << std::endl;
120  os << "original path:" << std::endl;
121  os << *original_ << std::endl;
122  return os;
123  }
124 
130  SubchainPath (const PathPtr_t& original,
131  const segments_t& confIntervals,
132  const segments_t& velIntervals) :
133  Path (original->timeRange(), Eigen::BlockIndex::cardinal(confIntervals),
134  Eigen::BlockIndex::cardinal(velIntervals)),
135  original_ (original), configView_ (confIntervals),
136  q_ (Configuration_t::Zero(original->outputSize()))
137  {}
138 
139  SubchainPath (const SubchainPath& path) : Path (path),
140  original_ (path.original_),
141  configView_ (path.configView_),
142  q_ (path.q_),
143  weak_ ()
144  {
145  }
146 
149  Path (path, constraints), original_ (path.original_),
150  configView_ (path.configView_), weak_ ()
151  {
152  }
153 
155  {
156  parent_t::init (self);
157  weak_ = self;
158  }
159 
160  private:
161  PathPtr_t original_;
162  Eigen::RowBlockIndices configView_, velView_;
163  mutable Configuration_t q_;
164  SubchainPathWkPtr_t weak_;
165  }; // SubchainPath
167  } // namespace core
168 } // namespace hpp
169 #endif // HPP_CORE_DOF_EXTRACTED_PATH_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
Configuration_t initial() const
Get the initial configuration.
Definition: subchain-path.hh:94
size_type outputSize() const
Get size of configuration space.
Definition: path.hh:197
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:97
virtual PathPtr_t copy(const ConstraintSetPtr_t &constraints) const
Definition: subchain-path.hh:50
Path parent_t
Definition: subchain-path.hh:36
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
static SubchainPathPtr_t createCopy(const SubchainPathPtr_t &path)
Definition: subchain-path.hh:67
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:98
SubchainPath(const SubchainPath &path)
Definition: subchain-path.hh:139
const ConstraintSetPtr_t & constraints() const
Get constraints the path is subject to.
Definition: path.hh:227
virtual PathPtr_t copy() const
Return a shared pointer to a copy of this.
Definition: subchain-path.hh:41
SubchainPath(const PathPtr_t &original, const segments_t &confIntervals, const segments_t &velIntervals)
Definition: subchain-path.hh:130
void init(SubchainPathPtr_t self)
Definition: subchain-path.hh:154
static SubchainPathPtr_t createCopy(const SubchainPathPtr_t &path, const ConstraintSetPtr_t &constraints)
Definition: subchain-path.hh:76
static SubchainPathPtr_t create(const PathPtr_t &original, const segments_t &confIntervals, const segments_t &velIntervals)
Definition: subchain-path.hh:57
boost::shared_ptr< SubchainPath > SubchainPathPtr_t
Definition: fwd.hh:129
void init(const PathWkPtr_t &self)
virtual bool impl_compute(ConfigurationOut_t result, value_type param) const
Function evaluation without applying constraints.
Definition: subchain-path.hh:85
const interval_t & timeRange() const
Get interval of definition.
Definition: path.hh:209
Configuration_t end() const
Get the final configuration.
Definition: subchain-path.hh:102
EIGEN_STRONG_INLINE View< const MatrixType >::type rview(const MatrixBase< MatrixType > &other) const
virtual ~SubchainPath()
Definition: subchain-path.hh:38
pinocchio::value_type value_type
Definition: fwd.hh:157
Definition: subchain-path.hh:33
constraints::segments_t segments_t
Definition: fwd.hh:162
virtual std::ostream & print(std::ostream &os) const
Print path in a stream.
Definition: subchain-path.hh:116
SubchainPath(const SubchainPath &path, const ConstraintSetPtr_t &constraints)
Definition: subchain-path.hh:147
void dofExtract(ConfigurationIn_t qin, ConfigurationOut_t qout) const
Definition: subchain-path.hh:109
Definition: path.hh:60
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96