Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ class RosNodeAbstraction : public RosNodeAbstractionIface
std::map<std::string, std::vector<std::string>>
get_topic_names_and_types() const override;

/// Count the number of publishers for a given topic.
/**
* \param topic_name the name of the topic to count publishers for
* \return the number of publishers for the given topic
*/
RVIZ_COMMON_PUBLIC
size_t count_publishers(const std::string & topic_name) const override;

/// Return a map with service names mapped to a list of types for that service.
/**
* The node name is what was given when initializing this API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class RosNodeAbstractionIface
virtual std::map<std::string, std::vector<std::string>>
get_topic_names_and_types() const = 0;

virtual size_t count_publishers(const std::string & topic_name) const = 0;

virtual std::map<std::string, std::vector<std::string>>
get_service_names_and_types() const = 0;

Expand Down
5 changes: 5 additions & 0 deletions rviz_common/src/rviz_common/add_display_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ void getPluginGroups(
}
QString datatype = QString::fromStdString(map_pair.second[0]);

// Check if there is a publisher for this topic, if not we skip it
if (!rviz_ros_node.lock()->count_publishers(map_pair.first)) {
continue;
}

if (datatype_plugins.contains(datatype)) {
if (
groups->empty() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ RosNodeAbstraction::get_topic_names_and_types() const
return raw_node_->get_topic_names_and_types();
}

size_t RosNodeAbstraction::count_publishers(const std::string & topic_name) const
{
return raw_node_->count_publishers(topic_name);
}

std::map<std::string, std::vector<std::string>>
RosNodeAbstraction::get_service_names_and_types() const
{
Expand Down