Skip to content

Failure to call parameter service after server restarts #502

Open

Description

@sloretz

Bug report

Required Info:

Steps to reproduce issue

Build an rclcpp executable with the following code

#include <string>

#include "rclcpp/rclcpp.hpp"

int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);

  std::string node_name = "initial_params_node";
  std::string namespace_ = "/";
  auto node = rclcpp::Node::make_shared(node_name, namespace_);

  rclcpp::spin(node);

  rclcpp::shutdown();
  return 0;
}

Run the following python code (change the hardcoded path to initial_params_rclcpp to the above binary)

from rcl_interfaces.srv import GetParameters
import rclpy

import subprocess
import threading
import time


rclpy.init()
node = rclpy.create_node('tests_yaml')


def background_spin(node):
    while rclpy.ok():
        # workaround ros2/rclpy#188
        rclpy.spin_once(node, timeout_sec=time.sleep(0.25))


try:
    # Keep an executor running in the background
    thr = threading.Thread(target=background_spin, args=(node,), daemon=True)
    thr.start()

    while True:
        print('start loop')


        proc = subprocess.Popen(['/workspace/ros2-dev0/build/test_cli/initial_params_rclcpp', '__node:=listener'])
        # Using the listener node instead fixes the issue
        # proc = subprocess.Popen(['ros2', 'run', 'demo_nodes_cpp', 'listener'])
        try:
            # print('about to create client')
            client = node.create_client(GetParameters, '/listener/get_parameters')
            # print('about to wait for service')
            client.wait_for_service()

            # Sleeping here fixes the issue
            # time.sleep(1)

            # print('about to send service request')
            request = GetParameters.Request()
            request.names = ('use_sim_time',)
            client.call(request)

            # print('about to destroy client')
            node.destroy_client(client)
        finally:
            # print('about to kill subprocess')
            proc.kill()
finally:
    node.destroy_node()
    rclpy.shutdown()

Expected behavior

start loop would be printed forever

Actual behavior

start loop prints twice. The program is forever waiting in the second invocation of client.call(request)

Additional information

ros2/system_tests#274 (comment)

Activity

  1. added
    bug
    on Jun 7, 2018
  2. sloretz commented on Jun 8, 2018

    @sloretz
    ContributorAuthor

    Possibly related to ros2/rmw_fastrtps#205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions