hpp-pinocchio  6.0.0
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 
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_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
30 #define HPP_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
31 
32 #include <pinocchio/multibody/liegroup/special-orthogonal.hpp>
33 
34 namespace hpp {
35 namespace pinocchio {
36 namespace liegroup {
37 template <int N>
39  : public ::pinocchio::SpecialOrthogonalOperationTpl<N, value_type> {
40  typedef ::pinocchio::SpecialOrthogonalOperationTpl<N, value_type> Base;
41  enum { BoundSize = 0, NR = Base::NV, NT = 0 };
42 
43  template <class ConfigL_t, class ConfigR_t>
44  double squaredDistance(const Eigen::MatrixBase<ConfigL_t>& q0,
45  const Eigen::MatrixBase<ConfigR_t>& q1) {
46  return Base::squaredDistance(q0, q1);
47  }
48 
49  template <class ConfigL_t, class ConfigR_t>
50  double squaredDistance(const Eigen::MatrixBase<ConfigL_t>& q0,
51  const Eigen::MatrixBase<ConfigR_t>& q1,
52  const typename ConfigL_t::Scalar& w) {
53  return w * squaredDistance(q0, q1);
54  }
55 
56  template <class ConfigIn_t, class ConfigOut_t>
57  static void setBound(const Eigen::MatrixBase<ConfigIn_t>& bound,
58  const Eigen::MatrixBase<ConfigOut_t>& out) {
59  if (bound.size() == 0) return;
60  if (bound.size() != Base::NQ) {
61  HPP_THROW(std::invalid_argument, "Expected vector of size 0 or "
62  << (int)Base::NQ << ", got size "
63  << bound.size());
64  }
65  const_cast<Eigen::MatrixBase<ConfigOut_t>&>(out).head(bound.size()) = bound;
66  }
67 
68  template <class JacobianIn_t, class JacobianOut_t>
70  const Eigen::MatrixBase<JacobianIn_t>& Jin,
71  const Eigen::MatrixBase<JacobianOut_t>& Jout) {
72  const_cast<Eigen::MatrixBase<JacobianOut_t>&>(Jout) = Jin;
73  }
74 
75  template <class ConfigIn_t>
76  static bool isNormalized(const Eigen::MatrixBase<ConfigIn_t>& q,
77  const value_type& eps) {
78  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ConfigIn_t, Base::ConfigVector_t);
79  return (std::abs(q.norm() - 1) < eps);
80  }
81 };
82 } // namespace liegroup
83 } // namespace pinocchio
84 } // namespace hpp
85 
86 #endif // HPP_PINOCCHIO_LIEGROUP_SPECIAL_ORTHOGONAL_OPERATION_HH
double value_type
Definition: fwd.hh:51
Utility functions.
Definition: body.hh:39
Definition: collision-object.hh:40
Definition: special-orthogonal.hh:39
@ BoundSize
Definition: special-orthogonal.hh:41
@ NT
Definition: special-orthogonal.hh:41
@ NR
Definition: special-orthogonal.hh:41
static void getRotationSubJacobian(const Eigen::MatrixBase< JacobianIn_t > &Jin, const Eigen::MatrixBase< JacobianOut_t > &Jout)
Definition: special-orthogonal.hh:69
::pinocchio::SpecialOrthogonalOperationTpl< N, value_type > Base
Definition: special-orthogonal.hh:40
static void setBound(const Eigen::MatrixBase< ConfigIn_t > &bound, const Eigen::MatrixBase< ConfigOut_t > &out)
Definition: special-orthogonal.hh:57
static bool isNormalized(const Eigen::MatrixBase< ConfigIn_t > &q, const value_type &eps)
Definition: special-orthogonal.hh:76
double squaredDistance(const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1)
Definition: special-orthogonal.hh:44
double squaredDistance(const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const typename ConfigL_t::Scalar &w)
Definition: special-orthogonal.hh:50