Custom message with rosbuild & rospy [No module named *]

asked 2017-04-03 10:43:01 -0500

persuasiv gravatar image


I'am trying to build a ros node which use a custom message. I have installed ROS Indigo on Ubuntu 12.04. The workspace I use is rosbuild and the code is in Python.

The problem I am facing with is that I'm unable to import the custom message I just created. The import statement for my message is the following:

from roi_py.msg import *


from roi_py.msg import sendMsg

Where "sendMsg" is the name of my message located in msg/sendMsg.msg

But the result is the following:

user@system:~/ROS_Workspace/sandbox/roi_py$ rosrun roi_py 
Traceback (most recent call last):
  File "/home/user/ROS_Workspace/sandbox/roi_py/scripts/", line 10, in <module>
    from roi_py.msg import *
ImportError: No module named roi_py.msg

In the same project I also have some CPP files. In those file I can use my messages and works. It looks like only Python is not recognizing my custom messages.

Also the package path seems to be good:

user@system:~/ROS_Workspace/sandbox/roi_py$ echo $ROS_PACKAGE_PATH 

PS: However, the statement to include standard messages is working:

from std_msgs.msg import String

Do you guys have any idea?

PS: rosbuild_genmsg() is also uncommented on CMakeLists.txt

And the tree of roi_py looks like:

├── bin
├── CMakeLists.txt
├── lib
├── mainpage.dox
├── Makefile
├── manifest.xml
├── msg
│   ├── recvMsg.msg
│   └── sendMsg.msg
├── scripts
│  └──
└── src
    └── roi_py
edit retag flag offensive close merge delete



If you are using ROS Indigo, you should definitely be using catkin instead of rosbuild. rosbuild was deprecated several releases ago, and you are less likely to run into problems and more likely to get help if you switch to the more modern build system.

jarvisschultz gravatar image jarvisschultz  ( 2017-04-03 12:39:44 -0500 )edit

I will try to go with catkin then. Thank you, didn't know that rosbuild is outdated.

persuasiv gravatar image persuasiv  ( 2017-04-04 10:06:28 -0500 )edit

@jarvisschultz: Can't believe. The same error on catkin workspace after followed all instructions step by step from tutorials...

persuasiv gravatar image persuasiv  ( 2017-04-04 15:13:37 -0500 )edit

I think you may be having the same problem as in this question:

lindzey gravatar image lindzey  ( 2017-04-05 04:24:02 -0500 )edit