Robotics StackExchange | Archived questions

Cannot import custom message using rospy (Groovy)

I have several custom messages created. I can safely import all of them except for one. Running rosmsg show finds the message. I have done the catkinmake and rebuilt the project. The auto-generated header for the message file exists in devel/include. The message is included in `addmessagefiles()` in CMakeLists.txt. Despite all of this, I have a script (i.e., mypack/scripts/my_script.py) that tries:

from my_pack.msg import MyMessageType1, MyMessageType2 

gives me

ImportError: cannot import name MyMessageType2

I can't see any differences between MyMessageType1 and MyMessageType2. Does anyone have any ideas on what could cause an error like this?

EDIT: I have seen this question: http://answers.ros.org/question/52687/cannot-find-custom-message-groovy/ in which the problem might have been the message being inconsistently named. This is not the case for me, the message is the same name everywhere.

Asked by kamek on 2013-01-18 03:43:49 UTC

Comments

Please explain more carefully where you tried to import MyMessageType2. Check devel/lib/python2.7/dist-packages/my_pack/msg/init.py, and _MyMessageType2.py for anything odd. The only other thing I could imagine is that you use the installspace instead of develspace, but have not installed yet.

Asked by KruseT on 2013-01-18 04:27:30 UTC

@KruseT I updated the question to include where I tried the import (catkin_workspace/src/my_pack/scripts/my_script.py). I have a setup.py that includes all the scripts in the scripts folder and catkin_python_setup() is called from CMakeLists.txt. I do not have an install space, only a devel space.

Asked by kamek on 2013-01-18 05:04:08 UTC

@KruseT I can't see anything odd in the files you mentioned. __init__.py has both from _MyMessageType1 import * and from _MyMessageType2 import *, and _MyMessageType1.py and _MyMessageType2.py look very similar (with the fields being slightly different, of course).

Asked by kamek on 2013-01-18 05:07:49 UTC

Same problem here... any solution yet? Have you found the cause?

Asked by Hendrik Wiese on 2013-07-24 00:23:01 UTC

How this question is "not relevant" ... ???

Asked by Kansai on 2021-02-18 20:32:42 UTC

Answers