hpp-constraints  6.0.0
Definition of basic geometric constraints for motion planning
difference.hh
Go to the documentation of this file.
1 // Copyright (c) 2018, 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_FUNCTION_DIFFERENCE_HH
30 #define HPP_CONSTRAINTS_FUNCTION_DIFFERENCE_HH
31 
34 #include <hpp/constraints/fwd.hh>
35 
36 namespace hpp {
37 namespace constraints {
38 namespace function {
39 class Difference;
40 typedef shared_ptr<Difference> DifferencePtr_t;
41 
47  public:
48  typedef shared_ptr<Difference> Ptr_t;
57  Difference(const DifferentiableFunctionPtr_t& inner, const size_type& nArgs,
58  const size_type& nDers, const segment_t& lInArgs,
59  const segment_t& lInDers, const segment_t& rInArgs,
60  const segment_t& rInDers);
61 
62  protected:
64  inner_->value(l_, arg.segment(lsa_.first, lsa_.second));
65  inner_->value(r_, arg.segment(rsa_.first, rsa_.second));
66  y.vector() = l_ - r_;
67  }
68 
69  void impl_jacobian(matrixOut_t J, vectorIn_t arg) const {
70  inner_->jacobian(J.middleCols(lsd_.first, lsd_.second),
71  arg.segment(lsa_.first, lsa_.second));
72  inner_->jacobian(J.middleCols(rsd_.first, rsd_.second),
73  arg.segment(rsa_.first, rsa_.second));
74  J.middleCols(rsd_.first, rsd_.second) *= -1;
75  }
76 
77  bool isEqual(const DifferentiableFunction& other) const {
78  const Difference& castother = dynamic_cast<const Difference&>(other);
79  if (!DifferentiableFunction::isEqual(other)) return false;
80 
81  if (inner_ != castother.inner_) return false;
82  if (lsa_ != castother.lsa_) return false;
83  if (lsd_ != castother.lsd_) return false;
84  if (rsa_ != castother.rsa_) return false;
85  if (rsd_ != castother.rsd_) return false;
86 
87  return true;
88  }
89 
90  std::ostream& print(std::ostream& os) const;
91 
93  const segment_t lsa_, lsd_;
94  const segment_t rsa_, rsd_;
95 
96  mutable LiegroupElement l_, r_;
97 }; // class Difference
98 } // namespace function
99 } // namespace constraints
100 } // namespace hpp
101 
102 #endif // HPP_CONSTRAINTS_FUNCTION_DIFFERENCE_HH
Definition: differentiable-function.hh:63
virtual bool isEqual(const DifferentiableFunction &other) const
Definition: differentiable-function.hh:206
Definition: difference.hh:46
Difference(const DifferentiableFunctionPtr_t &inner, const size_type &nArgs, const size_type &nDers, const segment_t &lInArgs, const segment_t &lInDers, const segment_t &rInArgs, const segment_t &rInDers)
void impl_jacobian(matrixOut_t J, vectorIn_t arg) const
Definition: difference.hh:69
const segment_t rsa_
Definition: difference.hh:94
const segment_t rsd_
Definition: difference.hh:94
bool isEqual(const DifferentiableFunction &other) const
Definition: difference.hh:77
void impl_compute(LiegroupElementRef y, vectorIn_t arg) const
User implementation of function evaluation.
Definition: difference.hh:63
const segment_t lsd_
Definition: difference.hh:93
const segment_t lsa_
Definition: difference.hh:93
DifferentiableFunctionPtr_t inner_
Definition: difference.hh:92
LiegroupElement l_
Definition: difference.hh:96
std::ostream & print(std::ostream &os) const
Display object in a stream.
shared_ptr< Difference > Ptr_t
Definition: difference.hh:48
#define HPP_CONSTRAINTS_LOCAL
Definition: config.hh:92
shared_ptr< Difference > DifferencePtr_t
Definition: difference.hh:39
pinocchio::LiegroupElement LiegroupElement
Definition: fwd.hh:65
shared_ptr< DifferentiableFunction > DifferentiableFunctionPtr_t
Definition: fwd.hh:113
std::pair< size_type, size_type > segment_t
Definition: fwd.hh:83
pinocchio::size_type size_type
Definition: fwd.hh:47
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:60
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:58
pinocchio::LiegroupElementRef LiegroupElementRef
Definition: fwd.hh:66
Definition: active-set-differentiable-function.hh:36