hpp-constraints  4.12.0
Definition of basic geometric constraints for motion planning
differentiable-function.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Florent Lamiraux
4 //
5 // This file is part of hpp-constraints
6 // hpp-constraints is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-constraints is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-constraints If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CONSTRAINTS_DIFFERENTIABLE_FUNCTION_HH
20 # define HPP_CONSTRAINTS_DIFFERENTIABLE_FUNCTION_HH
21 
22 # include <hpp/constraints/fwd.hh>
23 # include <hpp/constraints/config.hh>
24 # include <hpp/pinocchio/liegroup-element.hh>
25 
26 # include <hpp/util/serialization-fwd.hh>
27 
28 namespace hpp {
29  namespace constraints {
30 
33 
53  {
54  public:
59  LiegroupElement operator () (vectorIn_t argument) const
60  {
61  assert (argument.size () == inputSize ());
62  LiegroupElement result (outputSpace_);
63  impl_compute (result, argument);
64  return result;
65  }
69  void value (LiegroupElementRef result,
70  vectorIn_t argument) const
71  {
72  assert (result.space()->nq() == outputSize ());
73  assert (argument.size () == inputSize ());
74  impl_compute (result, argument);
75  }
80  void jacobian (matrixOut_t jacobian, vectorIn_t argument) const
81  {
82  assert (argument.size () == inputSize ());
83  assert (jacobian.rows () == outputDerivativeSize ());
84  assert (jacobian.cols () == inputDerivativeSize ());
85  impl_jacobian (jacobian, argument);
86  }
87 
90  const ArrayXb& activeParameters () const
91  {
92  return activeParameters_;
93  }
94 
98  {
99  return activeDerivativeParameters_;
100  }
101 
104  {
105  return inputSize_;
106  }
113  {
114  return inputDerivativeSize_;
115  }
118  {
119  return outputSpace_;
120  }
123  {
124  return outputSpace_->nq ();
125  }
128  {
129  return outputSpace_->nv ();
130  }
134  const std::string& name () const
135  {
136  return name_;
137  }
138 
140  virtual std::ostream& print (std::ostream& o) const;
141 
142  std::string context () const {
143  return context_;
144  }
145 
146  void context (const std::string& c) {
147  context_ = c;
148  }
149 
159  void finiteDifferenceForward (matrixOut_t jacobian, vectorIn_t arg,
160  DevicePtr_t robot = DevicePtr_t (),
161  value_type eps = std::sqrt(Eigen::NumTraits<value_type>::epsilon())) const;
162 
172  void finiteDifferenceCentral (matrixOut_t jacobian, vectorIn_t arg,
173  DevicePtr_t robot = DevicePtr_t (),
174  value_type eps = std::sqrt(Eigen::NumTraits<value_type>::epsilon())) const;
175 
176  protected:
184  size_type sizeInputDerivative,
185  size_type sizeOutput,
186  std::string name = std::string ());
187 
195  size_type sizeInputDerivative,
196  const LiegroupSpacePtr_t& outputSpace,
197  std::string name = std::string ());
198 
200  virtual void impl_compute (LiegroupElementRef result,
201  vectorIn_t argument) const = 0;
202 
203  virtual void impl_jacobian (matrixOut_t jacobian,
204  vectorIn_t arg) const = 0;
205 
212 
221 
222  private:
223  std::string name_;
225  std::string context_;
226 
228 
229  protected:
231  private:
232  HPP_SERIALIZABLE();
233  }; // class DifferentiableFunction
234  inline std::ostream&
235  operator<< (std::ostream& os, const DifferentiableFunction& f)
236  {
237  return f.print (os);
238  }
240  } // namespace constraints
241 } // namespace hpp
242 
243 
244 #endif // HPP_CONSTRAINTS_DIFFERENTIABLE_FUNCTION_HH
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:48
ArrayXb activeParameters_
Definition: differentiable-function.hh:216
Definition: active-set-differentiable-function.hh:24
pinocchio::LiegroupSpacePtr_t LiegroupSpacePtr_t
Definition: fwd.hh:57
virtual std::ostream & print(std::ostream &o) const
Display object in a stream.
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:97
size_type outputDerivativeSize() const
Get dimension of output derivative vector.
Definition: differentiable-function.hh:127
size_type inputSize_
Dimension of input vector.
Definition: differentiable-function.hh:207
pinocchio::LiegroupElement LiegroupElement
Definition: fwd.hh:53
size_type inputDerivativeSize() const
Definition: differentiable-function.hh:112
LiegroupSpacePtr_t outputSpace_
Dimension of output vector.
Definition: differentiable-function.hh:211
size_type outputSize() const
Get dimension of output vector.
Definition: differentiable-function.hh:122
pinocchio::ArrayXb ArrayXb
Definition: fwd.hh:68
Definition: differentiable-function-set.hh:33
size_type inputDerivativeSize_
Dimension of input derivative.
Definition: differentiable-function.hh:209
void value(LiegroupElementRef result, vectorIn_t argument) const
Definition: differentiable-function.hh:69
const std::string & name() const
Get function name.
Definition: differentiable-function.hh:134
assert(d.lhs()._blocks()==d.rhs()._blocks())
void jacobian(matrixOut_t jacobian, vectorIn_t argument) const
Definition: differentiable-function.hh:80
const ArrayXb & activeParameters() const
Definition: differentiable-function.hh:90
Definition: differentiable-function.hh:52
const ArrayXb & activeDerivativeParameters() const
Definition: differentiable-function.hh:97
void context(const std::string &c)
Definition: differentiable-function.hh:146
size_type inputSize() const
Get dimension of input vector.
Definition: differentiable-function.hh:103
std::string context() const
Definition: differentiable-function.hh:142
ComparisonTypes_t operator<<(const ComparisonType &a, const ComparisonType &b)
Definition: comparison-types.hh:54
LiegroupSpacePtr_t outputSpace() const
Get output space.
Definition: differentiable-function.hh:117
DifferentiableFunction()
Definition: differentiable-function.hh:230
#define HPP_CONSTRAINTS_DLLAPI
Definition: config.hh:64
pinocchio::LiegroupElementRef LiegroupElementRef
Definition: fwd.hh:54
pinocchio::size_type size_type
Definition: fwd.hh:36
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:46
pinocchio::value_type value_type
Definition: fwd.hh:37
virtual ~DifferentiableFunction()
Definition: differentiable-function.hh:55
ArrayXb activeDerivativeParameters_
Definition: differentiable-function.hh:220