Ask Your Question
0

Cannot import my self-defined msg in ROS using Python

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

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 -0600

pavel92 gravatar image

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

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 imagedrodgu ( 2019-10-15 12:50:30 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 19 times

Last updated: Oct 15