ObjectDetectionPersonVisual.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2017 by Florian Beck <florian.beck@tuwien.ac.at> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
33 #include <OGRE/OgreVector3.h>
34 #include <OGRE/OgreMatrix3.h>
35 #include <OGRE/OgreSceneNode.h>
36 #include <OGRE/OgreSceneManager.h>
37 
39 
40 namespace tuw_object_rviz
41 {
42 ObjectDetectionPersonVisual::ObjectDetectionPersonVisual(Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node) : ObjectDetectionVisual(scene_manager, parent_node)
43 {
45 }
46 
48 {
49  // empty destructor since parent destructor destroys frame node anyway
50 }
51 
52 void ObjectDetectionPersonVisual::setMessage(const tuw_object_msgs::ObjectWithCovariance::ConstPtr& msg)
53 {
54  // call parent class set Message to also display covariance, center, ids
56 
57  Ogre::Vector3 position = Ogre::Vector3(msg->object.pose.position.x, msg->object.pose.position.y, msg->object.pose.position.z);
58  position = transform_ * position;
59  position.z = 0; // fix on ground z=0
60 
61  Ogre::Quaternion orientation = Ogre::Quaternion(msg->object.pose.orientation.w, msg->object.pose.orientation.x,
62  msg->object.pose.orientation.y, msg->object.pose.orientation.z);
63 
64  person_visual_->setPosition(position + Ogre::Vector3(0, 0, person_visual_->getHeight() / 2));
65  person_visual_->setOrientation(orientation);
66 }
67 
68 // Color is passed through to the pose Shape object.
69 void ObjectDetectionPersonVisual::setColor(Ogre::ColourValue color)
70 {
72  person_visual_->setColor(color);
73 }
74 
76 {
77  Ogre::Vector3 position;
78  Ogre::Quaternion orientation;
79  Ogre::ColourValue color;
81 
82  position = person_visual_->getPosition();
83  orientation = person_visual_->getOrientation();
84  color = person_visual_->getColor();
85 
86  switch (style)
87  {
88  case STYLE_SIMPLE:
89  person_visual_->setVisible(false);
90  break;
91  case STYLE_CYLINDER:
92  person_visual_.reset(new CylinderPersonVisual(default_args));
93  break;
95  person_visual_.reset(new MeshPersonVisual(default_args));
96  break;
98  person_visual_.reset(new BoundingBoxPersonVisual(default_args));
99  break;
100  }
101 
102  person_visual_->setOrientation(orientation);
103  person_visual_->setPosition(position);
104  person_visual_->setColor(color);
105 
106 }
107 
108 } // end namespace tuw_object_rviz
Visualization of a person as a mesh (walking human)
Definition: PersonVisual.h:161
virtual void setColor(Ogre::ColourValue color)
virtual void setMessage(const tuw_object_msgs::ObjectWithCovariance::ConstPtr &msg)
void setMessage(const tuw_object_msgs::ObjectWithCovariance::ConstPtr &msg)
Visualization of a person as a wireframe bounding box.
Definition: PersonVisual.h:133
Styles
Visualization style for an object.
Definition: common.h:40
ObjectDetectionPersonVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
Visualization of a person as cylinder (body) + sphere (head)
Definition: PersonVisual.h:116


tuw_object_rviz
Author(s): Florian Beck
autogenerated on Mon Jun 10 2019 15:40:17