ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Cannot import my self-defined msg in ROS using Python

asked 2019-10-15 06:26:28 -0500

drodgu gravatar image

Hi everyone,

I'm quite new in programming using Python, but I need to use it in order to call some libraries in ROS I've downloaded from Github. The thing is that I need to call a msg I've created (it works in ROS using C++), but when I try to load it in a Python script using from my_pkg.msg import my_msg it just exit because of the following error:

ImportError: No module named msg

I've followed the instruction you can find in this tutorial 1 and I've read a lot of topics, but I still cannot solve it. The thing is that for what I can understand from other topics and user answer, Python makes itself a mess and cannot find the module. There's something I might be forgeting. Any idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-15 06:47:48 -0500

pavel92 gravatar image

updated 2019-10-15 06:51:41 -0500

I guess your custom messages are in the package named my_pkg. Add that package in your package.xml so the messages are built before this package is to be used:

<depend>my_pkg</depend>

If you have already done so, you can also check this question.

edit flag offensive delete link more

Comments

I'm sorry I answer you so late. I've tried but failed. The compiler says that you cannot load that package on my_pkg or something like that. Finally I've decided to create a new package with al my messages and use that package messages instead.

Thank you very much for your quick answer!

drodgu gravatar image drodgu  ( 2019-10-15 12:50:30 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-10-15 06:26:28 -0500

Seen: 1,062 times

Last updated: Oct 15 '19