@@ -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+
418440void 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