MapDisplay.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  * MapDisplay.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 MAP_DISPLAY_HPP
50 #define MAP_DISPLAY_HPP
51 
52 #include <Types.hpp>
53 #include "RvizFileProperty.hpp"
54 
55 #include <vector>
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 #include <map>
66 
67 #include <QMessageBox>
68 #include <QApplication>
69 #include <QIcon>
70 #include <QString>
71 
72 #include <ros/ros.h>
73 #include <ros/console.h>
77 #include <rviz/geometry.h>
78 
79 #include <rviz/display_context.h>
80 #include <rviz/frame_manager.h>
81 #include <rviz/display.h>
82 #include <rviz/config.h>
83 
84 #include <rviz/tool.h>
85 #include <rviz/tool_manager.h>
86 #include <rviz/display_group.h>
87 
88 #include <std_msgs/Int32.h>
89 #include <geometry_msgs/Point32.h>
90 #include <geometry_msgs/PoseStamped.h>
91 #include <mesh_msgs/MeshGeometryStamped.h>
92 #include <mesh_msgs/MeshGeometry.h>
93 #include <mesh_msgs/GetGeometry.h>
94 #include <mesh_msgs/GetLabeledClusters.h>
95 
97 
98 #ifndef Q_MOC_RUN
99 #include <rviz/mesh_loader.h>
100 
101 #include <OGRE/OgreManualObject.h>
102 #include <OGRE/OgreSceneNode.h>
103 #include <OGRE/OgreSceneManager.h>
104 #include <OGRE/OgreEntity.h>
105 #include <OGRE/OgreStringConverter.h>
106 #include <OGRE/OgreMaterialManager.h>
107 #include <OGRE/OgreRay.h>
108 #include <OGRE/OgreSceneQuery.h>
109 #include <OGRE/OgreColourValue.h>
110 
111 #endif
112 
113 #include <ClusterLabelDisplay.hpp>
114 #include <MeshDisplay.hpp>
115 
116 namespace rviz
117 {
118 // Forward declaration
119 class BoolProperty;
120 class ColorProperty;
121 class FloatProperty;
122 class IntProperty;
123 class EnumProperty;
124 class StringProperty;
125 
126 } // End namespace rviz
127 
128 namespace rviz_map_plugin
129 {
130 using std::shared_ptr;
131 using std::string;
132 using std::unique_ptr;
133 using std::vector;
134 
139 class MapDisplay : public rviz::Display
140 {
141  Q_OBJECT
142 
143 public:
147  MapDisplay();
148 
152  ~MapDisplay();
153 
154  virtual void load(const rviz::Config& config);
155 
156 public Q_SLOTS:
157 
162  void saveLabel(Cluster cluster);
163 
168  shared_ptr<Geometry> getGeometry();
169 
170 private Q_SLOTS:
171 
175  void updateMap();
176 
177 private:
181  void onInitialize();
182 
186  void onEnable();
187 
191  void onDisable();
192 
197  bool loadData();
198 
199  // TODO: make more efficient - currently everything is stored in the MapDisplay, the MeshDisplay and the MeshVisual
201  shared_ptr<Geometry> m_geometry;
203  vector<Material> m_materials;
205  vector<Texture> m_textures;
207  vector<Color> m_colors;
209  vector<Normal> m_normals;
211  vector<TexCoords> m_texCoords;
213  vector<Cluster> m_clusterList;
214 
215  std::map<std::string, std::vector<float>> m_costs;
216 
217  std::shared_ptr<ros::NodeHandle> m_nh;
218  std::shared_ptr<ros::NodeHandle> m_nh_p;
219 
222  std::string m_map_file_loaded;
223 
228 
234  rviz::Display* createDisplay(const QString& class_id);
235 };
236 
237 } // end namespace rviz_map_plugin
238 
239 #endif
hdf5_map_io.h
rviz_map_plugin::MapDisplay::m_mapFilePath
rviz::FileProperty * m_mapFilePath
Path to map file.
Definition: MapDisplay.hpp:221
display_group.h
mesh_loader.h
config.h
rviz_map_plugin::MapDisplay::updateMap
void updateMap()
Update the map, based on the current data state.
Definition: MapDisplay.cpp:178
rviz_map_plugin::MapDisplay::m_nh_p
std::shared_ptr< ros::NodeHandle > m_nh_p
Definition: MapDisplay.hpp:218
ros.h
rviz_map_plugin::MapDisplay::m_colors
vector< Color > m_colors
Colors.
Definition: MapDisplay.hpp:207
frame_manager.h
ClusterLabelDisplay.hpp
viewport_mouse_event.h
rviz_map_plugin::MapDisplay::getGeometry
shared_ptr< Geometry > getGeometry()
Get the geometry.
Definition: MapDisplay.cpp:84
display.h
rviz_map_plugin::MapDisplay::~MapDisplay
~MapDisplay()
Destructor.
Definition: MapDisplay.cpp:77
rviz_map_plugin::MapDisplay::m_textures
vector< Texture > m_textures
Textures.
Definition: MapDisplay.hpp:205
rviz_map_plugin::MapDisplay::m_materials
vector< Material > m_materials
Materials.
Definition: MapDisplay.hpp:203
visualization_manager.h
rviz_map_plugin::MapDisplay::MapDisplay
MapDisplay()
Constructor.
Definition: MapDisplay.cpp:71
rviz::Display
tool_manager.h
rviz_map_plugin::MapDisplay::m_normals
vector< Normal > m_normals
Vertex normals.
Definition: MapDisplay.hpp:209
rviz_map_plugin::ClusterLabelDisplay
Display class for the map plugin.
Definition: ClusterLabelDisplay.hpp:136
console.h
rviz_map_plugin::MapDisplay::m_meshDisplay
rviz_map_plugin::MeshDisplay * m_meshDisplay
Subdisplay: MeshDisplay (for showing the mesh)
Definition: MapDisplay.hpp:227
rviz_map_plugin::MapDisplay::m_clusterLabelDisplay
rviz_map_plugin::ClusterLabelDisplay * m_clusterLabelDisplay
Subdisplay: ClusterLabel (for showing the clusters)
Definition: MapDisplay.hpp:225
rviz_map_plugin::MapDisplay::m_geometry
shared_ptr< Geometry > m_geometry
Geometry.
Definition: MapDisplay.hpp:201
rviz
rviz_map_plugin::MapDisplay::m_costs
std::map< std::string, std::vector< float > > m_costs
Definition: MapDisplay.hpp:215
visualization_frame.h
rviz_map_plugin::MapDisplay::createDisplay
rviz::Display * createDisplay(const QString &class_id)
Create a RViz display from it's unique class_id.
Definition: MapDisplay.cpp:96
MeshDisplay.hpp
rviz::FileProperty
Definition: RvizFileProperty.hpp:56
rviz_map_plugin::MapDisplay::m_texCoords
vector< TexCoords > m_texCoords
Texture coordinates.
Definition: MapDisplay.hpp:211
Types.hpp
rviz_map_plugin::MapDisplay::onEnable
void onEnable()
RViz callback on enable.
Definition: MapDisplay.cpp:138
RvizFileProperty.hpp
rviz_map_plugin::MapDisplay::load
virtual void load(const rviz::Config &config)
Definition: MapDisplay.cpp:153
rviz_map_plugin::MapDisplay::onDisable
void onDisable()
RViz callback on disable.
Definition: MapDisplay.cpp:144
geometry.h
rviz_map_plugin::MeshDisplay
Display for showing the mesh in different modes.
Definition: MeshDisplay.hpp:128
rviz_map_plugin
Definition: ClusterLabelDisplay.hpp:120
rviz_map_plugin::MapDisplay::saveLabel
void saveLabel(Cluster cluster)
Saves a label to HDF5.
Definition: MapDisplay.cpp:456
rviz_map_plugin::MapDisplay::m_clusterList
vector< Cluster > m_clusterList
Clusters.
Definition: MapDisplay.hpp:213
rviz_map_plugin::MapDisplay::onInitialize
void onInitialize()
RViz callback on initialize.
Definition: MapDisplay.cpp:108
config
config
rviz_map_plugin::MapDisplay
Master display for the Mesh- and Cluster- subdisplays. THis implementation uses HDF5 as it's data sou...
Definition: MapDisplay.hpp:139
rviz_map_plugin::Cluster
Struct for clusters.
Definition: Types.hpp:87
rviz_map_plugin::MapDisplay::m_nh
std::shared_ptr< ros::NodeHandle > m_nh
Definition: MapDisplay.hpp:217
tool.h
rviz::Config
rviz_map_plugin::MapDisplay::loadData
bool loadData()
Read all data from the HDF5 file and save it in the member variables.
Definition: MapDisplay.cpp:217
rviz_map_plugin::MapDisplay::m_map_file_loaded
std::string m_map_file_loaded
Definition: MapDisplay.hpp:222
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