in roscpp_azure_iothub/src/ros_azure_iothub_cpp_node.cpp [175:197]
static bool IsTopicAvailableForSubscribe(const char* topicName)
{
std::string topic_name = topicName;
ros::master::V_TopicInfo advertized_topics;
ros::master::getTopics(advertized_topics);
bool found = false;
for (const auto& topic_info: advertized_topics)
{
if( topic_info.name == topic_name)
{
found = true;
break;
}
}
if (!found )
{
ROS_WARN("This topic has not been published yet: %s", topic_name.c_str());
return false;
}
return true;
}