Skip to content

Commit e18ac42

Browse files
committed
Print warning when waiting for more than 3 seconds for topic.
1 parent 9bab548 commit e18ac42

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ros_babel_fish/src/detail/topic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
//
44

55
#include "ros_babel_fish/detail/topic.hpp"
6+
#include "../logging.hpp"
67

78
#include <rclcpp/graph_listener.hpp>
89
#include <rclcpp/node.hpp>
910
#include <rclcpp/wait_set.hpp>
1011

12+
using namespace std::chrono_literals;
13+
1114
namespace ros_babel_fish
1215
{
1316
namespace impl
@@ -68,6 +71,12 @@ bool wait_for_topic_and_type_nanoseconds( rclcpp::Node &node, const std::string
6871
if ( timeout > std::chrono::nanoseconds( 0 ) ) {
6972
time_to_wait = timeout - ( std::chrono::steady_clock::now() - start );
7073
}
74+
if ( std::chrono::steady_clock::now() - start > 3s ) {
75+
RBF2_WARN_THROTTLE(
76+
*node.get_clock(), 3000,
77+
"Still waiting for topic '%s' to appear (timeout=%ld). Are you spinning the node?",
78+
topic.c_str(), timeout.count() );
79+
}
7180
} while ( time_to_wait > std::chrono::nanoseconds( 0 ) );
7281
return false; // timeout exceeded while waiting for the topic
7382
}

0 commit comments

Comments
 (0)