msg_conversions.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 #ifndef MSG_CONVERSIONS_H
00030 #define MSG_CONVERSIONS_H
00031 
00032 #include "OgreVector3.h"
00033 #include "OgreQuaternion.h"
00034 
00035 #include <geometry_msgs/Point.h>
00036 #include <geometry_msgs/Vector3.h>
00037 #include <geometry_msgs/Quaternion.h>
00038 
00039 namespace rviz {
00040 
00041 // This file contains some convenience functions for Ogre / geometry_msgs conversions.
00042 
00043 // pointMsgToOgre  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00044 static inline Ogre::Vector3 pointMsgToOgre(const geometry_msgs::Point& m)
00045 {
00046   return Ogre::Vector3(m.x, m.y, m.z);
00047 }
00048 
00049 static inline void pointMsgToOgre(const geometry_msgs::Point &m, Ogre::Vector3& o)
00050 {
00051   o.x = m.x; o.y = m.y; o.z = m.z;
00052 }
00053 
00054 // vector3MsgToOgre  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00055 static inline Ogre::Vector3 vector3MsgToOgre(const geometry_msgs::Vector3& m)
00056 {
00057   return Ogre::Vector3(m.x, m.y, m.z);
00058 }
00059 
00060 
00061 static inline void vector3MsgToOgre(const geometry_msgs::Vector3 &m, Ogre::Vector3& o)
00062 {
00063   o.x = m.x; o.y = m.y; o.z = m.z;
00064 }
00065 
00066 // quaternionMsgToOgre  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00067 static inline Ogre::Quaternion quaternionMsgToOgre(const geometry_msgs::Quaternion& m)
00068 {
00069   return Ogre::Quaternion(m.w, m.x, m.y, m.z);
00070 }
00071 
00072 static inline void quaternionMsgToOgre(const geometry_msgs::Quaternion &m, Ogre::Quaternion& o)
00073 {
00074   o.w = m.w; o.x = m.x; o.y = m.y; o.z = m.z;
00075 }
00076 
00077 // pointOgreToMsg  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00078 static inline void pointOgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Point &m)
00079 {
00080   m.x = o.x; m.y = o.y; m.z = o.z;
00081 }
00082 
00083 static inline geometry_msgs::Point pointOgreToMsg(const Ogre::Vector3 &o)
00084 {
00085   geometry_msgs::Point m;
00086   pointOgreToMsg(o, m);
00087   return m;
00088 }
00089 
00090 // vectorOgreToMsg  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00091 static inline void vector3OgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Vector3 &m)
00092 {
00093   m.x = o.x; m.y = o.y; m.z = o.z;
00094 }
00095 
00096 static inline geometry_msgs::Vector3 vector3OgreToMsg(const Ogre::Vector3 &o)
00097 {
00098   geometry_msgs::Vector3 m;
00099   vector3OgreToMsg(o, m);
00100   return m;
00101 }
00102 
00103 // quaternionOgreToMsg  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
00104 static inline void quaternionOgreToMsg(const Ogre::Quaternion &o, geometry_msgs::Quaternion &m)
00105 {
00106   m.w = o.w; m.x = o.x; m.y = o.y; m.z = o.z;
00107 }
00108 
00109 static inline geometry_msgs::Quaternion quaternionOgreToMsg(const Ogre::Quaternion &o)
00110 {
00111   geometry_msgs::Quaternion m;
00112   quaternionOgreToMsg(o, m);
00113   return m;
00114 }
00115 
00116 
00117 } // namespace rviz
00118 
00119 #endif


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:31