Error in Importing Custom Message Types in a Python File in Eclipse
I have created a msgs package containing a msg folder which contains the custom messages in .msg format. When I try to import the .msg files in eclipse from my module in python, eclipse gives an error that " No Module Named msgs.msg".
The exact code I use is -
from msgs.msg import FloatStamped, FloatArrayStamped, waypointnavigationstatus
The folder structure is like this
surveying - package name
src
module.py (This is where I try to import the msg files)
msgs - package name
msg - folder containing .msg files
FloatStamped.msg, FloatArrayStamped.msg, waypoint_navigation_status.msg
Can anybody please help??
Thanks
Asked by ish45 on 2014-10-24 10:44:11 UTC
Comments
I guess you haven't forgotten to build the package containing the custom message? Can you find it with
rosmsg list
? Did you rebuild your index in Eclipse(not sure about Python)?You might want to check that Eclipse is starting as an interactive shell and that your workspace is properly sourced.
Asked by al-dev on 2014-10-24 20:41:48 UTC
Yes, when I do rosmsg list, the messages do show up on the terminal. Also, I have launched eclipse from the terminal. And I have also rebuild the project. But still it is unable to detect the msg folder. I have also changed the CMakeLists.txt and the package.xml files to detect the msg files.
Asked by ish45 on 2014-10-25 05:16:52 UTC
Do you have any other idea? It detects the built in msg files like std_msgs, nav_msg. But it is unable to detect only the custom message files. I would be very grateful if anybody could help me solve this problem.
Asked by ish45 on 2014-10-25 05:18:32 UTC
Is your python script called by the same name as your package by any chance, i.e msgs.py ?This problem has been solved here : http://answers.ros.org/question/113671/catkin-package-cannot-find-own-message-type-python/
As a side note, you might want to choose a more explicit package name than "msgs".
Asked by al-dev on 2014-10-25 12:09:56 UTC
Yes. But my package name is very different from my python script name. There might have been many people who might have faced this problem when importing custom message types in ROS, I am surprised not many people are responding to my problem.
I hope many of you would try to help me out. Thanks
Asked by ish45 on 2014-10-25 12:58:07 UTC
Could you post the entire code of your python script?
Asked by al-dev on 2014-10-25 13:02:49 UTC