Exercise 3.1 cant execute service

I’m feeling super stupid, but i cant launch the example from exercise 3.1 (I mean its basicaly a copy paste exercise isn’t it?) But I get the following error:

The cpp content is a 100% copy of the given code.
it starts with <launch … which i can twrite here

    <include file="$(find trajectory_by_name)/launch/start_service.launch"/>
    <node pkg = "service_client_pkg" type = "simple_service_client" name = "simple_service_client" output = "screen">

What I added to the cmake:

add_executable(simple_service_client src/simple_service_client.cpp)

add_dependencies(simple_service_client ${simple_service_client_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})


${catkin_LIBRARIES} )

Hi @t.alscher,

The error says the service could not be called, and this could mean that the service is not ready. Could you check you code is waiting for the service to be ready (even if it’s a 100% copy of the given code :slight_smile: )?

What you can do to confirm:

  • Start the service manually.
  • Temporarily remove the include tag of the launch file and launch the code again.

Hi, this solution doesn’t seem to work, i believe the correct solution would be to add the custom message to the CMakeList, unfortunately I don’t know how to do that.

Hi @ricardo.rico-uribe,

You don’t need to add the custom message to CMakeList.txt as it already exists. You just need to add the trajectory_by_name_srv package as a dependency when creating the package, viz:

catkin_create_pkg your_package roscpp trajectory_by_name_srv

This is mentioned in the notes. Don’t forget that you also need to set up your C++ source normally (unlike the Python colleague, a C++ source needs some extra setup in CMakeLists even in cases like this when you don’t need to add any custom message).

Please go over the notes again and let us know the details of any problems you still have,

By the way, welcome to the Community!