Exercise 5.1 ,Error when launching service and client from same launch file

@staff In ROS Basics in C++,Unit 5, I am trying to run call a service programmatically according to tutorial.

When i include the launch file for the server start_service.launch in the launch file for the service client, it gives error, but when i run them in 2 different launch files, it works as intended.

When using a single launch file:


  <include file="$(find trajectory_by_name)/launch/start_service.launch"/>

  <node pkg ="service_client_pkg"




 * /rosdistro: noetic
 * /rosversion: 1.15.9

    iri_wam_reproduce_trajectory (iri_wam_reproduce_trajectory/iri_wam_reproduce_trajectory_node)
    service_client_node (service_client_pkg/service_client_pkg_node)
    traj_by_name_node (trajectory_by_name/traj_by_name.py)


process[iri_wam_reproduce_trajectory-1]: started with pid [10951]
process[traj_by_name_node-2]: started with pid [10952]
process[service_client_node-3]: started with pid [10953]
[ INFO] [1646400762.345289623]: Waiting for action server to start.
[ERROR] [1646400762.371537319]: Failed to call service /trajectory_by_name
[ INFO] [1646400762.376170257]: Ready execute trajectories
[service_client_node-3] process has died [pid 10953, exit code 1, cmd /home/user/catkin_ws/devel/lib/service_client_pkg/service_client_pkg_node __name:=service_client_node __log:=/home/user/.ros/log/caebc1ca-9bb5-11ec-99af-0242ac190008/service_client_node-3.log].
log file: /home/user/.ros/log/caebc1ca-9bb5-11ec-99af-0242ac190008/service_client_node-3*.log

Can i know why this is happening?

Feedback to @staff
under Exercise 5.1, please include which service we should launch, that is, please include the line below:

roslaunch trajectory_by_name start_service.launch

You are calling the service before it’s ready. You need to use this somewhere in your service client:


Figuring out what to launch is part of the exercise. We expected that you would know this if you have been following the material up to that point.

This line of code was not part of the sample code provided in the tutorial. Waiting for service was part of the code in the python tutorial but missing here in the C++ version. This can be very confusing to new
users. Please update it.

Thank you, you are right. We will update it.

1 Like