Ask Your Question

Creating custom message and service for groovy, using them with Python

asked 2013-02-06 23:10:11 -0500

Manon gravatar image

updated 2014-01-28 17:15:09 -0500

ngrennan gravatar image


I am discovering ROS groovy and I try to create a custom service. I followed the tutorial on creating a service with Python and did a Python node. But when I run my Python node, I get 'from myModuleName.srv import mysrv.srv ImportError : no module named myModuleName'

I checked with rossrv that my service is known, I also tried to follow instructions in 'What's A Catkin?'

I don't know where to look for debug logs or build errors. What should I do ?



PS : the more I think of it, it does not look like the service is faulty, but Python can't find the right files to import.

edit retag flag offensive close merge delete



Please update your question with a link to the tutorial you are following, so people will know what you are doing.

joq gravatar image joq  ( 2013-02-09 07:22:52 -0500 )edit

Well, I don't have enough karma to publish links. The tutorial for catkin is this one : and the python tutorial is the standard create a simple service and client in Python.

Manon gravatar image Manon  ( 2013-02-18 04:40:43 -0500 )edit

Thank you for your help. I will retry and let you know the result. The problem may be that when you click on a link on the tuto you go automatically to the rosmake version so I may have followed the wrong one.

Manon gravatar image Manon  ( 2013-02-18 19:47:41 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-11-28 04:20:15 -0500

Benjamin Blumer gravatar image

It's an old question, but still a top hit on Google. So I'll post a possible solution:

First of all, as dornhege pointed out, your import statement is incorrect. It should be:

from myModuleName.srv import mysrv

Also, have you sourced the setup.bash file in your catkin workspace? It should be at catkin_workspace_name/devel/setup.bash (where catkin_workspace_name is swapped with the name of your catkin workspace). To source it:

source /path/path/path/catkin_workspace_name/devel/setup.bash

You can also add that line to your .bashrc file so that it's automatically sourced every time you open a terminal.

edit flag offensive delete link more


lubuntu 12.4 hydro in almost same env, the solution makes me alive! i spent a whole day to reset my project which copy the service and client example. anyway, just doing 'source ~/CATKIN_WS/devel/setup.bash' solve this problem. i'm so happy now. thanks.

akudoku gravatar image akudoku  ( 2014-01-09 01:07:34 -0500 )edit

answered 2013-02-18 05:32:32 -0500

130s gravatar image

Looks like a python module that is called from other modules isn't generated, although I'm not sure since some info lacking (eg. which command you used to run your python module).

I suspect that you might have not followed creating srv tutorial. Make sure that in CreatingMsgAndSrv tutorial page choose catkin at the TOP OF THE WIKI PAGE so that you will see necessary instruction (in this case adding macro to CMakeLists.txt etc.)

ps. I know this wiki pages structure isn't ideal...I just added clarification to wiki not to miss choosing right build system.

edit flag offensive delete link more

answered 2013-02-18 05:37:50 -0500

dornhege gravatar image

updated 2013-02-18 05:38:43 -0500

Beside the possibly service-not-created error, I think your import is also wrong:

Instead of:

from myModuleName.srv import mysrv.srv


from myModuleName.srv import mysrv
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2013-02-06 23:10:11 -0500

Seen: 1,327 times

Last updated: Nov 28 '13