hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
spline-gradient-based-abstract.hh
Go to the documentation of this file.
1 // Copyright (c) 2017 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_OPTIMIZATION_SPLINE_GRADIENT_BASED_ABSTRACT_HH
19 # define HPP_CORE_PATH_OPTIMIZATION_SPLINE_GRADIENT_BASED_ABSTRACT_HH
20 
22 
24 
26 #include <hpp/core/path-vector.hh>
27 #include <hpp/core/path/spline.hh>
28 
31 
32 namespace hpp {
33  namespace core {
36  namespace pathOptimization {
38  template <int _PolynomeBasis, int _SplineOrder>
39  class HPP_CORE_DLLAPI SplineGradientBasedAbstract : public PathOptimizer
40  {
41  public:
42  enum {
43  PolynomeBasis = _PolynomeBasis,
44  SplineOrder = _SplineOrder
45  };
47  typedef typename Spline::Ptr_t SplinePtr_t;
48  typedef std::vector<SplinePtr_t> Splines_t;
49 
52 
54  static void copy (const Splines_t& in, Splines_t& out);
55 
59  void updateSplines (Splines_t& spline, const vector_t& param) const;
60 
64  void updateParameters (vector_t& param, const Splines_t& spline) const;
65 
67  static void interpolate (const Splines_t& a, const Splines_t& b,
68  const value_type& alpha, Splines_t& res);
69 
71 
72  protected:
73 
74  SplineGradientBasedAbstract (const Problem& problem);
75 
78 
80  static PathVectorPtr_t cleanInput (const PathVectorPtr_t& input);
81 
85 
95  void appendEquivalentSpline (const StraightPathPtr_t& path, Splines_t& splines) const;
96 
108  void appendEquivalentSpline (const InterpolatedPathPtr_t& path, Splines_t& splines) const;
109 
113  void appendEquivalentSpline (const PathVectorPtr_t& path, Splines_t& splines) const;
114 
116 
119 
122  std::vector<PathValidationPtr_t> validations_;
123 
127  virtual void initializePathValidation(const Splines_t& splines);
128 
129  typedef std::vector <std::pair <PathValidationReportPtr_t,
130  std::size_t> > Reports_t;
139  Reports_t validatePath (const Splines_t& splines,
140  std::vector<std::size_t>& reordering,
141  bool stopAtFirst,
142  bool reorder) const;
143 
145 
148 
150  typedef std::vector <bool> Bools_t;
151  typedef std::vector <size_type> Indices_t;
155  { activeParameters.addRow (0, rDof); }
156 
160  boost::shared_ptr<constraints::ExplicitConstraintSet> es;
161 
164  RowBlockIndices activeParameters;
165  };
166  typedef std::vector <SplineOptimizationData> SplineOptimizationDatas_t;
167 
168  void jointBoundConstraint (const Splines_t& splines, LinearConstraint& lc) const;
169 
171  std::size_t addBoundConstraints (const Indices_t& bci, const LinearConstraint& bc,
172  Bools_t& activeConstraint, LinearConstraint& constraint) const;
173 
175  Indices_t validateBounds (const Splines_t& splines, const LinearConstraint& lc) const;
176 
178  void addContinuityConstraints (const Splines_t& splines, const size_type maxOrder, const SplineOptimizationDatas_t& ess, LinearConstraint& continuity);
179 
181 
182 
183  PathVectorPtr_t buildPathVector (const Splines_t& splines) const;
184 
186 
187  private:
189  // void addCollisionConstraint (const std::size_t idxSpline,
190  // const SplinePtr_t& spline, const SplinePtr_t& nextSpline,
191  // const SolverPtr_t& solver,
192  // const CollisionPathValidationReportPtr_t& report,
193  // LinearConstraint& collision, CollisionFunctions& functions) const;
194  }; // SplineGradientBasedAbstract
195  } // namespace pathOptimization
196  } // namespace core
197 } // namespace hpp
198 
199 #endif // HPP_CORE_PATH_OPTIMIZATION_SPLINE_GRADIENT_BASED_ABSTRACT_HH
boost::shared_ptr< Spline > Ptr_t
Definition: spline.hh:100
std::vector< std::pair< PathValidationReportPtr_t, std::size_t > > Reports_t
Definition: spline-gradient-based-abstract.hh:130
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
DevicePtr_t robot_
Definition: spline-gradient-based-abstract.hh:185
Vec3f b
Definition: problem.hh:48
RowBlockIndices activeParameters
Definition: spline-gradient-based-abstract.hh:164
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:110
Eigen::RowBlockIndices RowBlockIndices
Definition: spline-gradient-based-abstract.hh:149
pinocchio::size_type size_type
Definition: fwd.hh:156
steeringMethod::Spline< PolynomeBasis, SplineOrder > SSM_t
Spline steering method.
Definition: spline-gradient-based-abstract.hh:83
std::vector< bool > Bools_t
Definition: spline-gradient-based-abstract.hh:150
SplineOptimizationData()
Definition: spline-gradient-based-abstract.hh:153
std::vector< SplinePtr_t > Splines_t
Definition: spline-gradient-based-abstract.hh:48
Common base for optimization-based path optimizer with splines.
Definition: spline-gradient-based-abstract.hh:39
Spline::Ptr_t SplinePtr_t
Definition: spline-gradient-based-abstract.hh:47
std::vector< PathValidationPtr_t > validations_
Definition: spline-gradient-based-abstract.hh:122
boost::shared_ptr< StraightPath > StraightPathPtr_t
Definition: fwd.hh:182
boost::shared_ptr< constraints::ExplicitConstraintSet > es
A copy of the explicit solver included in set.
Definition: spline-gradient-based-abstract.hh:160
boost::shared_ptr< InterpolatedPath > InterpolatedPathPtr_t
Definition: fwd.hh:192
path::Spline< PolynomeBasis, SplineOrder > Spline
Definition: spline-gradient-based-abstract.hh:46
std::vector< size_type > Indices_t
Definition: spline-gradient-based-abstract.hh:151
Definition: path-optimizer.hh:32
pinocchio::vector_t vector_t
Definition: fwd.hh:201
Vec3f a
pinocchio::value_type value_type
Definition: fwd.hh:157
boost::shared_ptr< Spline > Ptr_t
Definition: spline.hh:48
SSM_t::Ptr_t steeringMethod_
Definition: spline-gradient-based-abstract.hh:84
Definition: fwd.hh:224
boost::shared_ptr< PathVector > PathVectorPtr_t
Definition: fwd.hh:176
boost::shared_ptr< PathValidationReport > PathValidationReportPtr_t
Definition: fwd.hh:298
SplineOptimizationData(size_type rDof)
Definition: spline-gradient-based-abstract.hh:154
std::vector< SplineOptimizationData > SplineOptimizationDatas_t
Definition: spline-gradient-based-abstract.hh:166
A linear constraint .
Definition: linear-constraint.hh:28