ImportError : No module named xxx.msg. CMakeLists.txt, package.xml, terminal output, code

asked 2019-05-07 10:41:37 -0600

Nurbek gravatar image

updated 2019-05-08 01:26:44 -0600

Hi,

I am very tired trying more and more, but I want to try unless i accomplish.

I have already read dozens of ros.org links and watched two popular youtube videos according to this ImportError problem:

https://www.youtube.com/watch?v=NKeeb...

https://www.youtube.com/watch?v=ZPmlF...

I am doing exactly as they say, however at the end I still get this f**king error ImportError!!

Please, help me who is aware of this problem.

I have changed Cmakelists, package.xml, everything everything, but still((( Everything is going exactly the same as these videos, but at the last minutes of video I am getting ImportError

edit retag flag offensive close merge delete

Comments

1

Can you post some information about your problem? To help you we'd need to see the exact error and your CMakeLists.txt and package.xml

Carl D gravatar imageCarl D ( 2019-05-07 13:22:01 -0600 )edit

Thanks.

My package.xml (besides comments):

<buildtool_depend>catkin</buildtool_depend> <build_depend>message_generation</build_depend> <exec_depend>message_runtime</exec_depend>

My CMakeLists.txt(the places where I made changes):

find_package(catkin REQUIRED COMPONENTS std.msgs message_generation )

add_message_files( FILES Robotjon.msg )

generate_messages( DEPENDENCIES std_msgs
)

catkin_package(

CATKIN_DEPENDS message_runtime

)

My python code:

#! /usr/bin/env python

import rospy

from mode_publishers.msg import Robotjon

rospy.init_node('topic_publisher') pub = rospy.Publisher('/topic_ex', Robotjon, queue_size=1) rate=rospy.Rate(2) message = Robotjon() message.custom_msg = "Hello World"

while not rospy.is_shutdown(): pub.publish(message) rate.sleep()

My Robotjon.msg:

string custom_msg

My Robotjon.msg file is inside the mode_publishers package

Nurbek gravatar imageNurbek ( 2019-05-07 13:43:28 -0600 )edit

I don't see anything obviously wrong with the snippets you've posted. Here's some things to check: 1. Is Robotjon.msg in the mode_publishers/msg directory. 2. Are there any spelling mistakes? Maybe an extra _ or an i instead of a j? 3. Do you get any errors when you run catkin_make? 4. Does the package name in the package.xml file match the package name in the CMakeLists.txt? 5. After you source devel/setup.bash what do you have in your PYTHONPATH environment variable? Does mode_publishers show up?

Carl D gravatar imageCarl D ( 2019-05-07 14:55:39 -0600 )edit
  1. Yes, Robotjon is in the mode_publishers/msg directory.
  2. No,everything is true. It is j, not i
  3. No errors during catkin_make. But one thing I noticed. In the youtube videos, when they did catkin_make, they got something with percentages. 10%, 20%, ..... 100% accomplished. In my case, there were not such percentages in my terminal during compiling.
  4. Yes, they match: everywhere it is mode_publishers
  5. Let me check...
Nurbek gravatar imageNurbek ( 2019-05-07 16:33:16 -0600 )edit

When I am running rosmsg show Robotjon:

mode_publishers/Robotjon:
string custom_msg

I think everything is ok

Nurbek gravatar imageNurbek ( 2019-05-07 16:50:01 -0600 )edit

BUT During running catkin_make I noticed that there are no such messages in my terminal during compiling like in youtube videos:

[16%] BUILT TARGET <name of package>_generate_messages Scanning dependencies..... [33%] BUILT TARGET <name of package>_generate_messages Scanning dependencies..... [50%] BUILT TARGET <name of package>_generate_messages Scanning dependencies..... [66%] BUILT TARGET <name of package>_generate_messages Scanning dependencies..... [83%] BUILT TARGET <name of package>_generate_messages Scanning dependencies..... [100%] BUILT TARGET <name of package>_generate_messages Scanning dependencies.....

Nurbek gravatar imageNurbek ( 2019-05-07 16:59:40 -0600 )edit

@Nurbek can you please update your question with this information (code, package.xml, CMakelists.txt, terminal output)? Having this information in the comments in the comments makes your question difficult to follow.

jayess gravatar imagejayess ( 2019-05-07 18:52:38 -0600 )edit

Also, did you source your setup.bash file? I.e., run

source devel/setup.bash

from the root of your workspace?

jayess gravatar imagejayess ( 2019-05-07 19:55:12 -0600 )edit