From 2bf688827ba8d69e979b3ab9d69b45ef168aeb7f Mon Sep 17 00:00:00 2001 From: Sriram Raghunathan Date: Wed, 20 Dec 2017 09:15:58 +0530 Subject: [PATCH] =?UTF-8?q?Change=20rmw=5Fcount=5Fpublishers=20API,=20to?= =?UTF-8?q?=20rcl=20equivalent=20rcl=5Fcount=5Fpublishe=E2=80=A6=20(#425)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change rmw_count_publishers API, to rcl equivalent rcl_count_publishers and remove the TODO line. Signed-off-by: Sriram Raghunathan * Remove rmw_handle and refer to rcl_node_handle, change the API signature to topic_names. Signed-off-by: Sriram Raghunathan * Use rcl_* specific functions to derive the fully qualified topic name. Signed-off-by: Sriram Raghunathan * [nitpick] remove unnecessary variable storage --- .../src/rclcpp/node_interfaces/node_graph.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp index fc2bfba..2feb8f0 100644 --- a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp +++ b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp @@ -166,16 +166,16 @@ NodeGraph::get_node_names() const size_t NodeGraph::count_publishers(const std::string & topic_name) const { - auto rmw_node_handle = rcl_node_get_rmw_handle(node_base_->get_rcl_node_handle()); + auto rcl_node_handle = node_base_->get_rcl_node_handle(); + auto fqdn = rclcpp::expand_topic_or_service_name( topic_name, - rmw_node_handle->name, - rmw_node_handle->namespace_, + rcl_node_get_name(rcl_node_handle), + rcl_node_get_namespace(rcl_node_handle), false); // false = not a service size_t count; - // TODO(wjwwood): use the rcl equivalent methods - auto ret = rmw_count_publishers(rmw_node_handle, fqdn.c_str(), &count); + auto ret = rcl_count_publishers(rcl_node_handle, fqdn.c_str(), &count); if (ret != RMW_RET_OK) { // *INDENT-OFF* throw std::runtime_error( @@ -188,16 +188,16 @@ NodeGraph::count_publishers(const std::string & topic_name) const size_t NodeGraph::count_subscribers(const std::string & topic_name) const { - auto rmw_node_handle = rcl_node_get_rmw_handle(node_base_->get_rcl_node_handle()); + auto rcl_node_handle = node_base_->get_rcl_node_handle(); + auto fqdn = rclcpp::expand_topic_or_service_name( topic_name, - rmw_node_handle->name, - rmw_node_handle->namespace_, + rcl_node_get_name(rcl_node_handle), + rcl_node_get_namespace(rcl_node_handle), false); // false = not a service size_t count; - // TODO(wjwwood): use the rcl equivalent methods - auto ret = rmw_count_subscribers(rmw_node_handle, fqdn.c_str(), &count); + auto ret = rcl_count_subscribers(rcl_node_handle, fqdn.c_str(), &count); if (ret != RMW_RET_OK) { // *INDENT-OFF* throw std::runtime_error(