Line |
Branch |
Exec |
Source |
1 |
|
|
// Copyright (c) 2017 - 2018, CNRS |
2 |
|
|
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr), Florent Lamiraux |
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_OF_PARAMETER_SUBSET_HH |
30 |
|
|
#define HPP_CONSTRAINTS_FUNCTION_OF_PARAMETER_SUBSET_HH |
31 |
|
|
|
32 |
|
|
#include <hpp/constraints/differentiable-function.hh> |
33 |
|
|
|
34 |
|
|
namespace hpp { |
35 |
|
|
namespace constraints { |
36 |
|
|
namespace function { |
37 |
|
|
/// Function depending on a subset of parameters |
38 |
|
|
/// |
39 |
|
|
/// This class implements a function over a configuration space, |
40 |
|
|
/// the output values of which only depend on a convex subset of |
41 |
|
|
/// parameters. |
42 |
|
|
/// |
43 |
|
|
/// \f{equation} |
44 |
|
|
/// f (q_1,\cdots,q_n) = g (q_{i},\cdots,q_{i+p-1}) |
45 |
|
|
/// \f} |
46 |
|
|
/// where |
47 |
|
|
/// \li \f$n\f$ is the dimension of the input configuration space, |
48 |
|
|
/// \li \f$[i,i+p-1]\f$ is an interval included in \f$[1,n]\f$, |
49 |
|
|
/// \li \f$g\f$ is a differentiable mapping from \f$\mathbf{R}^p\f$ |
50 |
|
|
/// to the output space of \f$f\f$. |
51 |
|
|
class HPP_CONSTRAINTS_DLLAPI OfParameterSubset : public DifferentiableFunction { |
52 |
|
|
public: |
53 |
|
|
/// Create instance and return shared pointer |
54 |
|
|
/// \param g the mapping from the subset of parameters to the |
55 |
|
|
/// output space, |
56 |
|
|
/// \param nArgs dimension \f$n\f$ of the input space representation, |
57 |
|
|
/// \param nDers dimension of the input tangent space, |
58 |
|
|
/// \param inArgs interval \f$[i,i+p-1]\f$ of configuration indices, |
59 |
|
|
/// \param inDers interval of velocity indices. |
60 |
|
|
static OfParameterSubsetPtr_t create(const DifferentiableFunctionPtr_t& g, |
61 |
|
|
const size_type& nArgs, |
62 |
|
|
const size_type& nDers, |
63 |
|
|
const segment_t& inArgs, |
64 |
|
|
const segment_t& inDers) { |
65 |
|
|
return OfParameterSubsetPtr_t( |
66 |
|
|
new OfParameterSubset(g, nArgs, nDers, inArgs, inDers)); |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
protected: |
70 |
|
|
/// Constructor |
71 |
|
|
/// \param g the mapping from the subset of parameters to the |
72 |
|
|
/// output space, |
73 |
|
|
/// \param nArgs dimension \f$n\f$ of the input space representation, |
74 |
|
|
/// \param nDers dimension of the input tangent space, |
75 |
|
|
/// \param inArgs interval \f$[i,i+p-1]\f$ of configuration indices, |
76 |
|
|
/// \param inDers interval of velocity indices. |
77 |
|
|
OfParameterSubset(const DifferentiableFunctionPtr_t& g, |
78 |
|
|
const size_type& nArgs, const size_type& nDers, |
79 |
|
|
const segment_t& inArgs, const segment_t& inDers); |
80 |
|
|
|
81 |
|
✗ |
void impl_compute(LiegroupElementRef y, vectorIn_t arg) const { |
82 |
|
✗ |
g_->value(y, arg.segment(sa_.first, sa_.second)); |
83 |
|
|
} |
84 |
|
|
|
85 |
|
✗ |
void impl_jacobian(matrixOut_t J, vectorIn_t arg) const { |
86 |
|
✗ |
g_->jacobian(J.middleCols(sd_.first, sd_.second), |
87 |
|
✗ |
arg.segment(sa_.first, sa_.second)); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
✗ |
bool isEqual(const DifferentiableFunction& other) const { |
91 |
|
|
const OfParameterSubset& castother = |
92 |
|
✗ |
dynamic_cast<const OfParameterSubset&>(other); |
93 |
|
✗ |
if (!DifferentiableFunction::isEqual(other)) return false; |
94 |
|
|
|
95 |
|
✗ |
if (g_ != castother.g_) return false; |
96 |
|
✗ |
if (sa_ != castother.sa_) return false; |
97 |
|
✗ |
if (sd_ != castother.sd_) return false; |
98 |
|
|
|
99 |
|
✗ |
return true; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
std::ostream& print(std::ostream& os) const; |
103 |
|
|
|
104 |
|
|
DifferentiableFunctionPtr_t g_; |
105 |
|
|
const segment_t sa_, sd_; |
106 |
|
|
}; // class OfParameterSubset |
107 |
|
|
} // namespace function |
108 |
|
|
} // namespace constraints |
109 |
|
|
} // namespace hpp |
110 |
|
|
#endif // HPP_CONSTRAINTS_FUNCTION_OF_PARAMETER_SUBSET_HH |
111 |
|
|
|