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

Where should I put generated Python srv

asked 2014-05-21 21:56:40 -0500

Mehdi. gravatar image

I looked for it in the tutorials and online but I didn't find anything helpful. After uncommenting the line srv_gen in CMakeFiles.txt and running rosmake, some files are generated including headers for C++ put in include folder and Python scripts which are put into the folder packagename/src/packagename. The generated Python module's name was _myServiceMessagesFile.py for myServiceMessagesFile.srv being my service's messages declaration file that I put in packagename/srv. Then the tutorial says to use "import myServiceMessagesFile.srv" which doesn't work.

I solved this problem by taking the generated .py file from packagename/src/packagename folder and putting it in the same folder as my Python script (for example packagename/scripts) needing this messages, but I feel that this method is more a dirty fix than an elegant solution.

I work with ros groovy and rosbuild. Can somebody give me some hints on what to do?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-05-21 22:39:23 -0500

ahendrix gravatar image

updated 2014-06-03 04:16:54 -0500

You shouldn't have to move the generated service files.

Are you following the rosbuild version of the python service and client tutorial)?

Your import should be:

from mypackage.srv import *
edit flag offensive delete link more

Comments

yes and somehow it doesn't find it. ImportError: No module named GetMeasures.srv

Mehdi. gravatar image Mehdi.  ( 2014-06-03 01:56:41 -0500 )edit
1

The correct form for this import is

from [package].srv import [service]
.

ahendrix gravatar image ahendrix  ( 2014-06-03 04:16:40 -0500 )edit

Thanks. I somehow got confused in the tutorial ending up using myServiceMessagesFile.srv instead of package.srv

Mehdi. gravatar image Mehdi.  ( 2014-06-03 05:02:54 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-21 21:56:40 -0500

Seen: 885 times

Last updated: Jun 03 '14