MeshDisplay.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  * MeshDisplay.hpp
41  *
42  *
43  * authors:
44  *
45  * Sebastian Pütz <spuetz@uni-osnabrueck.de>
46  * Henning Deeken <hdeeken@uni-osnabrueck.de>
47  * Marcel Mrozinski
48  * Nils Oesting
49  * Kristin Schmidt <krschmidt@uni-osnabrueck.de>
50  * Jan Philipp Vogtherr <jvogtherr@uni-osnabrueck.de>
51  * Malte kleine Piening <malte@klpiening.de>
52  */
53 
54 #ifndef MESH_DISPLAY_HPP
55 #define MESH_DISPLAY_HPP
56 
57 #include <Types.hpp>
58 #include <MeshVisual.hpp>
59 
60 #include <vector>
61 #include <memory>
62 #include <queue>
63 
64 #include <string>
65 #include <math.h>
66 #include <algorithm>
67 
68 #include <QMessageBox>
69 #include <QApplication>
70 #include <QIcon>
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 
83 #ifndef Q_MOC_RUN
86 #include <message_filters/cache.h>
87 
88 #include <tf2_ros/message_filter.h>
89 
90 #include <rviz/mesh_loader.h>
91 
92 #include <OGRE/OgreManualObject.h>
93 #include <OGRE/OgreSceneNode.h>
94 #include <OGRE/OgreSceneManager.h>
95 #include <OGRE/OgreStringConverter.h>
96 #include <OGRE/OgreMaterialManager.h>
97 #include <OGRE/OgreColourValue.h>
98 
99 #endif
100 
101 namespace rviz
102 {
103 // Forward declaration
104 class BoolProperty;
105 class ColorProperty;
106 class FloatProperty;
107 class IntProperty;
108 class RosTopicProperty;
109 class EnumProperty;
110 class StringProperty;
111 
112 } // End namespace rviz
113 
114 namespace rviz_map_plugin
115 {
116 using std::shared_ptr;
117 using std::string;
118 using std::unique_ptr;
119 using std::vector;
120 
121 // Forward declaration
122 class MeshVisual;
123 
129 {
130  Q_OBJECT
131 
132 public:
136  MeshDisplay();
137 
141  ~MeshDisplay();
142 
146  void onEnable();
147 
151  void onDisable();
152 
156  void subscribe();
157 
161  void unsubscribe();
162 
169  void ignoreIncomingMessages();
170 
175  void setGeometry(shared_ptr<Geometry> geometry);
176 
181  void setVertexColors(vector<Color>& vertexColors);
182 
186  void clearVertexCosts();
187 
193  void addVertexCosts(std::string costlayer, vector<float>& vertexCosts);
194 
199  void setVertexNormals(vector<Normal>& vertexNormals);
200 
206  void setMaterials(vector<Material>& materials, vector<TexCoords>& texCoords);
207 
213  void addTexture(Texture& texture, uint32_t textureIndex);
214 
220  void setPose(Ogre::Vector3& position, Ogre::Quaternion& orientation);
221 
222 private Q_SLOTS:
223 
227  void updateBufferSize();
228 
232  void updateMesh();
233 
237  void updateWireframe();
238 
242  void updateNormals();
243 
247  void updateNormalsColor();
248 
252  void updateNormalsSize();
253 
257  void updateVertexCosts();
258 
263 
267  void updateVertexCostsTopic();
268 
272  void updateTopic();
273 
278 
283 
284 private:
288  void onInitialize();
289 
293  void initialServiceCall();
294 
299  void processMessage(const mesh_msgs::MeshGeometryStamped::ConstPtr& meshMsg);
300 
305  void incomingGeometry(const mesh_msgs::MeshGeometryStamped::ConstPtr& meshMsg);
306 
311  void incomingVertexColors(const mesh_msgs::MeshVertexColorsStamped::ConstPtr& colorsStamped);
312 
317  void incomingVertexCosts(const mesh_msgs::MeshVertexCostsStamped::ConstPtr& costsStamped);
318 
323  void requestVertexColors(std::string uuid);
324 
329  void requestMaterials(std::string uuid);
330 
335  void cacheVertexCosts(std::string layer, const std::vector<float>& costs);
336 
341  std::shared_ptr<MeshVisual> getLatestVisual();
342 
347  std::shared_ptr<MeshVisual> addNewVisual();
348 
351 
354 
357 
360 
363 
366 
369 
372 
375 
378 
381 
384 
387 
390 
393 
396 
398  std::string m_lastUuid;
399 
401  std::queue<std::shared_ptr<MeshVisual>> m_visuals;
402 
405 
408 
411 
414 
417 
420 
423 
426 
429 
432 
435 
438 
441 
444 
447 
450 
453 
456 
459 
462 
465 
468 
471 
473  std::map<std::string, std::vector<float>> m_costCache;
474 };
475 
476 } // end namespace rviz_map_plugin
477 
478 #endif
rviz_map_plugin::MeshDisplay::m_costCache
std::map< std::string, std::vector< float > > m_costCache
Cache for received vertex cost messages.
Definition: MeshDisplay.hpp:473
rviz_map_plugin::MeshDisplay::m_costLowerLimit
rviz::FloatProperty * m_costLowerLimit
Property for setting the lower limit of cost display.
Definition: MeshDisplay.hpp:446
rviz_map_plugin::MeshDisplay::m_materialsClient
ros::ServiceClient m_materialsClient
Client to request the materials.
Definition: MeshDisplay.hpp:356
rviz_map_plugin::MeshDisplay::m_geometryClient
ros::ServiceClient m_geometryClient
Client to request the geometry.
Definition: MeshDisplay.hpp:365
rviz_map_plugin::MeshDisplay::updateVertexColorService
void updateVertexColorService()
Updates the vertex color service.
Definition: MeshDisplay.cpp:660
rviz_map_plugin::MeshDisplay::m_facesColor
rviz::ColorProperty * m_facesColor
Property to set faces color.
Definition: MeshDisplay.hpp:413
rviz_map_plugin::MeshDisplay::processMessage
void processMessage(const mesh_msgs::MeshGeometryStamped::ConstPtr &meshMsg)
Sets data for trianglemesh_visual and updates the mesh.
Definition: MeshDisplay.cpp:736
rviz::RosTopicProperty
rviz_map_plugin::MeshDisplay::addTexture
void addTexture(Texture &texture, uint32_t textureIndex)
Add a texture.
Definition: MeshDisplay.cpp:395
rviz_map_plugin::MeshDisplay::updateVertexColorsTopic
void updateVertexColorsTopic()
Updates the subscribed vertex colors topic.
Definition: MeshDisplay.cpp:595
tf2_ros::MessageFilter< mesh_msgs::MeshGeometryStamped >
rviz_map_plugin::MeshDisplay::setVertexColors
void setVertexColors(vector< Color > &vertexColors)
Set the vertex colors.
Definition: MeshDisplay.cpp:350
rviz_map_plugin::MeshDisplay::addVertexCosts
void addVertexCosts(std::string costlayer, vector< float > &vertexCosts)
Adds a vertex costlayer.
Definition: MeshDisplay.cpp:366
mesh_loader.h
rviz_map_plugin::MeshDisplay::initialServiceCall
void initialServiceCall()
initial service call for UUID & geometry
Definition: MeshDisplay.cpp:692
rviz_map_plugin::MeshDisplay::m_meshTopic
rviz::RosTopicProperty * m_meshTopic
Property to handle topic for meshMsg.
Definition: MeshDisplay.hpp:404
rviz_map_plugin::MeshDisplay::m_tfMeshFilter
tf2_ros::MessageFilter< mesh_msgs::MeshGeometryStamped > * m_tfMeshFilter
Messagefilter for meshMsg.
Definition: MeshDisplay.hpp:377
rviz_map_plugin::MeshDisplay::addNewVisual
std::shared_ptr< MeshVisual > addNewVisual()
adds a new visual to the ring buffer
Definition: MeshDisplay.cpp:973
rviz_map_plugin::MeshDisplay::m_materialServiceName
rviz::StringProperty * m_materialServiceName
Property to handle service name for materials.
Definition: MeshDisplay.hpp:428
rviz_map_plugin::MeshDisplay::m_vertexCostsTopic
rviz::RosTopicProperty * m_vertexCostsTopic
Property to handle topic for vertex cost maps.
Definition: MeshDisplay.hpp:437
rviz_map_plugin::MeshDisplay::setGeometry
void setGeometry(shared_ptr< Geometry > geometry)
Set the geometry.
Definition: MeshDisplay.cpp:336
ros.h
rviz::BoolProperty
message_filters::Cache< mesh_msgs::MeshGeometryStamped >
rviz_map_plugin::MeshDisplay::MeshDisplay
MeshDisplay()
Constructor.
Definition: MeshDisplay.cpp:72
frame_manager.h
rviz_map_plugin::MeshDisplay::~MeshDisplay
~MeshDisplay()
Destructor.
Definition: MeshDisplay.cpp:199
rviz_map_plugin::MeshDisplay::m_vertexColorsSubscriber
message_filters::Subscriber< mesh_msgs::MeshVertexColorsStamped > m_vertexColorsSubscriber
Subscriber for vertex colors.
Definition: MeshDisplay.hpp:371
rviz_map_plugin::MeshDisplay::setVertexNormals
void setVertexNormals(vector< Normal > &vertexNormals)
Set the vertex normals.
Definition: MeshDisplay.cpp:372
viewport_mouse_event.h
time_synchronizer.h
display.h
rviz_map_plugin::MeshDisplay::updateVertexCostsTopic
void updateVertexCostsTopic()
Updates the subscribed vertex costs topic.
Definition: MeshDisplay.cpp:605
rviz_map_plugin::MeshDisplay::updateMaterialAndTextureServices
void updateMaterialAndTextureServices()
Updates the material and texture services.
Definition: MeshDisplay.cpp:622
rviz::ColorProperty
visualization_manager.h
message_filters::Subscriber< mesh_msgs::MeshGeometryStamped >
rviz::Display
rviz::EnumProperty
rviz::FloatProperty
rviz_map_plugin::MeshDisplay::m_normalsAlpha
rviz::FloatProperty * m_normalsAlpha
Property to set the transparency of the normals.
Definition: MeshDisplay.hpp:458
rviz_map_plugin::MeshDisplay::updateMesh
void updateMesh()
Updates the mesh.
Definition: MeshDisplay.cpp:425
rviz_map_plugin::MeshDisplay::incomingGeometry
void incomingGeometry(const mesh_msgs::MeshGeometryStamped::ConstPtr &meshMsg)
Handler for incoming geometry messages. Validate data and update mesh.
Definition: MeshDisplay.cpp:798
rviz_map_plugin::MeshDisplay::m_vertexColorServiceName
rviz::StringProperty * m_vertexColorServiceName
Property to handle service name for vertexColors.
Definition: MeshDisplay.hpp:422
rviz_map_plugin::MeshDisplay::m_vertexColorClient
ros::ServiceClient m_vertexColorClient
Client to request the vertex colors.
Definition: MeshDisplay.hpp:353
console.h
rviz_map_plugin::MeshDisplay::m_costColorType
rviz::EnumProperty * m_costColorType
Property for selecting the color type for cost display.
Definition: MeshDisplay.hpp:434
message_filter.h
rviz_map_plugin::MeshDisplay::clearVertexCosts
void clearVertexCosts()
Clears the vertex costs.
Definition: MeshDisplay.cpp:360
rviz
subscriber.h
rviz_map_plugin::MeshDisplay::m_visuals
std::queue< std::shared_ptr< MeshVisual > > m_visuals
Visual data.
Definition: MeshDisplay.hpp:401
rviz_map_plugin::MeshDisplay::m_wireframeAlpha
rviz::FloatProperty * m_wireframeAlpha
Property to set wireframe transparency.
Definition: MeshDisplay.hpp:470
rviz_map_plugin::MeshDisplay::updateNormalsSize
void updateNormalsSize()
Update the size of the mesh normals.
Definition: MeshDisplay.cpp:558
rviz::StringProperty
visualization_frame.h
cache.h
rviz_map_plugin::MeshDisplay::onEnable
void onEnable()
RViz callback on enable.
Definition: MeshDisplay.cpp:241
rviz_map_plugin::MeshDisplay::onInitialize
void onInitialize()
RViz callback on initialize.
Definition: MeshDisplay.cpp:203
rviz_map_plugin::MeshDisplay::updateWireframe
void updateWireframe()
Updates the mesh wireframe.
Definition: MeshDisplay.cpp:524
rviz_map_plugin::MeshDisplay::m_messagesReceived
uint32_t m_messagesReceived
Counter for the received messages.
Definition: MeshDisplay.hpp:395
ros::ServiceClient
MeshVisual.hpp
rviz_map_plugin::MeshDisplay::m_vertexCostsSubscriber
message_filters::Subscriber< mesh_msgs::MeshVertexCostsStamped > m_vertexCostsSubscriber
Subscriber for vertex costs.
Definition: MeshDisplay.hpp:374
rviz_map_plugin::MeshDisplay::m_meshSubscriber
message_filters::Subscriber< mesh_msgs::MeshGeometryStamped > m_meshSubscriber
Subscriber for meshMsg.
Definition: MeshDisplay.hpp:368
rviz_map_plugin::MeshDisplay::m_textureServiceName
rviz::StringProperty * m_textureServiceName
Property to handle service name for textures.
Definition: MeshDisplay.hpp:431
rviz_map_plugin::MeshDisplay::m_selectVertexCostMap
rviz::EnumProperty * m_selectVertexCostMap
Property to select different types of vertex cost maps to be shown.
Definition: MeshDisplay.hpp:440
rviz_map_plugin::MeshDisplay::m_facesAlpha
rviz::FloatProperty * m_facesAlpha
Property to set faces transparency.
Definition: MeshDisplay.hpp:416
rviz_map_plugin::MeshDisplay::setPose
void setPose(Ogre::Vector3 &position, Ogre::Quaternion &orientation)
Set geometrys pose.
Definition: MeshDisplay.cpp:404
rviz_map_plugin::MeshDisplay::updateNormalsColor
void updateNormalsColor()
Update the color of the mesh normals.
Definition: MeshDisplay.cpp:547
rviz_map_plugin::MeshDisplay::unsubscribe
void unsubscribe()
Unsubscribes all topics.
Definition: MeshDisplay.cpp:297
rviz_map_plugin::MeshDisplay::setMaterials
void setMaterials(vector< Material > &materials, vector< TexCoords > &texCoords)
Set the materials and texture coordinates.
Definition: MeshDisplay.cpp:385
Types.hpp
rviz_map_plugin::MeshDisplay::updateTopic
void updateTopic()
Updates the subscribed topic.
Definition: MeshDisplay.cpp:615
rviz_map_plugin::MeshDisplay::m_costUseCustomLimits
rviz::BoolProperty * m_costUseCustomLimits
Property for using custom limits for cost display.
Definition: MeshDisplay.hpp:443
geometry.h
rviz_map_plugin::MeshDisplay::m_tfVertexColorsFilter
tf2_ros::MessageFilter< mesh_msgs::MeshVertexColorsStamped > * m_tfVertexColorsFilter
Messagefilter for vertex colors.
Definition: MeshDisplay.hpp:380
rviz_map_plugin::MeshDisplay
Display for showing the mesh in different modes.
Definition: MeshDisplay.hpp:128
rviz_map_plugin::MeshDisplay::m_ignoreMsgs
bool m_ignoreMsgs
if set to true, ignore incoming messages and do not use services to request materials
Definition: MeshDisplay.hpp:350
rviz_map_plugin::MeshDisplay::m_uuidClient
ros::ServiceClient m_uuidClient
Client to request the UUID.
Definition: MeshDisplay.hpp:362
rviz_map_plugin::MeshDisplay::m_showWireframe
rviz::BoolProperty * m_showWireframe
Property to select the wireframe.
Definition: MeshDisplay.hpp:464
rviz_map_plugin
Definition: ClusterLabelDisplay.hpp:120
rviz_map_plugin::MeshDisplay::requestMaterials
void requestMaterials(std::string uuid)
Requests materials from the specified service.
Definition: MeshDisplay.cpp:865
rviz_map_plugin::MeshDisplay::requestVertexColors
void requestVertexColors(std::string uuid)
Requests vertex colors from the specified service.
Definition: MeshDisplay.cpp:835
rviz_map_plugin::MeshDisplay::m_wireframeColor
rviz::ColorProperty * m_wireframeColor
Property to set wireframe color.
Definition: MeshDisplay.hpp:467
rviz_map_plugin::MeshDisplay::m_textureClient
ros::ServiceClient m_textureClient
Client to request the textures.
Definition: MeshDisplay.hpp:359
rviz_map_plugin::MeshDisplay::m_normalsColor
rviz::ColorProperty * m_normalsColor
Property to set the color of the normals.
Definition: MeshDisplay.hpp:455
rviz_map_plugin::MeshDisplay::m_costsSynchronizer
message_filters::Cache< mesh_msgs::MeshVertexCostsStamped > * m_costsSynchronizer
Synchronizer for vertex costs.
Definition: MeshDisplay.hpp:392
rviz_map_plugin::MeshDisplay::subscribe
void subscribe()
Set the topics to subscribe.
Definition: MeshDisplay.cpp:258
rviz_map_plugin::MeshDisplay::m_scalingFactor
rviz::FloatProperty * m_scalingFactor
Property to set the size of the normals.
Definition: MeshDisplay.hpp:461
rviz_map_plugin::MeshDisplay::updateVertexCosts
void updateVertexCosts()
Update the vertex costs.
Definition: MeshDisplay.cpp:567
rviz_map_plugin::MeshDisplay::m_colorsSynchronizer
message_filters::Cache< mesh_msgs::MeshVertexColorsStamped > * m_colorsSynchronizer
Synchronizer for vertex colors.
Definition: MeshDisplay.hpp:389
rviz_map_plugin::Texture
Struct for textures.
Definition: Types.hpp:160
rviz_map_plugin::MeshDisplay::m_costUpperLimit
rviz::FloatProperty * m_costUpperLimit
Property for setting the upper limit of cost display.
Definition: MeshDisplay.hpp:449
rviz_map_plugin::MeshDisplay::m_bufferSize
rviz::IntProperty * m_bufferSize
Property to handle buffer size.
Definition: MeshDisplay.hpp:407
rviz_map_plugin::MeshDisplay::incomingVertexColors
void incomingVertexColors(const mesh_msgs::MeshVertexColorsStamped::ConstPtr &colorsStamped)
Handler for incoming vertex color messages. Validate data and update mesh.
Definition: MeshDisplay.cpp:805
rviz_map_plugin::MeshDisplay::updateNormals
void updateNormals()
Update the mesh normals.
Definition: MeshDisplay.cpp:535
rviz_map_plugin::MeshDisplay::m_showNormals
rviz::BoolProperty * m_showNormals
Property to select the normals.
Definition: MeshDisplay.hpp:452
rviz_map_plugin::MeshDisplay::m_lastUuid
std::string m_lastUuid
Uuid of the last received message.
Definition: MeshDisplay.hpp:398
rviz_map_plugin::MeshDisplay::m_displayType
rviz::EnumProperty * m_displayType
Property to select the display type.
Definition: MeshDisplay.hpp:410
rviz_map_plugin::MeshDisplay::incomingVertexCosts
void incomingVertexCosts(const mesh_msgs::MeshVertexCostsStamped::ConstPtr &costsStamped)
Handler for incoming vertex cost messages. Validate data and update mesh.
Definition: MeshDisplay.cpp:823
rviz_map_plugin::MeshDisplay::updateBufferSize
void updateBufferSize()
Updates the buffer size.
Definition: MeshDisplay.cpp:417
rviz_map_plugin::MeshDisplay::ignoreIncomingMessages
void ignoreIncomingMessages()
disables visualization of incoming messages
Definition: MeshDisplay.cpp:320
rviz_map_plugin::MeshDisplay::getLatestVisual
std::shared_ptr< MeshVisual > getLatestVisual()
delivers the latest mesh visual
Definition: MeshDisplay.cpp:964
rviz_map_plugin::MeshDisplay::m_vertexColorsTopic
rviz::RosTopicProperty * m_vertexColorsTopic
Property to handle topic for vertex colors.
Definition: MeshDisplay.hpp:419
rviz_map_plugin::MeshDisplay::m_tfVertexCostsFilter
tf2_ros::MessageFilter< mesh_msgs::MeshVertexCostsStamped > * m_tfVertexCostsFilter
Messagefilter for vertex costs.
Definition: MeshDisplay.hpp:383
rviz_map_plugin::MeshDisplay::onDisable
void onDisable()
RViz callback on disable.
Definition: MeshDisplay.cpp:250
rviz_map_plugin::MeshDisplay::cacheVertexCosts
void cacheVertexCosts(std::string layer, const std::vector< float > &costs)
Cache function for vertex cost messages.
Definition: MeshDisplay.cpp:944
rviz::IntProperty
display_context.h
rviz_map_plugin::MeshDisplay::m_meshSynchronizer
message_filters::Cache< mesh_msgs::MeshGeometryStamped > * m_meshSynchronizer
Synchronizer for meshMsgs.
Definition: MeshDisplay.hpp:386
rviz_map_plugin::MeshDisplay::m_showTexturedFacesOnly
rviz::BoolProperty * m_showTexturedFacesOnly
Property to only show textured faces when texturizing is enabled.
Definition: MeshDisplay.hpp:425


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