diff --git a/CMakeLists.txt b/CMakeLists.txt index e2bf578..135bdba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.5) project(rqt_image_view) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic -Wno-deprecated-declarations) +endif() + find_package(ament_cmake REQUIRED) if(WIN32) diff --git a/src/rqt_image_view/image_view.cpp b/src/rqt_image_view/image_view.cpp index 9eaf21a..62e9369 100644 --- a/src/rqt_image_view/image_view.cpp +++ b/src/rqt_image_view/image_view.cpp @@ -316,7 +316,20 @@ void ImageView::onTopicChanged(int index) image_transport::ImageTransport it(node_); const image_transport::TransportHints hints(node_.get(), transport.toStdString()); try { - subscriber_ = it.subscribe(topic.toStdString(), 1, &ImageView::callbackImage, this, &hints); + std::vector endpoints = node_->get_publishers_info_by_topic(topic.toStdString()); + if(endpoints.empty()) + { + rclcpp::QoS topic_qos(1); + subscriber_ = image_transport::create_subscription(node_.get(),topic.toStdString(),std::bind(&ImageView::callbackImage,this,std::placeholders::_1),hints.getTransport(), + topic_qos.get_rmw_qos_profile()); + } + else + { + rclcpp::QoS topic_qos = endpoints.front().qos_profile(); + subscriber_ = image_transport::create_subscription(node_.get(),topic.toStdString(),std::bind(&ImageView::callbackImage,this,std::placeholders::_1),hints.getTransport(), + topic_qos.get_rmw_qos_profile()); + } + qDebug("ImageView::onTopicChanged() to topic '%s' with transport '%s'", topic.toStdString().c_str(), subscriber_.getTransport().c_str()); } catch (image_transport::TransportLoadException& e) { QMessageBox::warning(widget_, tr("Loading image transport plugin failed"), e.what());