Error in Importing Custom Message Types in a Python File in Eclipse [closed]

asked 2014-10-24 10:44:11 -0500

ish45 gravatar image

updated 2014-10-24 10:47:05 -0500

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, waypoint_navigation_status

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2020-12-18 13:36:53.146959

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.

al-dev gravatar image al-dev  ( 2014-10-24 20:41:48 -0500 )edit

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.

ish45 gravatar image ish45  ( 2014-10-25 05:16:52 -0500 )edit

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.

ish45 gravatar image ish45  ( 2014-10-25 05:18:32 -0500 )edit

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/11367...

As a side note, you might want to choose a more explicit package name than "msgs".

al-dev gravatar image al-dev  ( 2014-10-25 12:09:56 -0500 )edit

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

ish45 gravatar image ish45  ( 2014-10-25 12:58:07 -0500 )edit

Could you post the entire code of your python script?

al-dev gravatar image al-dev  ( 2014-10-25 13:02:49 -0500 )edit