marker_with_covariance_visual.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/OgreVector3.h>
33 #include <OGRE/OgreSceneNode.h>
34 #include <OGRE/OgreSceneManager.h>
35 #include <OGRE/OgreEntity.h>
36 
37 #include "rviz/ogre_helpers/axes.h"
38 
40 
41 namespace marker_rviz_plugin {
42 
43  MarkerWithCovarianceVisual::MarkerWithCovarianceVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node) {
44  scene_manager_ = scene_manager;
45  frame_node_ = parent_node->createChildSceneNode();
46 
47  _showAxes = true;
48  _showMarker = true;
49  _showLabel = true;
50  _scale = 1;
51  }
52 
54  // Destroy the frame node since we don't need it anymore.
55  scene_manager_->destroySceneNode(frame_node_);
56  }
57 
58  void MarkerWithCovarianceVisual::setMessage(const marker_msgs::MarkerWithCovarianceStamped::ConstPtr &msg) {
59  marker_msgs::MarkerWithCovariance marker_cov = msg->marker;
60  marker_msgs::Marker marker = marker_cov.marker;
61 
62  double p_x = marker.pose.position.x;
63  double p_y = marker.pose.position.y;
64  double p_z = marker.pose.position.z;
65  double o_x = marker.pose.orientation.x;
66  double o_y = marker.pose.orientation.y;
67  double o_z = marker.pose.orientation.z;
68  double o_w = marker.pose.orientation.w;
69 
70  int id = -1;
71  if (marker.ids.size() > 0)
72  id = marker.ids[0];
73 
75  m->setPosition(Ogre::Vector3(p_x, p_y, p_z));
76  m->setOrientation(Ogre::Quaternion(o_w, o_x, o_y, o_z));
77  m->setShowMarker(_showMarker);
78  m->setShowAxes(_showAxes);
79  m->setShowLabel(_showLabel);
80  m->setScale(Ogre::Vector3(_scale, _scale, _scale));
81  m->setCovarianceMatrix(msg->marker.covariance);
82  _marker.reset(m);
83  }
84 
85  void MarkerWithCovarianceVisual::setFramePosition(const Ogre::Vector3 &position) {
86  frame_node_->setPosition(position);
87  }
88 
89  void MarkerWithCovarianceVisual::setFrameOrientation(const Ogre::Quaternion &orientation) {
90  frame_node_->setOrientation(orientation);
91  }
92 
94  _marker->setShowAxes(showAxes);
95  _showAxes = showAxes;
96  }
97 
99  _marker->setShowMarker(showMarker);
100  _showMarker = showMarker;
101  }
102 
104  _marker->setShowLabel(showLabel);
105  _showLabel = showLabel;
106  }
107 
109  _marker->setScale(Ogre::Vector3(scale, scale, scale));
110  _scale = scale;
111  }
112 
113 }
void setMessage(const marker_msgs::MarkerWithCovarianceStamped::ConstPtr &msg)
MarkerWithCovarianceVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
void setFrameOrientation(const Ogre::Quaternion &orientation)
virtual void setPosition(const Ogre::Vector3 &position)
Definition: marker.cpp:137


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