Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to call parameter service after server restarts #502

Open
sloretz opened this issue Jun 7, 2018 · 1 comment
Open

Failure to call parameter service after server restarts #502

sloretz opened this issue Jun 7, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@sloretz
Copy link
Contributor

sloretz commented Jun 7, 2018

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)

@sloretz
Copy link
Contributor Author

sloretz commented Jun 8, 2018

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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant