ROS2 Python call_async() blocked

asked 2020-10-09 14:15:22 -0500

redtedtezza gravatar image

Hello,

I have a question about the potential reason for a service call from a ROS2 Python node being blocked. The service server is in a separate C++ node. An outline is provided below of each code block. I am observing that when the service is called via the rqt plugin, it successfully displays the response. Furthermore, a printout (not shown here) shows the full service call function on the C++ side is executed. However when it is called from the Python node, it fails to get past the spin_until_future_complete line. I would appreciate any leads for things to investigate.

Python (client)

    def get_waypoints(self):
        req = WaypointList.Request()
        while not self.cli.wait_for_service(timeout_sec=1.0):
            self.node.get_logger().info('Waiting for waypoint service to become available...')
        future = self.cli.call_async(req)
        rclpy.spin_until_future_complete(self.node, future)
        try:
            result = future.result()
        except Exception as e:
            self.node.get_logger().info('Service call failed %r' % (e,))    
        return result

C++ (server)

  void srv_clbk(const std::shared_ptr<custom_msgs::srv::WaypointList::Request>  req,
                      std::shared_ptr<custom_msgs::srv::WaypointList::Response> res) {
       res->waypoints = waypoints_;
  }
edit retag flag offensive close merge delete