Robotics StackExchange | Archived questions

ImportError

Hi all,

I created a catkin package and defined a custom ros msg. I built it with catkinmake. Msg can be seen through rosmsg. But still my node can not import <packagename>.msg

ImportError: No module named blue_tracker.msg

That is the import command line : *from blue_tracker.msg import **

Meanwhile there is no problem with ros package path.It can reach all other packages like roslib,rospy,smach..etc. I have alrady given two days to this annoying problem.All suggestions are wellcome.

Any ideas?

[more inforrmation as asked]

System:

         Bodhi 2.4.0 ,  Ros Hydro ,  Python  2.7.3 

Ros Package :

         Catkin package "blue_tracker "  with a node trace_face.py

Code : (I blinded out all the parts of code but the ones give error to be able to focus on the problem)


 import roslib
 import roslib
 import rospy
 from sensormsgs.msg import * # no problem with this line
 from bluetracker.msg import * # here is the problem

if name == 'main': rospy.initnode('trackface') print "test"

Error message :

Traceback (most recent call last): File "/home/bdr/catkinws/src/bluetracker/src/trackface.py", line 14, in module from bluetracker.msg import ImportError: No module named blue_tracker.msg

CMakeList.txt :

 cmake_minimum_required(VERSION 2.8.3) 
  project(blue_tracker)
  find_package(catkin REQUIRED COMPONENTS
     cv_bridge
     roscpp
     rospy
     sensor_msgs
     std_msgs
     message_generation)
  find_package(OpenCV REQUIRED) 
     add_message_files(
             FILES
              RoisInFrame.msg)
  generate_messages(
              DEPENDENCIES
              sensor_msgs
              std_msgs)

   catkin_package(
              INCLUDE_DIRS include
              #LIBRARIES blue_tracker
             #CATKIN_DEPENDS cv_bridge roscpp rospy sensor_msgs std_msgs
               DEPENDS system_lib blue_tracker)
    include_directories(
               ${catkin_INCLUDE_DIRS}
               ${OpenCV_INCLUDE_DIRS})

     install(PROGRAMS
                 src/track_face.py src/test_tracking.py
                 DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

Asked by Kaplan on 2014-02-27 04:00:06 UTC

Comments

Did you add the following in your CMakeLists.txt ? find_package(message_generation) add_message_files(FILES blue_tracker.msg) Maybe someone more experienced with catkin can give a more precise answer but you have to generate python/C++ header files of your custom messages, in compilation step.

Asked by Erwan R. on 2014-02-27 04:22:56 UTC

Thank you for your quick reply. For catkin packages there are some adjustments/modifications that must be made under CMakeList.txt and package.xml. As you mentioned one of them is adding add_message_files( FILES ...) command.But in this form : add_message_files(FILES justMessageFileName1.msg)

Asked by Kaplan on 2014-02-27 04:51:19 UTC

The modifications/adjustments in CmakeList.txt and package.xml do the generatin work. As i sad i do not think so that the problem is with message generation.Because catkin_make reports that message are created and it can also be seen by rosmsg.

Thanks anyway.

Asked by Kaplan on 2014-02-27 04:54:34 UTC

Could You elaborate more, please? Providing minimal CMakeList, directory structure, full list of ROS related commands You're executing and Python code sample facing same problem would help helping You tremendously. Also, ROS version? Python version?

Asked by Kamiccolo on 2014-02-27 06:43:46 UTC

As Kamiccolo asked , I edited my question and added some more infos.

Asked by Kaplan on 2014-02-28 03:22:06 UTC

I have been still struggling with the same issue.Any idea?

Asked by Kaplan on 2014-03-06 02:06:19 UTC

Answers