marker_with_covariance_array_display.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Lukas Pfeifhofer <lukas.pfeifhofer@devlabs.pro>
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  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #include <OGRE/OgreManualObject.h>
33 #include <OGRE/OgreEntity.h>
34 #include <OGRE/OgreMeshManager.h>
35 #include <OGRE/OgreSceneNode.h>
36 #include <OGRE/OgreSceneManager.h>
37 
38 #include <ros/package.h>
39 
40 #include <tf/transform_listener.h>
41 
47 #include <rviz/frame_manager.h>
48 #include "rviz/ogre_helpers/axes.h"
49 
52 
53 namespace marker_rviz_plugin {
54 
56 
57  _showAxesProperty = new rviz::BoolProperty("Show Axes", true, "Show or hide axes.", this, SLOT (updateVisual()));
58  _showMarkerProperty = new rviz::BoolProperty("Show Marker", false, "Show or hide marker image.", this, SLOT (updateVisual()));
59  _showLabelProperty = new rviz::BoolProperty("Show Label", true, "Show or hide marker label.", this, SLOT (updateVisual()));
60 
61  _markerSizeProperty = new rviz::FloatProperty("Marker Size", 0.3, "Size of the marker image.", this, SLOT (updateVisual()));
63 
64  // Add the plugin media folder to the Ogre ResourceGroup so it is possible to access plugin textures later on
65  std::string rviz_path = ros::package::getPath(ROS_PACKAGE_NAME);
66  Ogre::ResourceGroupManager::getSingleton().addResourceLocation(rviz_path + "/media", "FileSystem", ROS_PACKAGE_NAME);
67  Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(ROS_PACKAGE_NAME);
68 
69  }
70 
73 
75  }
76 
78  }
79 
80 // Clear the ogre_visuals by deleting their objects.
83  }
84 
90  }
91 
92 // This is our callback to handle an incoming message.
93  void MarkerWithCovarianceArrayDisplay::processMessage(const marker_msgs::MarkerWithCovarianceArray::ConstPtr &msg) {
94 
95  // Here we call the rviz::FrameManager to get the transform from the
96  // fixed frame to the frame in the header of this Imu message. If
97  // it fails, we can't do anything else so we return.
98  Ogre::Quaternion orientation;
99  Ogre::Vector3 position;
100  if (!context_->getFrameManager()->getTransform(msg->header.frame_id, msg->header.stamp, position, orientation)) {
101  ROS_DEBUG ("Error transforming from frame '%s' to frame '%s'", msg->header.frame_id.c_str(), qPrintable(fixed_frame_));
102  return;
103  }
104 
105  // Now set or update the contents of the chosen visual.
106  _visual->setMessage(msg);
107  _visual->setFramePosition(position);
108  _visual->setFrameOrientation(orientation);
113 
115  }
116 
117 } // end namespace marker_rviz_plugin
118 
119 // Tell pluginlib about this class. It is important to do this in
120 // global scope, outside our package's namespace.
void processMessage(const marker_msgs::MarkerWithCovarianceArray::ConstPtr &msg)
void setMin(float min)
DisplayContext * context_
virtual float getFloat() const
Ogre::SceneNode * scene_node_
virtual bool getBool() const
QString fixed_frame_
virtual FrameManager * getFrameManager() const =0
ROSLIB_DECL std::string getPath(const std::string &package_name)
virtual Ogre::SceneManager * getSceneManager() const =0
virtual void queueRender()=0
bool getTransform(const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void setMessage(const marker_msgs::MarkerWithCovarianceArray::ConstPtr &msg)
#define ROS_DEBUG(...)


marker_rviz_plugin
Author(s): Markus Bader, Lukas Pfeifhofer, Markus Macsek
autogenerated on Mon Jun 10 2019 13:54:22