ethzasl-msf - Modular Sensor Fusion
Time delay compensated single and multi sensor fusion framework based on an EKF
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
eigen_conversions.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2012 Stephan Weiss, ASL, ETH Zurich, Switzerland
3  * You can contact the author at <stephan dot weiss at ieee dot org>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef EIGEN_CONVERSIONS_H_
18 #define EIGEN_CONVERSIONS_H_
19 
20 #include <Eigen/Dense>
21 #include <Eigen/Geometry>
22 
23 #include <geometry_msgs/Quaternion.h>
24 #include <geometry_msgs/Point.h>
25 
26 namespace eigen_conversions {
27 
29 template<class Scalar>
30 inline void quaternionToMsg(const Eigen::Quaternion<Scalar> & q_in,
31  geometry_msgs::Quaternion & q_out) {
32  q_out.w = q_in.w();
33  q_out.x = q_in.x();
34  q_out.y = q_in.y();
35  q_out.z = q_in.z();
36 }
37 
39 template<class Scalar>
41  const Eigen::Quaternion<Scalar> & q_in) {
43  quaternionToMsg(q_in, q_out);
44  return q_out;
45 }
46 
48 template<class Derived, class Point>
49 inline void vector3dToPoint(const Eigen::MatrixBase<Derived> & vec,
50  Point & point) {
51  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
52  point.x = vec[0];
53  point.y = vec[1];
54  point.z = vec[2];
55 }
56 
58 template<class Derived, class Point>
59 inline Point vector3dToPoint(const Eigen::MatrixBase<Derived> & vec) {
60  Point point;
61  vector3dToPoint(vec, point);
62  return point;
63 }
64 
65 }
66 ;
67 
68 #endif // EIGEN_CONVERSIONS_H_