ImportError

asked 2014-02-27 03:00:06 -0500

Kaplan gravatar image

updated 2016-10-24 08:35:59 -0500

ngrennan gravatar image

Hi all,

I created a catkin package and defined a custom ros msg. I built it with catkin_make. Msg can be seen through rosmsg. But still my node can not import <package_name>.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 sensor_msgs.msg import * # no problem with this line
 from blue_tracker.msg import * # here is the problem

 if __name__ == '__main__':
     rospy.init_node('track_face')
     print "test"



Error message :

Traceback (most recent call last):
  File "/home/bdr/catkin_ws/src/blue_tracker/src/track_face.py", line 14, in  module
    from blue_tracker.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})
edit retag flag offensive close merge delete

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.

Erwan R. gravatar image Erwan R.  ( 2014-02-27 03:22:56 -0500 )edit

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)

Kaplan gravatar image Kaplan  ( 2014-02-27 03:51:19 -0500 )edit

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.

Kaplan gravatar image Kaplan  ( 2014-02-27 03:54:34 -0500 )edit
1

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?

Kamiccolo gravatar image Kamiccolo  ( 2014-02-27 05:43:46 -0500 )edit

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

Kaplan gravatar image Kaplan  ( 2014-02-28 02:22:06 -0500 )edit

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

Kaplan gravatar image Kaplan  ( 2014-03-06 01:06:19 -0500 )edit