matrix.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2011, Johannes Meyer and Martin Nowara, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Flight Systems and Automatic Control group,
13 // TU Darmstadt, nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 #ifndef HECTOR_POSE_ESTIMATION_MATRIX_H
30 #define HECTOR_POSE_ESTIMATION_MATRIX_H
31 
32 #include <hector_pose_estimation/matrix_config.h>
35 
36 #include <Eigen/Core>
37 #include <Eigen/Geometry>
38 #include <stdexcept>
39 
40 namespace hector_pose_estimation {
41  using Eigen::Dynamic;
42  using Eigen::Lower;
43  using Eigen::Upper;
44  using Eigen::DenseBase;
45 
46  typedef double ScalarType;
47  typedef Eigen::DenseIndex IndexType;
48 
49  typedef Eigen::Quaternion<ScalarType> Quaternion;
50 
51  template <int Rows>
52  struct ColumnVector_ {
53  typedef Eigen::Matrix<ScalarType, Rows, 1,
54  Eigen::ColMajor,
55  (Rows != Dynamic ? Rows : MaxVectorSize), 1
56  > type;
57  };
60 
61  template <int Cols>
62  struct RowVector_ {
63  typedef Eigen::Matrix<ScalarType, 1, Cols,
64  Eigen::RowMajor,
65  1, (Cols != Dynamic ? Cols : MaxVectorSize)
66  > type;
67  };
69  typedef typename RowVector_<3>::type RowVector3;
70 
71  template <int Rows, int Cols>
72  struct Matrix_ {
73  typedef Eigen::Matrix<ScalarType, Rows, Cols,
74  (Rows == 1 && Cols != 1 ? Eigen::RowMajor : Eigen::ColMajor),
75  (Rows != Dynamic ? Rows : MaxMatrixRowsCols),
76  (Cols != Dynamic ? Cols : MaxMatrixRowsCols)
77  > type;
78  };
80  typedef typename Matrix_<3,3>::type Matrix3;
81 
82  template <int RowsCols>
85  };
89 
90  template <typename OtherDerived>
91  static inline Matrix3 SkewSymmetricMatrix(const Eigen::MatrixBase<OtherDerived>& other) {
92  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Eigen::MatrixBase<OtherDerived>, 3);
93  Matrix3 result;
94  result << 0.0, -other.z(), other.y(),
95  other.z(), 0.0, -other.x(),
96  -other.y(), other.x(), 0.0;
97  return result;
98  }
99 
100 } // namespace hector_pose_estimation
101 
102 namespace Eigen {
103 
104 // Add template specializations of DenseStorage for null matrices for older Eigen versions.
105 // Those have been added to Eigen 3.1.0.
106 // See https://bitbucket.org/eigen/eigen/commits/e03061319d0297c34e3128dcc5a780824b4fdb78.
107 // Copied from https://bitbucket.org/eigen/eigen/src/167ce78594dc4e7a4b9ca27fc745e674300e85ff/Eigen/src/Core/DenseStorage.h.
108 #if !EIGEN_VERSION_AT_LEAST(3,0,91)
109  // more specializations for null matrices; these are necessary to resolve ambiguities
110  template<typename T, int _Options> class DenseStorage<T, 0, Dynamic, Dynamic, _Options>
111  : public DenseStorage<T, 0, 0, 0, _Options> { };
112 
113  template<typename T, int _Rows, int _Options> class DenseStorage<T, 0, _Rows, Dynamic, _Options>
114  : public DenseStorage<T, 0, 0, 0, _Options> { };
115 
116  template<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, _Cols, _Options>
117  : public DenseStorage<T, 0, 0, 0, _Options> { };
118 #endif
119 
120 } // namespace Eigen
121 
122 namespace hector_pose_estimation {
123 
124  using Eigen::VectorBlock;
125  typedef VectorBlock<ColumnVector,3> VectorBlock3;
126  typedef VectorBlock<ColumnVector,4> VectorBlock4;
127  typedef VectorBlock<const ColumnVector,3> ConstVectorBlock3;
128  typedef VectorBlock<const ColumnVector,4> ConstVectorBlock4;
129 
130  using Eigen::Block;
131  typedef Eigen::Block<Matrix,Dynamic,Dynamic> MatrixBlock;
132 
133 } // namespace hector_pose_estimation
134 
135 #endif // HECTOR_POSE_ESTIMATION_MATRIX_H
Eigen::Block< Matrix, Dynamic, Dynamic > MatrixBlock
Definition: matrix.h:131
Definition: matrix.h:102
Matrix_< RowsCols, RowsCols >::type type
Definition: matrix.h:84
Eigen::Quaternion< ScalarType > Quaternion
Definition: matrix.h:49
RowVector_< Dynamic >::type RowVector
Definition: matrix.h:68
SymmetricMatrix_< 3 >::type SymmetricMatrix3
Definition: matrix.h:86
Eigen::DenseIndex IndexType
Definition: matrix.h:47
SymmetricMatrix_< 6 >::type SymmetricMatrix6
Definition: matrix.h:87
VectorBlock< const ColumnVector, 4 > ConstVectorBlock4
Definition: matrix.h:128
RowVector_< 3 >::type RowVector3
Definition: matrix.h:69
Matrix_< 3, 3 >::type Matrix3
Definition: matrix.h:80
ColumnVector_< Dynamic >::type ColumnVector
Definition: matrix.h:58
Eigen::Matrix< ScalarType, Rows, Cols,(Rows==1 &&Cols!=1?Eigen::RowMajor:Eigen::ColMajor),(Rows!=Dynamic?Rows:MaxMatrixRowsCols),(Cols!=Dynamic?Cols:MaxMatrixRowsCols) > type
Definition: matrix.h:77
VectorBlock< const ColumnVector, 3 > ConstVectorBlock3
Definition: matrix.h:127
Matrix_< Dynamic, Dynamic >::type Matrix
Definition: matrix.h:79
Eigen::Matrix< ScalarType, 1, Cols, Eigen::RowMajor, 1,(Cols!=Dynamic?Cols:MaxVectorSize) > type
Definition: matrix.h:66
Eigen::Matrix< ScalarType, Rows, 1, Eigen::ColMajor,(Rows!=Dynamic?Rows:MaxVectorSize), 1 > type
Definition: matrix.h:56
SymmetricMatrix_< Dynamic >::type SymmetricMatrix
Definition: matrix.h:88
ColumnVector_< 3 >::type ColumnVector3
Definition: matrix.h:59
static Matrix3 SkewSymmetricMatrix(const Eigen::MatrixBase< OtherDerived > &other)
Definition: matrix.h:91
VectorBlock< ColumnVector, 4 > VectorBlock4
Definition: matrix.h:126
VectorBlock< ColumnVector, 3 > VectorBlock3
Definition: matrix.h:125


hector_pose_estimation_core
Author(s): Johannes Meyer
autogenerated on Thu Feb 18 2021 03:29:30