Ros basics in 5 days example 6.8

I can’t get the example 6.8 to work. Whenever i try to run the code i get the following error message:

Traceback (most recent call last):
File “/home/user/catkin_ws/src/my_custom_srv_msg_pkg/src/scripts/custom_service_server.py”, line 4, in
from my_custom_srv_msg_pkg.srv import MyCustomServiceMessage, MyCustomServiceMessageResponse # you import the service message python classes
ModuleNotFoundError: No module named ‘my_custom_srv_msg_pkg’

Does anyone have a solution for this?

Hi @Maartenschu

Welcome to the Community!

This can happen if you have not created or compiled the message or have not sourced the workspace on the terminal where you are running the code:

  • Ensure you have made the necessary modifications to create the message.
  • Compile using catkin_make. It must finish cleanly.
  • Source on every shell where you want to use the message or run any program using the message:
source ~/catkin_ws/devel/setup.bash
  • Check that the message exists
rosmsg list
  • If you cannot find the message in the list, please start go over the procedure again and correct any errors.

Hi, I’ve also been having this same issue even after sourcing the workspace and copy/pasting everything in it’s designated place in the directory. I’m still not sure what is going on. I’ve compiled and sourced the workspace many times and I see it in rossrv list

@erbrauch
I don’t understand what you mean by copying and pasting, but that may be the problem here. You are not expected to merely copy and paste in this exercise.

You’re expected to create a package of your own and modify it accordingly for creating the custom message, following (and not necessarily copying) the examples given. The purpose of the examples is to show you how to do it.

What you can try if everything was setup properly:

cd ~/catkin_ws
rm -rf build/ devel/
catkin_make
source devel/setup.bash # run source ~/catkin_ws/devel/setup.bash on every other terminal

I understand that, I merely copy and pasted the package.xml files and the CMakeLists.txt as instructed. I then took it a step further and checked the solutions and made a copy of the package there and that also didn’t work, throwing the same error. Here is what it is throwing now after running those commands. I’m not sure if it’s something I’m doing in the terminal or were the .srv file is located. Thanks


it is also showing some folders in red, I am not sure if this helps or not

I figured out the problem, there was another package that was preventing catkin_make to execute properly when I was compiling my service message. I would not have been able to find it without those commands so thank you!

1 Like

This topic was automatically closed after 20 hours. New replies are no longer allowed.