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;
52  o.y = m.y;
53  o.z = m.z;
54 }
55 
56 // vector3MsgToOgre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
57 static inline Ogre::Vector3 vector3MsgToOgre(const geometry_msgs::Vector3& m)
58 {
59  return Ogre::Vector3(m.x, m.y, m.z);
60 }
61 
62 
63 static inline void vector3MsgToOgre(const geometry_msgs::Vector3& m, Ogre::Vector3& o)
64 {
65  o.x = m.x;
66  o.y = m.y;
67  o.z = m.z;
68 }
69 
70 // quaternionMsgToOgre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
71 static inline Ogre::Quaternion quaternionMsgToOgre(const geometry_msgs::Quaternion& m)
72 {
73  return Ogre::Quaternion(m.w, m.x, m.y, m.z);
74 }
75 
76 static inline void quaternionMsgToOgre(const geometry_msgs::Quaternion& m, Ogre::Quaternion& o)
77 {
78  o.w = m.w;
79  o.x = m.x;
80  o.y = m.y;
81  o.z = m.z;
82 }
83 
84 // pointOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
85 static inline void pointOgreToMsg(const Ogre::Vector3& o, geometry_msgs::Point& m)
86 {
87  m.x = o.x;
88  m.y = o.y;
89  m.z = o.z;
90 }
91 
92 static inline geometry_msgs::Point pointOgreToMsg(const Ogre::Vector3& o)
93 {
94  geometry_msgs::Point m;
95  pointOgreToMsg(o, m);
96  return m;
97 }
98 
99 // vectorOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
100 static inline void vector3OgreToMsg(const Ogre::Vector3& o, geometry_msgs::Vector3& m)
101 {
102  m.x = o.x;
103  m.y = o.y;
104  m.z = o.z;
105 }
106 
107 static inline geometry_msgs::Vector3 vector3OgreToMsg(const Ogre::Vector3& o)
108 {
109  geometry_msgs::Vector3 m;
110  vector3OgreToMsg(o, m);
111  return m;
112 }
113 
114 // quaternionOgreToMsg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
115 static inline void quaternionOgreToMsg(const Ogre::Quaternion& o, geometry_msgs::Quaternion& m)
116 {
117  m.w = o.w;
118  m.x = o.x;
119  m.y = o.y;
120  m.z = o.z;
121 }
122 
123 static inline geometry_msgs::Quaternion quaternionOgreToMsg(const Ogre::Quaternion& o)
124 {
125  geometry_msgs::Quaternion m;
126  quaternionOgreToMsg(o, m);
127  return m;
128 }
129 
130 
131 } // namespace rviz
132 
133 #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 May 27 2023 02:06:24