Unit 5 Services in ROS: Clients


I am going through this Unit and doing the exercise at the end. While creating the service, I found out that in the example given in the course there was a line that I did not understand in the python file: simple_service_client.py

the following: from trajectory_by_name_srv.srv import TrajByName, TrajByNameRequest

I went to the supposed package on the terminal:

roscd trajectory_by_name_srv; ls srv

with this, I found the TrajByName.srv file that we are importing.

However, I could not find the request “TrajByNameRequest”.
I understand that this is the object that we send to the service server aka request. But, I do not know where that naming came from.

Is it something that is created directly with the python file?
Can I name it whatever I want?


Yeah, you can’t find the TrajByNameRequest because this file is generated by the compilation system using the trajectory_by_name.srv . Compiling a service file generates all the request and response versions of python objects including the TrajByName python object. Thats why you cant find it explicitly. Have a look at the custom message generation section for services to understand this concept further

1 Like

As @duckfrost2 mentioned, they are created when you catkin_make the packages in the workspace.

Just wanted to add that the files actually exist somewhere within the workspace, just not inside the src folder of the packages.

They can be found in the devel folder: catkin_ws/devel/lib/python3/dist-packages/[package_name]. Check them out!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.