geolib2
tf2_conversions.h
Go to the documentation of this file.
1 #ifndef GEOLIB_ROS_TF2_CONVERSIONS_H_
2 #define GEOLIB_ROS_TF2_CONVERSIONS_H_
3 
4 #include "geolib/datatypes.h"
5 
6 #include <tf2/LinearMath/Matrix3x3.h>
7 #include <tf2/LinearMath/Quaternion.h>
8 #include <tf2/LinearMath/Transform.h>
9 #include <tf2/LinearMath/Vector3.h>
10 
11 namespace geo {
12 
13 // ------------------------------ TO TF2 -----------------------------
14 
15 inline void convert(const geo::Vector3& v, tf2::Vector3& tf) {
16  tf.setValue(v.x, v.y, v.z);
17 }
18 
19 inline void convert(const geo::Quaternion& q, tf2::Quaternion& tf) {
20  tf.setValue(q.x, q.y, q.z, q.w);
21 }
22 
23 inline void convert(const geo::Matrix3& m, tf2::Matrix3x3& tf) {
24  tf.setValue(m.xx, m.xy, m.xz, m.yx, m.yy, m.yz, m.zx, m.zy, m.zz);
25 }
26 
27 inline void convert(const geo::Transform& t, tf2::Transform& tf) {
28  convert(t.getOrigin(), tf.getOrigin());
29  convert(t.getBasis(), tf.getBasis());
30 }
31 
32 // ------------------------------ FROM TF2 -----------------------------
33 
34 inline void convert(const tf2::Vector3& tf, geo::Vector3& v) {
35  v.x = tf.getX(); v.y = tf.getY(); v.z = tf.getZ();
36 }
37 
38 inline void convert(const tf2::Quaternion& tf ,geo::Quaternion& q) {
39  q.x = tf.getX(); q.y = tf.getY(); q.z = tf.getZ(); q.w = tf.getW();
40 }
41 
42 inline void convert(const tf2::Matrix3x3& tf, geo::Matrix3& m) {
43  m = geo::Matrix3(tf[0][0], tf[0][1], tf[0][2],
44  tf[1][0], tf[1][1], tf[1][2],
45  tf[2][0], tf[2][1], tf[2][2]);
46 }
47 
48 inline void convert(const tf2::Transform& tf, geo::Transform& t) {
49  convert(tf.getOrigin(), t.t);
50  convert(tf.getBasis(), t.R);
51 }
52 
53 }
54 
55 #endif
geo::Vector3::y
const real & y() const
Definition: matrix.h:32
geo::Vector3
Vec3 Vector3
Definition: datatypes.h:32
geo::QuaternionT
Definition: math_types.h:322
geo
Definition: Box.h:6
t
Timer t
geo::Mat3T::xz
T xz
Definition: math_types.h:576
geo::QuaternionT::w
T w
Definition: math_types.h:391
datatypes.h
geo::QuaternionT::y
T y
Definition: math_types.h:391
geo::Mat3T::zx
T zx
Definition: math_types.h:576
geo::QuaternionT::x
T x
Definition: math_types.h:391
geo::Mat3T::zz
T zz
Definition: math_types.h:576
geo::Mat3T::yy
T yy
Definition: math_types.h:576
geo::Transform
Definition: matrix.h:170
geo::Mat3T::xx
T xx
Definition: math_types.h:576
geo::Vector3
Definition: matrix.h:12
geo::Vector3::z
const real & z() const
Definition: matrix.h:33
geo::Mat3T::zy
T zy
Definition: math_types.h:576
geo::Mat3T
Definition: math_types.h:16
geo::Mat3T::yx
T yx
Definition: math_types.h:576
geo::convert
void convert(const geo::Vector3 &v, geometry_msgs::Point &msg)
converting geo::Vector3 to geometry_msgs::Point message
Definition: msg_conversions.h:23
geo::Vector3::x
const real & x() const
Definition: matrix.h:31
geo::Mat3T::yz
T yz
Definition: math_types.h:576
geo::QuaternionT::z
T z
Definition: math_types.h:391
geo::Transform
Transform3 Transform
Definition: datatypes.h:28
geo::Matrix3
Mat3 Matrix3
Definition: datatypes.h:33
geo::Mat3T::xy
T xy
Definition: math_types.h:576
geo::Quaternion
QuaternionT< real > Quaternion
Definition: datatypes.h:34