hpp-pinocchio  4.9.1
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
special-orthogonal.hh
Go to the documentation of this file.
1 // Copyright (c) 2017, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-pinocchio.
5 // hpp-pinocchio is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-pinocchio is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-pinocchio. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
18 #define HPP_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
19 
20 #include <pinocchio/multibody/liegroup/special-orthogonal.hpp>
21 
22 namespace hpp {
23  namespace pinocchio {
24  namespace liegroup {
25  template<int N>
27  {
28  typedef ::pinocchio::SpecialOrthogonalOperationTpl<N, value_type> Base;
29  enum {
30  BoundSize = 0,
31  NR = Base::NV,
32  NT = 0
33  };
34 
35  template <class ConfigL_t, class ConfigR_t>
37  const Eigen::MatrixBase<ConfigL_t> & q0,
38  const Eigen::MatrixBase<ConfigR_t> & q1)
39  {
40  return Base::squaredDistance(q0, q1);
41  }
42 
43  template <class ConfigL_t, class ConfigR_t>
45  const Eigen::MatrixBase<ConfigL_t> & q0,
46  const Eigen::MatrixBase<ConfigR_t> & q1,
47  const typename ConfigL_t::Scalar& w)
48  {
49  return w * squaredDistance(q0, q1);
50  }
51 
52  template <class ConfigIn_t, class ConfigOut_t>
53  static void setBound(
54  const Eigen::MatrixBase<ConfigIn_t > & bound,
55  const Eigen::MatrixBase<ConfigOut_t> & out)
56  {
57  if (bound.size() == 0) return;
58  if (bound.size() != Base::NQ) {
59  HPP_THROW(std::invalid_argument, "Expected vector of size 0 or "
60  << (int)Base::NQ << ", got size " << bound.size());
61  }
62  const_cast<Eigen::MatrixBase<ConfigOut_t>&>(out).head(bound.size()) = bound;
63  }
64 
65  template <class JacobianIn_t, class JacobianOut_t>
67  const Eigen::MatrixBase<JacobianIn_t > & Jin,
68  const Eigen::MatrixBase<JacobianOut_t> & Jout)
69  {
70  const_cast<Eigen::MatrixBase<JacobianOut_t>&> (Jout) = Jin;
71  }
72 
73  template <class ConfigIn_t>
74  static bool isNormalized(const Eigen::MatrixBase<ConfigIn_t > & q, const value_type& eps)
75  {
76  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ConfigIn_t , Base::ConfigVector_t);
77  return (std::abs(q.norm() - 1) < eps );
78  }
79  };
80  } // namespace liegroup
81  } // namespace pinocchio
82 } // namespace hpp
83 
84 #endif // HPP_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
static void getRotationSubJacobian(const Eigen::MatrixBase< JacobianIn_t > &Jin, const Eigen::MatrixBase< JacobianOut_t > &Jout)
Definition: special-orthogonal.hh:66
#define HPP_THROW(TYPE, MSG)
double squaredDistance(const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const typename ConfigL_t::Scalar &w)
Definition: special-orthogonal.hh:44
Utility functions.
static void setBound(const Eigen::MatrixBase< ConfigIn_t > &bound, const Eigen::MatrixBase< ConfigOut_t > &out)
Definition: special-orthogonal.hh:53
::pinocchio::SpecialOrthogonalOperationTpl< N, value_type > Base
Definition: special-orthogonal.hh:28
static bool isNormalized(const Eigen::MatrixBase< ConfigIn_t > &q, const value_type &eps)
Definition: special-orthogonal.hh:74
double squaredDistance(const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1)
Definition: special-orthogonal.hh:36
double value_type
Definition: fwd.hh:40
Definition: special-orthogonal.hh:26