hpp-constraints: include/hpp/constraints/function/difference.hh Source File

hpp-constraints 9.0.2 Definition of basic geometric constraints for motion planning

Loading...
Searching...
No Matches
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
32#include <hpp/constraints/config.hh>
33#include <hpp/constraints/differentiable-function.hh>
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
45 class HPP_CONSTRAINTS_LOCAL Difference
46 : public constraints::DifferentiableFunction {
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:
63 void impl_compute(LiegroupElementRef y, vectorIn_t arg) const {
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
92 DifferentiableFunctionPtr_t inner_;
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
hpp::constraints::DifferentiableFunction
Definition differentiable-function.hh:63
hpp::constraints::function::Difference
Definition difference.hh:46
hpp::constraints::function::Difference::Difference
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)
hpp::constraints::function::Difference::impl_jacobian
void impl_jacobian(matrixOut_t J, vectorIn_t arg) const
Definition difference.hh:69
hpp::constraints::function::Difference::rsa_
const segment_t rsa_
Definition difference.hh:94
hpp::constraints::function::Difference::rsd_
const segment_t rsd_
Definition difference.hh:94
hpp::constraints::function::Difference::isEqual
bool isEqual(const DifferentiableFunction &other) const
Definition difference.hh:77
hpp::constraints::function::Difference::impl_compute
void impl_compute(LiegroupElementRef y, vectorIn_t arg) const
User implementation of function evaluation.
Definition difference.hh:63
hpp::constraints::function::Difference::print
std::ostream & print(std::ostream &os) const
Display object in a stream.
hpp::constraints::function::Difference::lsd_
const segment_t lsd_
Definition difference.hh:93
hpp::constraints::function::Difference::lsa_
const segment_t lsa_
Definition difference.hh:93
hpp::constraints::function::Difference::inner_
DifferentiableFunctionPtr_t inner_
Definition difference.hh:92
hpp::constraints::function::Difference::l_
LiegroupElement l_
Definition difference.hh:96
hpp::constraints::function::Difference::Ptr_t
shared_ptr< Difference > Ptr_t
Definition difference.hh:48
hpp::pinocchio::LiegroupElementBase
hpp::pinocchio::LiegroupElementBase::vector
const vector_type & vector() const
config.hh
HPP_CONSTRAINTS_LOCAL
#define HPP_CONSTRAINTS_LOCAL
Definition config.hh:92
differentiable-function.hh
fwd.hh
hpp::constraints::function::DifferencePtr_t
shared_ptr< Difference > DifferencePtr_t
Definition difference.hh:40
hpp::constraints::DifferentiableFunctionPtr_t
shared_ptr< DifferentiableFunction > DifferentiableFunctionPtr_t
Definition fwd.hh:115
hpp::constraints::segment_t
std::pair< size_type, size_type > segment_t
Definition fwd.hh:84
hpp::constraints::size_type
pinocchio::size_type size_type
Definition fwd.hh:48
hpp::constraints::vectorIn_t
pinocchio::vectorIn_t vectorIn_t
Definition fwd.hh:61
hpp::constraints::matrixOut_t
Eigen::Ref< matrix_t > matrixOut_t
Definition fwd.hh:59
hpp