EigenConverter.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 // STD/STL
25 
26 
27 // Header
28 #include "EigenConverter.h"
29 
31 {
32  Eigen::Quaternion<float>
34  {
35  return ConvertToQuaternion<float>(n);
36  }
37 
38  Eigen::Quaternion<double>
40  {
41  return ConvertToQuaternion<double>(n);
42  }
43 
44  Eigen::Vector3f
46  {
47  return ConvertToVector<float, 3>(n);
48  }
49 
50  Eigen::Vector3d
52  {
53  return ConvertToVector<double, 3>(n);
54  }
55 
58  {
59  return ConvertToMatrix<float, 4, 4>(n);
60  }
61 
62  Eigen::Matrix4d
64  {
65  return ConvertToMatrix<double, 4, 4>(n);
66  }
67 
68  Eigen::Quaternion<float>
70  {
71  return ConvertToQuaternion<float>(n);
72  }
73 
74  Eigen::Quaternion<double>
76  {
77  return ConvertToQuaternion<double>(n);
78  }
79 
80  Eigen::Vector3f
82  {
83  return ConvertToVector<float, 3>(n);
84  }
85 
86  Eigen::Vector3d
88  {
89  return ConvertToVector<double, 3>(n);
90  }
91 
94  {
95  return ConvertToMatrix<float, 4, 4>(n);
96  }
97 
98  Eigen::Matrix4d
100  {
101  return ConvertToMatrix<double, 4, 4>(n);
102  }
103 
104  void
105  AronEigenConverter::checkDimensions(const data::NDArray& nav,
106  const std::vector<int>& expected,
107  const std::string& method,
108  const std::string& caller)
109  {
110  if (nav.getShape() != expected)
111  {
112  std::stringstream ss;
113  ss << "The size of an NDArray does not match.";
114  ss << "\n Expected: \t" << data::NDArray::DimensionsToString(expected);
115  ss << "\n Got: \t" << data::NDArray::DimensionsToString(nav.getShape());
116  ss << "\n";
117  throw error::AronException(__PRETTY_FUNCTION__, ss.str(), nav.getPath());
118  }
119  }
120 } // namespace armarx::aron::data::converter
armarx::aron::error::AronException
A base class for aron exceptions.
Definition: Exception.h:42
armarx::aron::data::converter::AronEigenConverter::ConvertToMatrix4f
static Eigen::Matrix4f ConvertToMatrix4f(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:57
armarx::aron::data::NDArray
Definition: NDArray.h:48
armarx::aron::data::converter::AronEigenConverter::ConvertToQuaterniond
static Eigen::Quaternion< double > ConvertToQuaterniond(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:39
armarx::aron::data::Variant::getPath
Path getPath() const
get the path
Definition: Variant.h:110
armarx::aron::data::NDArrayPtr
std::shared_ptr< NDArray > NDArrayPtr
Definition: NDArray.h:46
armarx::aron::data::NDArray::getShape
std::vector< int > getShape() const
Definition: NDArray.cpp:145
armarx::aron::data::NDArray::DimensionsToString
static std::string DimensionsToString(const std::vector< int > &dimensions)
Return dimensions in a readable string such as "(2, 3, 4)".
Definition: NDArray.cpp:254
armarx::aron::data::converter::AronEigenConverter::ConvertToVector3d
static Eigen::Vector3d ConvertToVector3d(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:51
armarx::aron::data::converter::AronEigenConverter::ConvertToMatrix4d
static Eigen::Matrix4d ConvertToMatrix4d(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:63
EigenConverter.h
armarx::aron::data::converter::AronEigenConverter::ConvertToQuaternionf
static Eigen::Quaternion< float > ConvertToQuaternionf(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:33
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::aron::data::converter
Definition: aron_conversions.cpp:3
armarx::aron::data::converter::AronEigenConverter::ConvertToVector3f
static Eigen::Vector3f ConvertToVector3f(const data::NDArrayPtr &)
Definition: EigenConverter.cpp:45