ros2 / ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
Apache License 2.0
452 stars 288 forks source link

No member named get_service_names_and_types_by_node #269

Closed iKrishneel closed 4 years ago

iKrishneel commented 4 years ago

Bug report

When building the ros1_bridge on the ROS_DISTRO foxy there is a build error I am using the docker image osrf/ros2:nightly

/home/ros2/foxy/src/ros1_bridge/src/dynamic_bridge.cpp: In lambda function:
/home/ros2/foxy/src/ros1_bridge/src/dynamic_bridge.cpp:708:22: error: ‘using element_type = class rclcpp::Node’ {aka ‘class rclcpp::Node’} has no member named ‘get_service_names_and_types_by_node’; did you mean ‘get_service_names_and_types’?
  708 |           ros2_node->get_service_names_and_types_by_node(pair.first, pair.second);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      get_service_names_and_types

Even on eloquent banch it seems rclcpp::Node no longer have this function get_service_names_and_types_by_node(x, y)

I am able to fix this issue with the following changes by replacing with

get_service_names_and_types()
/*Return a map of existing service names to list of service types.*/
diff --git a/src/dynamic_bridge.cpp b/src/dynamic_bridge.cpp
index 27da971..74890a9 100644
--- a/src/dynamic_bridge.cpp
+++ b/src/dynamic_bridge.cpp
@@ -698,18 +698,26 @@ int main(int argc, char * argv[])

       // collect available services (not clients)
       std::set<std::string> service_names;
+      /*
       std::vector<std::pair<std::string, std::string>> node_names_and_namespaces =
         ros2_node->get_node_graph_interface()->get_node_names_and_namespaces();
       for (auto & pair : node_names_and_namespaces) {
         if (pair.first == ros2_node->get_name() && pair.second == ros2_node->get_namespace()) {
           continue;
         }
+
         std::map<std::string, std::vector<std::string>> services_and_types =
           ros2_node->get_service_names_and_types_by_node(pair.first, pair.second);
         for (auto & it : services_and_types) {
           service_names.insert(it.first);
         }
       }
+    */
+      std::map<std::string, std::vector<std::string>> services_and_types =
+   ros2_node->get_service_names_and_types();
+        for (auto & it : services_and_types) {
+          service_names.insert(it.first);
+        }

       auto ros2_services_and_types = ros2_node->get_service_names_and_types();
       std::map<std::string, std::map<std::string, std::string>> active_ros2_services;
dirk-thomas commented 4 years ago

When building the ros1_bridge on the ROS_DISTRO foxy there is a build error I am using the docker image osrf/ros2:nightly

In order to build the latest state of the master branch (which includes #267) you need the referenced changes from ros2/rclcpp#1131. Please make sure you have the latest versions, e.g. rclcpp 1.1.0.

Even on eloquent banch it seems rclcpp::Node no longer have this function get_service_names_and_types_by_node(x, y)

The master branch of ros1_bridge is not compatible with ROS Eloquent. You need to use the eloquent branch for that.