hpp-constraints  6.0.0
Definition of basic geometric constraints for motion planning
active-set-differentiable-function.hh
Go to the documentation of this file.
1 // Copyright (c) 2017, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_CONSTRAINTS_ACTIVE_SET_DIFFERENTIABLE_FUNCTION_HH
30 #define HPP_CONSTRAINTS_ACTIVE_SET_DIFFERENTIABLE_FUNCTION_HH
31 
34 #include <hpp/constraints/fwd.hh>
35 
36 namespace hpp {
37 namespace constraints {
38 
48  : public DifferentiableFunction {
49  public:
55  segments_t intervals)
56  : DifferentiableFunction(f->inputSize(), f->inputDerivativeSize(),
57  f->outputSpace(), "ActiveSet_on_" + f->name()),
58  function_(f),
59  intervals_(intervals) {
60  context(f->context());
61  }
62 
64  const DifferentiableFunction& function() const { return *function_; }
65 
67  const DifferentiableFunctionPtr_t& functionPtr() const { return function_; }
68 
69  protected:
70  typedef std::vector<segments_t> intervalss_t;
71 
73  virtual void impl_compute(LiegroupElementRef result,
74  vectorIn_t argument) const {
75  function_->value(result, argument);
76  }
77 
78  virtual void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const {
79  function_->jacobian(jacobian, arg);
80  for (segments_t::const_iterator _int = intervals_.begin();
81  _int != intervals_.end(); ++_int)
82  jacobian.middleCols(_int->first, _int->second).setZero();
83  }
84 
85  bool isEqual(const DifferentiableFunction& other) const {
86  const ActiveSetDifferentiableFunction& castother =
87  dynamic_cast<const ActiveSetDifferentiableFunction&>(other);
88  if (!DifferentiableFunction::isEqual(other)) return false;
89 
90  if (function_ != castother.function_) return false;
91  if (intervals_ != castother.intervals_) return false;
92 
93  return true;
94  }
95 
98 }; // class ActiveSetDifferentiableFunction
99 } // namespace constraints
100 } // namespace hpp
101 
102 #endif // HPP_CONSTRAINTS_ACTIVE_SET_DIFFERENTIABLE_FUNCTION_HH
Definition: active-set-differentiable-function.hh:48
bool isEqual(const DifferentiableFunction &other) const
Definition: active-set-differentiable-function.hh:85
segments_t intervals_
Definition: active-set-differentiable-function.hh:97
const DifferentiableFunctionPtr_t & functionPtr() const
Get the original function.
Definition: active-set-differentiable-function.hh:67
virtual void impl_compute(LiegroupElementRef result, vectorIn_t argument) const
User implementation of function evaluation.
Definition: active-set-differentiable-function.hh:73
virtual void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const
Definition: active-set-differentiable-function.hh:78
DifferentiableFunctionPtr_t function_
Definition: active-set-differentiable-function.hh:96
ActiveSetDifferentiableFunction(const DifferentiableFunctionPtr_t &f, segments_t intervals)
Definition: active-set-differentiable-function.hh:54
std::vector< segments_t > intervalss_t
Definition: active-set-differentiable-function.hh:70
Definition: differentiable-function.hh:63
virtual bool isEqual(const DifferentiableFunction &other) const
Definition: differentiable-function.hh:206
#define HPP_CONSTRAINTS_DLLAPI
Definition: config.hh:88
shared_ptr< DifferentiableFunction > DifferentiableFunctionPtr_t
Definition: fwd.hh:113
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:60
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:58
std::vector< segment_t > segments_t
Definition: fwd.hh:84
pinocchio::LiegroupElementRef LiegroupElementRef
Definition: fwd.hh:66
Definition: active-set-differentiable-function.hh:36