ObjectDetectionDoorVisual.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 ObjectDetectionDoorVisual::ObjectDetectionDoorVisual(Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node) : ObjectDetectionVisual(scene_manager, parent_node)
43 {
46 }
47 
49 {
50  // empty destructor since parent destructor destroys frame node anyway
51 }
52 
53 void ObjectDetectionDoorVisual::setMessage(const tuw_object_msgs::ObjectWithCovariance::ConstPtr& msg)
54 {
55  // call parent class set Message to also display covariance, center, ids
57 
58  Ogre::Vector3 position = Ogre::Vector3(msg->object.pose.position.x, msg->object.pose.position.y, msg->object.pose.position.z);
59 
60  position = transform_ * position;
61  position.z = 0; // fix on ground z=0
62 
63  Ogre::Quaternion orientation = Ogre::Quaternion(msg->object.pose.orientation.w, msg->object.pose.orientation.x,
64  msg->object.pose.orientation.y, msg->object.pose.orientation.z);
65  double width = msg->object.shape_variables[DoorObjectShapeVariables::width];
66  double height = msg->object.shape_variables[DoorObjectShapeVariables::height];
67  double d_angle = msg->object.shape_variables[DoorObjectShapeVariables::angle_d];
68  bool clock_wise = ((int) msg->object.shape_variables[DoorObjectShapeVariables::clockwise] == 0) ? true : false;
69  door_visual_->setWidth(width);
70  door_visual_->setHeight(height);
71  door_visual_->setOpeningAngle(d_angle, clock_wise);
72  Ogre::Quaternion rotation_local_q;
73  rotation_local_q.FromRotationMatrix(door_visual_->getRotationMat());
74  orientation = transform_.extractQuaternion() * orientation * rotation_local_q;
75  door_visual_->setPosition(position);
76  door_visual_->setOrientation(orientation);
78  if (dv_bb)
79  {
80  dv_bb->generateWireframe();
81  }
83  if (base_f_bb)
84  {
85  base_f_bb->generateBaseframe();
86  }
87 }
88 
89 // Color is passed through to the pose Shape object.
90 void ObjectDetectionDoorVisual::setColor(Ogre::ColourValue color)
91 {
93  door_visual_->setColor(color);
94 }
95 
97 {
98  Ogre::Vector3 position;
99  Ogre::Quaternion orientation;
100  Ogre::ColourValue color;
102 
103  position = door_visual_->getPosition();
104  orientation = door_visual_->getOrientation();
105  color = door_visual_->getColor();
106 
107  switch (style)
108  {
110  door_visual_.reset(new BoundingBoxDoorVisual(default_args));
111  break;
112  default:
113  break;
114  }
115 
116  door_visual_->setOrientation(orientation);
117  door_visual_->setPosition(position);
118  door_visual_->setColor(color);
119 
120 }
121 
122 } // end namespace tuw_object_rviz
Visualization of a person as a wireframe bounding box.
Definition: DoorVisual.h:87
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)
ObjectDetectionDoorVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
Styles
Visualization style for an object.
Definition: common.h:40


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