$search
00001 //================================================================================================= 00002 // Copyright (c) 2011, Johannes Meyer and Martin Nowara, TU Darmstadt 00003 // All rights reserved. 00004 00005 // Redistribution and use in source and binary forms, with or without 00006 // modification, are permitted provided that the following conditions are met: 00007 // * Redistributions of source code must retain the above copyright 00008 // notice, this list of conditions and the following disclaimer. 00009 // * Redistributions in binary form must reproduce the above copyright 00010 // notice, this list of conditions and the following disclaimer in the 00011 // documentation and/or other materials provided with the distribution. 00012 // * Neither the name of the Flight Systems and Automatic Control group, 00013 // TU Darmstadt, nor the names of its contributors may be used to 00014 // endorse or promote products derived from this software without 00015 // specific prior written permission. 00016 00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 //================================================================================================= 00028 00029 #ifndef HECTOR_POSE_ESTIMATION_MATRIX_H 00030 #define HECTOR_POSE_ESTIMATION_MATRIX_H 00031 00032 #include <bfl/wrappers/matrix/matrix_wrapper.h> 00033 #include <stdexcept> 00034 00035 namespace hector_pose_estimation { 00036 00037 using namespace MatrixWrapper; 00038 00039 template <unsigned int dim> 00040 class ColumnVector_ : public ColumnVector { 00041 public: 00042 ColumnVector_() : ColumnVector(dim) {} 00043 ColumnVector_(double value) : ColumnVector(dim, value) {} 00044 ColumnVector_(const ColumnVector_<dim>& other) : ColumnVector(other) {} 00045 ColumnVector_(const ColumnVector& other) : ColumnVector(other) 00046 { 00047 if (other.rows() != dim) { 00048 std::cerr << (int)dim << " != " << (int)other.rows() << std::endl; 00049 throw std::runtime_error("Illegal vector assignment"); 00050 } 00051 } 00052 // ColumnVector_<dim>& operator=(const ColumnVector& other) { 00053 // if (other.rows() != dim) throw std::runtime_error("Illegal vector assignment"); 00054 // static_cast<ColumnVector &>(*this) = other; 00055 // return *this; 00056 // } 00057 }; 00058 00059 template <unsigned int dim> 00060 class RowVector_ : public RowVector { 00061 public: 00062 RowVector_() : RowVector(dim) {} 00063 RowVector_(double value) : RowVector(dim, value) {} 00064 RowVector_(const RowVector_<dim>& other) : RowVector(other) {} 00065 RowVector_(const RowVector& other) : RowVector(other) { 00066 if (other.columns() != dim) { 00067 std::cerr << (int)dim << " != " << (int)other.columns() << std::endl; 00068 throw std::runtime_error("Illegal vector assignment"); 00069 } 00070 } 00071 // RowVector_<dim>& operator=(const RowVector& other) { 00072 // if (other.columns() != dim) throw std::runtime_error("Illegal vector assignment"); 00073 // static_cast<RowVector &>(*this) = other; 00074 // return *this; 00075 // } 00076 }; 00077 00078 template <unsigned int m, unsigned int n> 00079 class Matrix_ : public Matrix { 00080 public: 00081 Matrix_() : Matrix(m, n) {} 00082 Matrix_(double value) : Matrix(m, RowVector_<n>(value)) {} 00083 Matrix_(const RowVector_<n> &row_value) : Matrix(m, row_value) {} 00084 Matrix_(const Matrix_<m,n>& other) : Matrix(other) {} 00085 Matrix_(const Matrix& other) : Matrix(other) { 00086 if (other.rows() != m || other.columns() != n) { 00087 std::cerr << (int)m << "x" << (int)n << " != " << (int)other.rows() << "x" << (int)other.columns() << std::endl; 00088 throw std::runtime_error("Illegal matrix assignment"); 00089 } 00090 } 00091 // Matrix_<m,n>& operator=(const Matrix& other) { 00092 // if (other.rows() != m || other.columns() != n) throw std::runtime_error("Illegal matrix assignment"); 00093 // static_cast<Matrix &>(*this) = other; 00094 // return *this; 00095 // } 00096 }; 00097 00098 template <unsigned int dim> 00099 class SymmetricMatrix_ : public SymmetricMatrix { 00100 public: 00101 SymmetricMatrix_() : SymmetricMatrix(dim) {} 00102 SymmetricMatrix_(double value) : SymmetricMatrix(dim, RowVector_<dim>(value)) {} 00103 SymmetricMatrix_(const SymmetricMatrix_<dim>& other) : SymmetricMatrix(other) {} 00104 SymmetricMatrix_(const SymmetricMatrix& other) : SymmetricMatrix(other) { 00105 if (other.rows() != dim || other.columns() != dim) { 00106 std::cerr << (int)dim << "x" << (int)dim << " != " << (int)other.rows() << "x" << (int)other.columns() << std::endl; 00107 throw std::runtime_error("Illegal matrix assignment"); 00108 } 00109 } 00110 // SymmetricMatrix_<dim>& operator=(const SymmetricMatrix& other) { 00111 // if (other.rows() != dim || other.columns() != dim) throw std::runtime_error("Illegal matrix assignment"); 00112 // static_cast<SymmetricMatrix &>(*this) = other; 00113 // return *this; 00114 // } 00115 }; 00116 00117 } // namespace hector_pose_estimation 00118 00119 #endif // HECTOR_POSE_ESTIMATION_MATRIX_H