msg_conversions.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef MSG_CONVERSIONS_H
30 #define MSG_CONVERSIONS_H
31 
32 #include "OgreVector3.h"
33 #include "OgreQuaternion.h"
34 
35 #include <geometry_msgs/Point.h>
36 #include <geometry_msgs/Vector3.h>
37 #include <geometry_msgs/Quaternion.h>
38 
39 namespace rviz {
40 
41 // This file contains some convenience functions for Ogre / geometry_msgs conversions.
42 
43 // pointMsgToOgre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
44 static inline Ogre::Vector3 pointMsgToOgre(const geometry_msgs::Point& m)
45 {
46  return Ogre::Vector3(m.x, m.y, m.z);
47 }
48 
49 static inline void pointMsgToOgre(const geometry_msgs::Point &m, Ogre::Vector3& o)
50 {
51  o.x = m.x; o.y = m.y; o.z = m.z;
52 }
53 
54 // vector3MsgToOgre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
55 static inline Ogre::Vector3 vector3MsgToOgre(const geometry_msgs::Vector3& m)
56 {
57  return Ogre::Vector3(m.x, m.y, m.z);
58 }
59 
60 
61 static inline void vector3MsgToOgre(const geometry_msgs::Vector3 &m, Ogre::Vector3& o)
62 {
63  o.x = m.x; o.y = m.y; o.z = m.z;
64 }
65 
66 // quaternionMsgToOgre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
67 static inline Ogre::Quaternion quaternionMsgToOgre(const geometry_msgs::Quaternion& m)
68 {
69  return Ogre::Quaternion(m.w, m.x, m.y, m.z);
70 }
71 
72 static inline void quaternionMsgToOgre(const geometry_msgs::Quaternion &m, Ogre::Quaternion& o)
73 {
74  o.w = m.w; o.x = m.x; o.y = m.y; o.z = m.z;
75 }
76 
77 // pointOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
78 static inline void pointOgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Point &m)
79 {
80  m.x = o.x; m.y = o.y; m.z = o.z;
81 }
82 
83 static inline geometry_msgs::Point pointOgreToMsg(const Ogre::Vector3 &o)
84 {
85  geometry_msgs::Point m;
86  pointOgreToMsg(o, m);
87  return m;
88 }
89 
90 // vectorOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
91 static inline void vector3OgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Vector3 &m)
92 {
93  m.x = o.x; m.y = o.y; m.z = o.z;
94 }
95 
96 static inline geometry_msgs::Vector3 vector3OgreToMsg(const Ogre::Vector3 &o)
97 {
98  geometry_msgs::Vector3 m;
99  vector3OgreToMsg(o, m);
100  return m;
101 }
102 
103 // quaternionOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
104 static inline void quaternionOgreToMsg(const Ogre::Quaternion &o, geometry_msgs::Quaternion &m)
105 {
106  m.w = o.w; m.x = o.x; m.y = o.y; m.z = o.z;
107 }
108 
109 static inline geometry_msgs::Quaternion quaternionOgreToMsg(const Ogre::Quaternion &o)
110 {
111  geometry_msgs::Quaternion m;
112  quaternionOgreToMsg(o, m);
113  return m;
114 }
115 
116 
117 } // namespace rviz
118 
119 #endif
static void pointOgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Point &m)
static void vector3OgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Vector3 &m)
static Ogre::Vector3 pointMsgToOgre(const geometry_msgs::Point &m)
static Ogre::Quaternion quaternionMsgToOgre(const geometry_msgs::Quaternion &m)
static void quaternionOgreToMsg(const Ogre::Quaternion &o, geometry_msgs::Quaternion &m)
static Ogre::Vector3 vector3MsgToOgre(const geometry_msgs::Vector3 &m)


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat Apr 27 2019 02:33:41