ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To me this sounds like an RTPS discovery thing. Discovery doesn't happen instantaneously. You may want to add in something like:

client = node.create_client(Type, 'topic')
print('waiting for service to become available')
if client.wait_for_service(timeout_sec=1.0):
    print('found service')
    result = client.call(Type())
else:
    print('service not found')

With ros2 service call, it'll wait until the service exists prior to actually calling it (similar to above, but with an infinite timeout).