Exercise 5.1 ROS Basics in 5 days, Topics exercise

Dear Instructor,
I have a couple of doubts regarding the exercise in ROS Topics section:

#! /usr/bin/env python

import rospy
from iri_wam_reproduce_trajectory.srv import ExecTraj, ExecTrajRequest # Import the service message used by the service /execute_trajectory

rospy.init_node('service_execute_trajectory_client') # Initialise a ROS node with the name service_client
rospy.wait_for_service('/execute_trajectory') # Wait for the service client /execute_trajectory to be running
execute_trajectory_service_client = rospy.ServiceProxy('/execute_trajectory', ExecTraj) # Create the connection to the service
execute_trajectory_request_object = ExecTrajRequest() # Create an object of type ExecTrajRequest
execute_trajectory_request_object.file = "file_path" # Fill the variable file of this object with the desired file path
result = execute_trajectory_service_client(execute_trajectory_request_object) # Send through the connection the path to the trajectory file to be executed
print(result) # Print the result type ExecTrajResponse
user:~/catkin_ws$ rossrv show iri_wam_reproduce_trajectory/ExecTraj
string file

Here, my question is, how do we know that ExecTraj is present in the iri_wam_reproduce_trajectory.srv file?

and the package unit_5_services has dependencies rospy and iri_wam_reproduce_trajectory, so the dependencies are other packages? or pieces of code? I do not have a clear understanding of dependencies. If you could help me out explaining it would be great. Thanks!

You know when you run the following command, after starting the service as explained in the exercise:

user:~$ rosservice info /execute_trajectory
Node: /iri_wam_reproduce_trajectory
URI: rosrpc://5_xterm:44851
Type: iri_wam_reproduce_trajectory/ExecTraj
Args: file

And you also know this by checking the .srv file name:

user:~$ roscd iri_wam_reproduce_trajectory
user:/home/simulations/public_sim_ws/src/all/iri_wam/iri_wam_reproduce_trajectory$ ll
total 40
drwxr-xr-x  5 user user 4096 Mar  5 11:08 ./
drwxr-xr-x 10 user user 4096 Mar  5 11:08 ../
-rwxr-xr-x  1 user user 5753 Mar  5 11:08 CMakeLists.txt*
drwxr-xr-x  2 user user 4096 Mar  5 11:08 config/
drwxr-xr-x  2 user user 4096 Mar  5 11:08 launch/
-rwxr-xr-x  1 user user 5818 Mar  5 11:08 main.cpp*
-rwxr-xr-x  1 user user 2192 Mar  5 11:08 package.xml*
drwxr-xr-x  2 user user 4096 Mar  5 11:08 srv/
user:/home/simulations/public_sim_ws/src/all/iri_wam/iri_wam_reproduce_trajectory$ cd srv
user:/home/simulations/public_sim_ws/src/all/iri_wam/iri_wam_reproduce_trajectory/srv$ ll
total 12
drwxr-xr-x 2 user user 4096 Mar  5 11:08 ./
drwxr-xr-x 5 user user 4096 Mar  5 11:08 ../
-rwxr-xr-x 1 user user   16 Mar  5 11:08 ExecTraj.srv*

When you want to use code from other packages in your package, you have to include them as dependencies. “Other packages” could be:

  • built-in ROS packages like rospy, roscpp, etc
  • user-created packages like iri_wam_reproduce_trajectory