Make sure that your CMakeLists.txt has rospy, std_msgs and message_generation listed under find_package(catkin REQUIRED COMPONENTS ) it will be in caps make sure it’s also listed in catkin_package CATKIN_DEPENDS . In the package.xml make sure you have <build_depend>message_generation</build_depend>, <build_export_depend>message_runtime</build_export_depend> and <exec_depend>message_runtime</exec_depend>
Finally if this compiles successfully remember to source devel/setup.bash in every terminal you use. Before you start you can also remove your build and devel folders. rm -rf build/ devel/ then re-build with catkin_make and source devel/setup.bash
hskramer, I had the same problem (error message “No module named ‘my_custom_srv_msg_pkg.srv’; ‘my_custom_srv_msg_pkg’ is not a package”), so I followed your recommendations; I double checked the changes to the CMakeLists.txt and package.xml files, and then removed the build and devel folders using rm -rf build/ devel/. When I tried to rebuild with catkin_make, I got the error:
“CMake Error at /opt/ros/noetic/share/genmsg/cmake/genmsg-extras.cmake:271 (message):
Could not find ‘share/rospy/cmake/rospy-msg-paths.cmake’ (searched in
‘/home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic’).”
I think I made a fatal mistake by deleting those folders. I don’t know enough about the catkin building process to know what to do next, so any help would be appreciated. I’m taking the ROS in 5 days course and I’m working on Unit 6, exercise 6.3.
Hi, deleting your build/ and devel/ folders is not a fatal mistake. They are generated in the compilation process, so sometimes it’s a good idea to delete them to “start fresh” when weird things are happening with your setup or your nodes. That error message is strange though, and it doesn’t have to do with those folders. Maybe a good idea would be to re-do the package from scratch. Is this issue happening to you still?
I can understand where your coming from but you have to remember two things; one It is common practice to put code inside a code block. Two and most importantly if you want to become a ROS developer you must pay attention to the details. Writing a CMake file and a package.xml file involves many subtle details far too many to start highlighting in color.