geolib2
msg_conversions.h
Go to the documentation of this file.
1 #ifndef GEOLIB_ROS_MSG_CONVERSIONS_H_
2 #define GEOLIB_ROS_MSG_CONVERSIONS_H_
3 
4 #include "geolib/datatypes.h"
5 #include "geolib/Mesh.h"
7 #include <geometry_msgs/Pose.h>
8 #include <geometry_msgs/Point.h>
9 #include <geometry_msgs/Point32.h>
10 #include <geometry_msgs/Transform.h>
11 #include <sensor_msgs/CameraInfo.h>
12 #include <shape_msgs/Mesh.h>
13 
14 namespace geo {
15 
16 // ------------------------------ TO ROS ------------------------------
17 
23 inline void convert(const geo::Vector3& v, geometry_msgs::Point& msg) {
24  msg.x = v.x; msg.y = v.y; msg.z = v.z;
25 }
26 
32 inline void convert(const geo::Vector3& v, geometry_msgs::Point32& msg) {
33  msg.x = v.x; msg.y = v.y; msg.z = v.z;
34 }
35 
41 inline void convert(const geo::Vector3& v, geometry_msgs::Vector3& msg) {
42  msg.x = v.x; msg.y = v.y; msg.z = v.z;
43 }
44 
50 inline void convert(const geo::Quaternion& q, geometry_msgs::Quaternion& msg) {
51  msg.x = q.x; msg.y = q.y; msg.z = q.z; msg.w = q.w;
52 }
53 
59 inline void convert(const geo::Matrix3& r, geometry_msgs::Quaternion& msg) {
60  Quaternion q;
61  r.getRotation(q);
62  convert(q, msg);
63 }
64 
70 inline void convert(const geo::Transform& t, geometry_msgs::Pose& msg) {
71  convert(t.getOrigin(), msg.position);
72  convert(t.getBasis(), msg.orientation);
73 }
74 
80 inline void convert(const geo::Transform& t, geometry_msgs::Transform& msg) {
81  convert(t.getOrigin(), msg.translation);
82  convert(t.getBasis(), msg.rotation);
83 }
84 
90 inline void convert(const geo::TriangleI& t, shape_msgs::MeshTriangle& msg) {
91  msg.vertex_indices[0] = t.i1_;
92  msg.vertex_indices[1] = t.i2_;
93  msg.vertex_indices[2] = t.i3_;
94 }
95 
102 void convert(const geo::Mesh& m, shape_msgs::Mesh& msg);
103 
109 void convert(const geo::DepthCamera& cam_model, sensor_msgs::CameraInfo& msg);
110 
111 // ------------------------------ FROM ROS ------------------------------
112 
118 inline void convert(const geometry_msgs::Point& msg, geo::Vector3& v) {
119  v.x = msg.x; v.y = msg.y; v.z = msg.z;
120 }
121 
127 inline void convert(const geometry_msgs::Point32& msg, geo::Vector3& v) {
128  v.x = msg.x; v.y = msg.y; v.z = msg.z;
129 }
130 
136 inline void convert(const geometry_msgs::Vector3& msg, geo::Vector3& v) {
137  v.x = msg.x; v.y = msg.y; v.z = msg.z;
138 }
139 
145 inline void convert(const geometry_msgs::Quaternion& msg, geo::Quaternion& q) {
146  q.x = msg.x; q.y = msg.y; q.z = msg.z; q.w = msg.w;
147 }
148 
154 inline void convert(const geometry_msgs::Quaternion& msg, geo::Matrix3& r) {
155  Quaternion q;
156  convert(msg, q);
157  r.setRotation(q);
158 }
159 
165 inline void convert(const geometry_msgs::Pose& msg, geo::Transform& t) {
166  convert(msg.orientation, t.R);
167  convert(msg.position, t.t);
168 }
169 
175 inline void convert(const geometry_msgs::Transform& msg, geo::Transform& t) {
176  convert(msg.rotation, t.R);
177  convert(msg.translation, t.t);
178 }
179 
180 }
181 
182 #endif
geo::Vector3::y
const real & y() const
Definition: matrix.h:32
geo::Vector3
Vec3 Vector3
Definition: datatypes.h:32
geo::Mat3T::setRotation
void setRotation(const QuaternionT< T > &q)
Definition: math_types.h:546
geo::QuaternionT
Definition: math_types.h:322
geo::Mat3T::getRotation
void getRotation(QuaternionT< T > &q) const
Definition: math_types.h:520
geo
Definition: Box.h:6
t
Timer t
geo::QuaternionT::w
T w
Definition: math_types.h:391
datatypes.h
geo::TriangleI
Definition: Mesh.h:11
geo::QuaternionT::y
T y
Definition: math_types.h:391
geo::QuaternionT::x
T x
Definition: math_types.h:391
geo::Transform
Definition: matrix.h:170
DepthCamera.h
geo::Vector3
Definition: matrix.h:12
geo::Vector3::z
const real & z() const
Definition: matrix.h:33
geo::Mat3T
Definition: math_types.h:16
Mesh.h
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::DepthCamera
Definition: DepthCamera.h:159
geo::QuaternionT::z
T z
Definition: math_types.h:391
geo::Transform
Transform3 Transform
Definition: datatypes.h:28
geo::Mesh
Definition: Mesh.h:25
geo::Quaternion
QuaternionT< real > Quaternion
Definition: datatypes.h:34