ClusterLabelDisplay.hpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Robot Operating System code by the University of Osnabrück
5  * Copyright (c) 2015, University of Osnabrück
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  *
21  * 3. Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
30  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  *
39  *
40  * ClusterLabelDisplay.hpp
41  *
42  *
43  * authors:
44  *
45  * Kristin Schmidt <krschmidt@uni-osnabrueck.de>
46  * Jan Philipp Vogtherr <jvogtherr@uni-osnabrueck.de>
47  */
48 
49 #ifndef CLUSTER_LABEL_DISPLAY_HPP
50 #define CLUSTER_LABEL_DISPLAY_HPP
51 
52 #include <Types.hpp>
53 
54 #include <vector>
55 #include <map>
56 #include <memory>
57 #include <boost/lexical_cast.hpp>
58 #include <boost/shared_ptr.hpp>
59 #include <boost/filesystem.hpp>
60 #include <boost/algorithm/string.hpp>
61 
62 #include <string>
63 #include <math.h>
64 #include <algorithm>
65 
66 #include <QMessageBox>
67 #include <QApplication>
68 #include <QIcon>
69 
70 #include <ros/ros.h>
71 #include <ros/console.h>
75 #include <rviz/geometry.h>
76 
77 #include <rviz/display_context.h>
78 #include <rviz/frame_manager.h>
79 #include <rviz/display.h>
80 
81 #include <rviz/tool.h>
82 #include <rviz/tool_manager.h>
83 #include <rviz/display_group.h>
84 
85 #include <std_msgs/Int32.h>
86 #include <geometry_msgs/Point32.h>
87 #include <geometry_msgs/PoseStamped.h>
88 #include <mesh_msgs/MeshGeometryStamped.h>
89 #include <mesh_msgs/MeshGeometry.h>
90 #include <mesh_msgs/GetGeometry.h>
91 #include <mesh_msgs/GetLabeledClusters.h>
92 
93 #ifndef Q_MOC_RUN
94 #include <rviz/mesh_loader.h>
95 
96 #include <OGRE/OgreManualObject.h>
97 #include <OGRE/OgreSceneNode.h>
98 #include <OGRE/OgreSceneManager.h>
99 #include <OGRE/OgreEntity.h>
100 #include <OGRE/OgreStringConverter.h>
101 #include <OGRE/OgreMaterialManager.h>
102 #include <OGRE/OgreRay.h>
103 #include <OGRE/OgreSceneQuery.h>
104 #include <OGRE/OgreColourValue.h>
105 
106 #endif
107 
108 namespace rviz
109 {
110 // Forward declaration
111 class BoolProperty;
112 class ColorProperty;
113 class FloatProperty;
114 class IntProperty;
115 class EnumProperty;
116 class StringProperty;
117 
118 } // End namespace rviz
119 
121 {
122 using std::map;
123 using std::shared_ptr;
124 using std::string;
125 using std::unique_ptr;
126 using std::vector;
127 
128 // Forward declaration
129 class ClusterLabelVisual;
130 class ClusterLabelTool;
131 
137 {
138  Q_OBJECT
139 
140 public:
145 
150 
157  void addLabel(string label, vector<uint32_t> faces);
158 
162  void onEnable();
163 
167  void onDisable();
168 
169 Q_SIGNALS:
170 
175  void signalAddLabel(Cluster cluster);
176 
177 public Q_SLOTS: // not sure wether any of those actually need to be q slots ...
178 
182  void notifyLabelTool();
183 
188  shared_ptr<Geometry> getGeometry();
189 
195  void setData(shared_ptr<Geometry> geometry, vector<Cluster> clusters);
196 
197 private Q_SLOTS:
198 
202  void updateMap();
203 
207  void updateColors();
208 
212  void updateSphereSize();
213 
217  void updatePhantomVisual();
218 
222  void changeVisual();
223 
224 private:
228  void onInitialize();
229 
233  void initializeLabelTool();
234 
239 
243  void createPhantomVisual();
244 
248  void fillPropertyOptions();
249 
251  shared_ptr<Geometry> m_geometry;
252 
254  vector<shared_ptr<ClusterLabelVisual>> m_visuals;
255 
257  uint32_t m_activeVisualId = 0;
258 
260  unique_ptr<ClusterLabelVisual> m_phantomVisual;
261 
263  vector<Cluster> m_clusterList;
264 
267 
270 
273 
276 
278  std::vector<rviz::ColorProperty*> m_colorProperties;
279 
282 
285 
288 
290  bool has_data = false;
291 };
292 
293 } // end namespace rviz_map_plugin
294 
295 #endif
rviz_map_plugin::ClusterLabelDisplay::onInitialize
void onInitialize()
RViz callback on initialize.
Definition: ClusterLabelDisplay.cpp:158
rviz_map_plugin::ClusterLabelTool
Tool for selecting faces.
Definition: ClusterLabelTool.hpp:125
rviz_map_plugin::ClusterLabelDisplay::onDisable
void onDisable()
RViz callback on disable.
Definition: ClusterLabelDisplay.cpp:169
rviz_map_plugin::ClusterLabelDisplay::has_data
bool has_data
A variable that will be set to true, once the initial data has arrived.
Definition: ClusterLabelDisplay.hpp:290
display_group.h
mesh_loader.h
rviz_map_plugin::ClusterLabelDisplay::~ClusterLabelDisplay
~ClusterLabelDisplay()
Destructor.
Definition: ClusterLabelDisplay.cpp:116
rviz_map_plugin::ClusterLabelDisplay::onEnable
void onEnable()
RViz callback on enable.
Definition: ClusterLabelDisplay.cpp:164
ros.h
rviz::BoolProperty
frame_manager.h
rviz_map_plugin::ClusterLabelDisplay::getGeometry
shared_ptr< Geometry > getGeometry()
Getter for the current geometry.
Definition: ClusterLabelDisplay.cpp:123
viewport_mouse_event.h
display.h
rviz_map_plugin::ClusterLabelDisplay::m_activeVisualId
uint32_t m_activeVisualId
ID of the current active visual.
Definition: ClusterLabelDisplay.hpp:257
rviz_map_plugin::ClusterLabelDisplay::m_sphereSizeProperty
rviz::FloatProperty * m_sphereSizeProperty
Property to set the brushsize of the sphere brush of the label tool from this package.
Definition: ClusterLabelDisplay.hpp:281
rviz_map_plugin::ClusterLabelDisplay::m_tool
ClusterLabelTool * m_tool
Label tool.
Definition: ClusterLabelDisplay.hpp:266
visualization_manager.h
rviz::Display
rviz::EnumProperty
rviz::FloatProperty
tool_manager.h
rviz::Property
rviz_map_plugin::ClusterLabelDisplay
Display class for the map plugin.
Definition: ClusterLabelDisplay.hpp:136
rviz_map_plugin::ClusterLabelDisplay::fillPropertyOptions
void fillPropertyOptions()
Dynamically fills the dropdown menus of those properties.
Definition: ClusterLabelDisplay.cpp:256
rviz_map_plugin::ClusterLabelDisplay::signalAddLabel
void signalAddLabel(Cluster cluster)
This signal is used for delegating new label data to the master display.
console.h
rviz_map_plugin::ClusterLabelDisplay::notifyLabelTool
void notifyLabelTool()
Refreshes the tool's current visual.
Definition: ClusterLabelDisplay.cpp:340
rviz_map_plugin::ClusterLabelDisplay::m_colorsProperty
rviz::Property * m_colorsProperty
Property for selecting colors (menu)
Definition: ClusterLabelDisplay.hpp:275
rviz_map_plugin::ClusterLabelDisplay::addLabel
void addLabel(string label, vector< uint32_t > faces)
The tool will call this function and emit the signal below to the master display to create the label.
Definition: ClusterLabelDisplay.cpp:345
rviz
rviz_map_plugin::ClusterLabelDisplay::m_visuals
vector< shared_ptr< ClusterLabelVisual > > m_visuals
Visuals.
Definition: ClusterLabelDisplay.hpp:254
rviz_map_plugin::ClusterLabelDisplay::m_labelToolVisualIndex
int m_labelToolVisualIndex
Index for the visuals.
Definition: ClusterLabelDisplay.hpp:287
visualization_frame.h
rviz_map_plugin::ClusterLabelDisplay::updateSphereSize
void updateSphereSize()
Updates the sphere size for the brush tool.
Definition: ClusterLabelDisplay.cpp:239
rviz_map_plugin::ClusterLabelDisplay::updateMap
void updateMap()
Update the map, based on newly loaded data since the last update.
Definition: ClusterLabelDisplay.cpp:195
rviz_map_plugin::ClusterLabelDisplay::createVisualsFromClusterList
void createVisualsFromClusterList()
Create visuals for each cluster in the list.
Definition: ClusterLabelDisplay.cpp:280
rviz_map_plugin::ClusterLabelDisplay::setData
void setData(shared_ptr< Geometry > geometry, vector< Cluster > clusters)
Setter for the geometry and cluster data.
Definition: ClusterLabelDisplay.cpp:132
rviz_map_plugin::ClusterLabelDisplay::ClusterLabelDisplay
ClusterLabelDisplay()
Constructor.
Definition: ClusterLabelDisplay.cpp:92
Types.hpp
rviz_map_plugin::ClusterLabelDisplay::m_phantomVisual
unique_ptr< ClusterLabelVisual > m_phantomVisual
Additional visual to help with labeling without a TexturedMesh.
Definition: ClusterLabelDisplay.hpp:260
rviz_map_plugin::ClusterLabelDisplay::m_phantomVisualProperty
rviz::BoolProperty * m_phantomVisualProperty
Property to hide or show a phantom visual.
Definition: ClusterLabelDisplay.hpp:284
rviz_map_plugin::ClusterLabelVisual
Visual to show a labeled cluster.
Definition: ClusterLabelVisual.hpp:80
rviz_map_plugin::ClusterLabelDisplay::m_activeVisualProperty
rviz::EnumProperty * m_activeVisualProperty
Property for the current active visual.
Definition: ClusterLabelDisplay.hpp:269
geometry.h
rviz_map_plugin::ClusterLabelDisplay::updateColors
void updateColors()
Updates the colors, based on newly loaded data since the last update.
Definition: ClusterLabelDisplay.cpp:230
rviz_map_plugin::ClusterLabelDisplay::createPhantomVisual
void createPhantomVisual()
Creates a phantom visual.
Definition: ClusterLabelDisplay.cpp:303
rviz_map_plugin
Definition: ClusterLabelDisplay.hpp:120
rviz_map_plugin::ClusterLabelDisplay::updatePhantomVisual
void updatePhantomVisual()
Updates the phantom visual, based on newly loaded data since the last update.
Definition: ClusterLabelDisplay.cpp:244
rviz_map_plugin::ClusterLabelDisplay::m_colorProperties
std::vector< rviz::ColorProperty * > m_colorProperties
Properties for selecting colors (menu-items)
Definition: ClusterLabelDisplay.hpp:278
rviz_map_plugin::ClusterLabelDisplay::m_clusterList
vector< Cluster > m_clusterList
Cluster data.
Definition: ClusterLabelDisplay.hpp:263
rviz_map_plugin::ClusterLabelDisplay::m_geometry
shared_ptr< Geometry > m_geometry
Geometry.
Definition: ClusterLabelDisplay.hpp:251
rviz_map_plugin::Cluster
Struct for clusters.
Definition: Types.hpp:87
rviz_map_plugin::ClusterLabelDisplay::m_alphaProperty
rviz::FloatProperty * m_alphaProperty
Property to set transparency.
Definition: ClusterLabelDisplay.hpp:272
tool.h
rviz_map_plugin::ClusterLabelDisplay::changeVisual
void changeVisual()
Slot for changing the visual to the selected visual from the dropdown menu.
Definition: ClusterLabelDisplay.cpp:179
rviz_map_plugin::ClusterLabelDisplay::initializeLabelTool
void initializeLabelTool()
Programmatically create an instance of the label tool from this package.
Definition: ClusterLabelDisplay.cpp:318
display_context.h


rviz_map_plugin
Author(s): Sebastian Pütz , Kristin Schmidt , Jan Philipp Vogtherr , Malte kleine Piening
autogenerated on Sun Jan 21 2024 04:06:25