Skip to content

Commit 80bb4f5

Browse files
authored
Merge pull request #61 from JustusBraun/feature/dynamic-cost-updates
Enable Use of New Display by Topic for MeshGeometryStamped
2 parents 3785098 + 852f36e commit 80bb4f5

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

rviz_mesh_tools_plugins/include/rviz_mesh_tools_plugins/MeshDisplay.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#include <message_filters/cache.h>
8686

8787
#include <rviz_mesh_tools_plugins/RVizMessageFilter.hpp>
88-
#include <rviz_mesh_tools_plugins/ThreadSaveQueue.hpp>
88+
#include <rviz_mesh_tools_plugins/ThreadSafeQueue.hpp>
8989

9090
#include <rviz_rendering/mesh_loader.hpp>
9191

@@ -143,7 +143,7 @@ class MeshDisplay : public rviz_common::Display
143143
Q_OBJECT
144144

145145
public:
146-
/**#include "rviz_common/ros_integration/ros_node_abstraction_iface.hpp"
146+
/**
147147
* @brief Constructor
148148
*/
149149
MeshDisplay();
@@ -177,6 +177,11 @@ class MeshDisplay : public rviz_common::Display
177177

178178
void fixedFrameChanged() override;
179179

180+
/**
181+
* @brief Used by RViz's "New display by topic" window
182+
*/
183+
void setTopic(const QString& topic, const QString& datatype) override;
184+
180185
/**
181186
* @brief Update all subscriptions. Individual subscription update function will check whether they are active. (e.g. vertex colors can also be inactive when the UI element is set to a fixed color).
182187
*/

rviz_mesh_tools_plugins/include/rviz_mesh_tools_plugins/ThreadSaveQueue.hpp renamed to rviz_mesh_tools_plugins/include/rviz_mesh_tools_plugins/ThreadSafeQueue.hpp

File renamed without changes.

rviz_mesh_tools_plugins/plugins_description.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<description>
3434
Displays a mesh.
3535
</description>
36+
<message_type>mesh_msgs/msg/MeshGeometryStamped</message_type>
3637
</class>
3738
<class name="rviz_mesh_tools_plugins/MeshGoal"
3839
type="rviz_mesh_tools_plugins::MeshGoalTool"

rviz_mesh_tools_plugins/src/MeshDisplay.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ void MeshDisplay::onInitialize()
284284
m_meshTopic->initialize(context_->getRosNodeAbstraction());
285285
m_vertexColorsTopic->initialize(context_->getRosNodeAbstraction());
286286
m_vertexCostsTopic->initialize(context_->getRosNodeAbstraction());
287+
m_vertexCostUpdateTopic->initialize(context_->getRosNodeAbstraction());
287288

288289
m_meshTopicQos->initialize(
289290
[this](rclcpp::QoS profile) {
@@ -303,6 +304,12 @@ void MeshDisplay::onInitialize()
303304
updateVertexCostsSubscription();
304305
});
305306

307+
m_vertexCostUpdateTopicQos->initialize(
308+
[this](rclcpp::QoS profile) {
309+
m_vertexCostUpdateQos = profile;
310+
updateVertexCostsUpdateSubscription();
311+
});
312+
306313
// Initialize service clients
307314
//m_vertexColorClient = node->create_client<mesh_msgs::srv::GetVertexColors>(m_vertexColorServiceName->getStdString());
308315
//m_materialsClient = node->create_client<mesh_msgs::srv::GetMaterials>(m_materialServiceName->getStdString());
@@ -415,6 +422,21 @@ void MeshDisplay::fixedFrameChanged()
415422
this->transformMesh();
416423
}
417424

425+
void MeshDisplay::setTopic(const QString& topic, const QString& datatype)
426+
{
427+
(void) datatype;
428+
RCLCPP_DEBUG(
429+
rclcpp::get_logger("rviz_mesh_tools_plugins"),
430+
// The char array returned by QString.data() may not be '\0' terminated! -> topic.toStdString().c_str()
431+
"MeshDisplay::setTopic() - called with topic='%s'", topic.toStdString().c_str()
432+
);
433+
if (m_meshTopic)
434+
{
435+
// This also triggers the updateMeshGeometrySubscription() slot
436+
m_meshTopic->setString(topic);
437+
}
438+
}
439+
418440
void MeshDisplay::reset()
419441
{
420442
Display::reset();
@@ -460,6 +482,7 @@ void MeshDisplay::updateAllSubscriptions()
460482
updateMeshGeometrySubscription();
461483
updateVertexColorsSubscription();
462484
updateVertexCostsSubscription();
485+
updateVertexCostsUpdateSubscription();
463486

464487
// TODO
465488
// initialServiceCall();
@@ -470,6 +493,7 @@ void MeshDisplay::unsubscribe()
470493
m_meshSubscriber.unsubscribe();
471494
m_vertexColorsSubscriber.unsubscribe();
472495
m_vertexCostsSubscriber.unsubscribe();
496+
m_vertexCostUpdateSubscriber.unsubscribe();
473497

474498
m_tfMeshFilter.reset();
475499
m_colorsMsgCache.reset();

0 commit comments

Comments
 (0)