Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion src/rqt_image_view/image_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rclcpp::TopicEndpointInfo> 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());
Expand Down