Making a client call a service defined in another workspace

asked 2023-04-07 13:55:34 -0500

brieb gravatar image

updated 2023-04-07 13:56:00 -0500

TL;DR

I have an existing service definition already deployed to a host that I cannot change. This service is running, and I want to make a new workspace with a client that calls that service, but I can't seem to get the client to "find" the service. Is it an overlay issue? Am I doing something incorrectly in making the client?

Base interface workspace

~/interfaces_ws/

I have an interface workspace defined with various messages and services. It builds just fine.

source /opt/ros/foxy/setup.bash
colcon build

First overlay workspace

~/service_ws/

This workspace uses some of the base interface workspace interfaces and build it

source ~/interfaces_ws/install/setup.bash
colcon build

I can launch the service just fine, waiting for client requests.

source ~/service_ws/install/setup.bash
ros2 launch service_pkg service_pkg_launch.py

When I open a new terminal and source the base ros2, I can list the service, call the service, anything I want.

source /opt/ros/foxy/setup.bash
ros2 service list
ros2 service call /service_pkg/service interfaces_pkg/service_interface "{payload}"

That works as expected.

Second Overlay Workspace

Now I run into issues when I try to make a client using python in a third workspace. Note, on my actual host, this will be a new workspace, the other two already exist and cannot be changed.

~/client_ws/

When I build this, I have tried many permutations, but the most basic builds

source /opt/ros.foxy/setup.bash
colcon build

Now when I run my client, I have tried overlaying the client workspace on the service workspace, overlaying the client on the interfaces, overlaying the client on the service on the interfaces...nothing seems to work. My client just hangs, waiting for the service to become available.

# this includes the /opt/ros/foxy on my path AMENT_PREFIX_PATH and PYTHONPATH, but not CMAKE_PREFIX_PATH nor COLCON_PREFIX_PATH
source ~/interfaces_ws/install/setup.bash 
source ~/client_ws/install/local_setup.bash
ros2 run client_pkg client_node

This just hangs, waiting for the service to become available. Based on my import though, it has to find the service interface built in the interfaces_ws.

What am I doing wrong?!?!

edit retag flag offensive close merge delete