hpp-constraints  4.13.0
Definition of basic geometric constraints for motion planning
implicit-function.hh
Go to the documentation of this file.
1 // Copyright (c) 2015 - 2018 LAAS-CNRS
2 // Authors: Florent Lamiraux, Joseph Mirabel
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_EXPLICIT_IMPLICIT_FUNCTION_HH
30 #define HPP_CONSTRAINTS_EXPLICIT_IMPLICIT_FUNCTION_HH
31 
34 
35 namespace hpp {
36 namespace constraints {
37 namespace explicit_ {
50  public:
51  typedef shared_ptr<ImplicitFunction> Ptr_t;
62 
63  static Ptr_t create(const LiegroupSpacePtr_t& configSpace,
64  const DifferentiableFunctionPtr_t& function,
65  const segments_t& inputConf, const segments_t& outputConf,
66  const segments_t& inputVelocity,
67  const segments_t& outputVelocity);
68 
71 
72  protected:
81  ImplicitFunction(const LiegroupSpacePtr_t& configSpace,
82  const DifferentiableFunctionPtr_t& function,
83  const segments_t& inputConf, const segments_t& outputConf,
84  const segments_t& inputVelocity,
85  const segments_t& outputVelocity);
87  void impl_compute(LiegroupElementRef result, vectorIn_t argument) const;
88 
91 
92  bool isEqual(const DifferentiableFunction& other) const {
93  const ImplicitFunction& castother =
94  dynamic_cast<const ImplicitFunction&>(other);
95  if (!DifferentiableFunction::isEqual(other)) return false;
96 
97  if (robot_ != castother.robot_) return false;
98  if (inputToOutput_ != castother.inputToOutput_) return false;
99  if (inputConfIntervals_.rows() != castother.inputConfIntervals_.rows())
100  return false;
101  if (outputConfIntervals_.rows() != castother.outputConfIntervals_.rows())
102  return false;
103  if (inputDerivIntervals_.rows() != castother.inputDerivIntervals_.rows())
104  return false;
105  if (outputDerivIntervals_.rows() != castother.outputDerivIntervals_.rows())
106  return false;
107 
108  return true;
109  }
110 
111  private:
112  void computeJacobianBlocks();
113 
114  DevicePtr_t robot_;
115  DifferentiableFunctionPtr_t inputToOutput_;
116  Eigen::RowBlockIndices inputConfIntervals_;
117  Eigen::RowBlockIndices outputConfIntervals_;
118  Eigen::RowBlockIndices inputDerivIntervals_;
119  Eigen::RowBlockIndices outputDerivIntervals_;
120  std::vector<Eigen::MatrixBlocks<false, false> > outJacobian_;
121  std::vector<Eigen::MatrixBlocks<false, false> > inJacobian_;
122  mutable vector_t qIn_;
123  mutable LiegroupElement f_qIn_, qOut_;
124  mutable LiegroupElement result_;
125  // Jacobian of explicit function
126  mutable matrix_t Jf_;
127 
128  ImplicitFunction() {}
129  HPP_SERIALIZABLE();
130 }; // class ImplicitFunction
131 
132 } // namespace explicit_
133 } // namespace constraints
134 } // namespace hpp
135 
136 BOOST_CLASS_EXPORT_KEY(hpp::constraints::explicit_::ImplicitFunction)
137 
138 #endif // HPP_CONSTRAINTS_EXPLICIT_IMPLICIT_FUNCTION_HH
std::vector< segment_t > segments_t
Definition: fwd.hh:83
pinocchio::vector_t vector_t
Definition: fwd.hh:58
pinocchio::vectorIn_t vectorIn_t
Definition: fwd.hh:59
const DifferentiableFunctionPtr_t & inputToOutput() const
Get function f that maps input variables to output variables.
static Ptr_t create(const LiegroupSpacePtr_t &configSpace, const DifferentiableFunctionPtr_t &function, const segments_t &inputConf, const segments_t &outputConf, const segments_t &inputVelocity, const segments_t &outputVelocity)
Definition: active-set-differentiable-function.hh:36
pinocchio::LiegroupSpacePtr_t LiegroupSpacePtr_t
Definition: fwd.hh:68
bool isEqual(const DifferentiableFunction &other) const
Definition: implicit-function.hh:92
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:108
pinocchio::LiegroupElement LiegroupElement
Definition: fwd.hh:64
void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const
Compute Jacobian of g (q_out) - f (q_in) with respect to q.
pinocchio::matrix_t matrix_t
Definition: fwd.hh:55
Definition: implicit-function.hh:49
virtual bool isEqual(const DifferentiableFunction &other) const
Definition: differentiable-function.hh:190
void jacobian(matrixOut_t jacobian, vectorIn_t argument) const
Definition: differentiable-function.hh:88
Definition: differentiable-function.hh:63
shared_ptr< DifferentiableFunction > DifferentiableFunctionPtr_t
Definition: fwd.hh:111
pinocchio::LiegroupElementRef LiegroupElementRef
Definition: fwd.hh:65
Eigen::Ref< matrix_t > matrixOut_t
Definition: fwd.hh:57
shared_ptr< ImplicitFunction > Ptr_t
Definition: implicit-function.hh:51
const RowIndices_t & rows() const
Definition: matrix-view.hh:673
void impl_compute(LiegroupElementRef result, vectorIn_t argument) const
Compute g (q_out) - f (q_in)