diff --git a/test_tracetools/src/test_generic_ping.cpp b/test_tracetools/src/test_generic_ping.cpp index 8ae18f89..79fbfff8 100644 --- a/test_tracetools/src/test_generic_ping.cpp +++ b/test_tracetools/src/test_generic_ping.cpp @@ -41,7 +41,7 @@ class PingNode : public rclcpp::Node pub_ = this->create_generic_publisher( PUB_TOPIC_NAME, "std_msgs/msg/String", - rclcpp::QoS(QUEUE_DEPTH)); + rclcpp::QoS(QUEUE_DEPTH).transient_local()); timer_ = this->create_wall_timer( 500ms, std::bind(&PingNode::timer_callback, this)); @@ -69,7 +69,11 @@ class PingNode : public rclcpp::Node rclcpp::SerializedMessage serialized_msg; serialized_msg.reserve(1024); serializer_->serialize_message(&msg, &serialized_msg); + RCLCPP_INFO(this->get_logger(), "ping"); pub_->publish(serialized_msg); + if (do_only_one_) { + timer_->cancel(); + } } rclcpp::GenericSubscription::SharedPtr sub_; diff --git a/test_tracetools/src/test_generic_pong.cpp b/test_tracetools/src/test_generic_pong.cpp index d6398dca..b7574071 100644 --- a/test_tracetools/src/test_generic_pong.cpp +++ b/test_tracetools/src/test_generic_pong.cpp @@ -32,7 +32,7 @@ class PongNode : public rclcpp::Node sub_ = this->create_generic_subscription( SUB_TOPIC_NAME, "std_msgs/msg/String", - rclcpp::QoS(10), + rclcpp::QoS(10).transient_local(), std::bind(&PongNode::callback, this, std::placeholders::_1)); pub_ = this->create_generic_publisher( PUB_TOPIC_NAME, @@ -55,6 +55,7 @@ class PongNode : public rclcpp::Node rclcpp::SerializedMessage serialized_msg; serialized_msg.reserve(1024); serializer_->serialize_message(&next_msg, &serialized_msg); + RCLCPP_INFO(this->get_logger(), "pong"); pub_->publish(serialized_msg); if (do_only_one_) { rclcpp::shutdown(); diff --git a/test_tracetools/src/test_ping.cpp b/test_tracetools/src/test_ping.cpp index b06a87e5..61951b20 100644 --- a/test_tracetools/src/test_ping.cpp +++ b/test_tracetools/src/test_ping.cpp @@ -38,7 +38,7 @@ class PingNode : public rclcpp::Node std::bind(&PingNode::callback, this, std::placeholders::_1)); pub_ = this->create_publisher( PUB_TOPIC_NAME, - rclcpp::QoS(QUEUE_DEPTH)); + rclcpp::QoS(QUEUE_DEPTH).transient_local()); timer_ = this->create_wall_timer( 500ms, std::bind(&PingNode::timer_callback, this)); @@ -60,7 +60,11 @@ class PingNode : public rclcpp::Node { auto msg = std::make_shared(); msg->data = "some random ping string"; + RCLCPP_INFO(this->get_logger(), "ping"); pub_->publish(*msg); + if (do_only_one_) { + timer_->cancel(); + } } rclcpp::Subscription::SharedPtr sub_; diff --git a/test_tracetools/src/test_pong.cpp b/test_tracetools/src/test_pong.cpp index 5a69cab1..7eaedd53 100644 --- a/test_tracetools/src/test_pong.cpp +++ b/test_tracetools/src/test_pong.cpp @@ -30,7 +30,7 @@ class PongNode : public rclcpp::Node { sub_ = this->create_subscription( SUB_TOPIC_NAME, - rclcpp::QoS(10), + rclcpp::QoS(10).transient_local(), std::bind(&PongNode::callback, this, std::placeholders::_1)); pub_ = this->create_publisher( PUB_TOPIC_NAME, @@ -46,6 +46,7 @@ class PongNode : public rclcpp::Node RCLCPP_INFO(this->get_logger(), "[output] %s", msg->data.c_str()); auto next_msg = std::make_shared(); next_msg->data = "some random pong string"; + RCLCPP_INFO(this->get_logger(), "pong"); pub_->publish(*next_msg); if (do_only_one_) { rclcpp::shutdown();