Hello. I am facing an Import Error when I try to launch/run my custom srv message file. It gives me the following error:
I have already done:
- catkin_make and source devel/setup.bash in the terminal I am using
- changed the CMakeLists.txt and package.xml file according to the instructions (there might be issues here tho)
Can someone please help me out?
Thanks
Hi @n.pradhan,
Whatâs your output for rossrv ?
Do you get something like this
rossrv show package_name/MyCustomServiceMessage
[package_name/MyCustomServiceMessage]:
int32 duration
---
bool success
2 Likes
Hello. Yes I get the following:
@n.pradhan, that looks good.
Please go through this post(attached below) if you havenât already it deals with the same issue, if going through the post doesnât resolve your problem, maybe you can post your package.xml and CMakeLists.txt files here so that we can check if something is missing there.
Post Link: No module named my_custom_srv_msg_pkg.srv how to resolve this error?
1 Like
@textzip Thanks for the help. I already tried everything in the post you linked. Removing the build folder and rebuilding it gave me a âInvoking cmake failedâ error. Here is my CMakeList.txt and package.xml files:
Hi,
Try adding message_runtime to ur catkin_package() like this, redo catkin_make, source and then check.
catkin_package(
CATKIN_DEPENDS rospy message_runtime
)
I know the notebook from the course doesnât add message_runtime but the ROS wiki page here shows that we should, http://wiki.ros.org/catkin/CMakeLists.txt#Messages.2C_Services.2C_and_Action_Targets
1 Like
@textzip I tried that but still got the same ImportError
Hmm, Iâm not really sure where the error is maybe one of the moderators can help you better.
@bayodesegun
1 Like
@textzip ooh ok. Thank you very much for your time tho
Hi, did you delete your build/
and devel/
folders before compiling again?
1 Like
@roalgoal Hi. Yea I tried copying the build/ and devel/ folders outside the catkin_ws/ folder into a new temporary backup folder (because I didnât want to delete it completely) then using catkin_make in the catkin_ws/ folder but I got a âInvoking cmake failedâ error which I could not get rid of.
Here is the error:
CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
Could not find a package configuration file provided by âodometry_pkgâ with
any of the following names:
odometry_pkgConfig.cmake
odometry_pkg-config.cmake
Add the installation prefix of âodometry_pkgâ to CMAKE_PREFIX_PATH or set
âodometry_pkg_DIRâ to a directory containing one of the above files. If
âodometry_pkgâ provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
odometry_pkg/CMakeLists.txt:10 (find_package)
â Could not find the required component âodometry_pkgâ. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by âodometry_pkgâ with
any of the following names:
odometry_pkgConfig.cmake
odometry_pkg-config.cmake
Add the installation prefix of âodometry_pkgâ to CMAKE_PREFIX_PATH or set
âodometry_pkg_DIRâ to a directory containing one of the above files. If
âodometry_pkgâ provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
odometry_pkg/CMakeLists.txt:10 (find_package)
â Configuring incomplete, errors occurred!
See also â/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.logâ.
See also â/home/user/catkin_ws/build/CMakeFiles/CMakeError.logâ.
Invoking âcmakeâ failed
Hi,
Donât worry about copying the build/
and devel/
folders to a backup folder, thatâs probably whatâs causing the error. Those folders are created every time you run catkin_make
, and when you move them, the system canât create new ones because the dependencies for the old folders are still there since you havenât deleted them. Do this instead:
cd catkin_ws
rm -rf build/
rm -rf devel/
catkin_make
2 Likes
I was having the same problem, I removed the /build and /devel folders and I am now able to launch the service, however Iâm not able to call the service:
ERROR: Unable to load type [my_custom_srv_msg_pkg/MyCustomServiceMessage].
Have you typed âmakeâ in [my_custom_srv_msg_pkg]?
I verified that the my_custom_srv_msg_pkg was there, but when I try to get information about the service I get:
Any ideas?
Thanks in advance
1 Like
Hi @lucas.gallindo.costa, Itâs most probably because you didnât source your setup.bash in all the terminals where your using the rosservice call
.
Once you logout of your course and come back later you will have to source your terminals again.
3 Likes
Hello,
Doing this solved the ImportError:
cd catkin_ws
rm -rf build
catkin_make --only-pkg-with-deps <your_package_name>
source devel/setup.bash
Thanks everyone for the help.
2 Likes