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

from testsrv.srv import * [ImportError: No module named testsrv.srv]

asked 2013-07-01 07:09:07 -0500

Verane gravatar image

Hi. I'm trying to make a ROS service, but I'm getting "ImportError: No module named testsrv.srv".

My code is:

#!/usr/bin/python
# -*- coding : utf-8 -*-

from testsrv.srv import *

I've uncommented into the CMakeLists.txt:

#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()

And part of my directory tree is this: http://pastebin.com/882TacQ2

What is the problem? Why can't I import the srv file?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-07-01 08:40:46 -0500

Since it seems like you are using rosbuild and not catkin to build your packages, if you check out the rosbuild version of rospy Publisher and Subscriber tutorial, you'll notice that the Python scripts start with two lines that look like

import roslib; roslib.load_manifest('beginner_tutorials')
import rospy

It looks to me like your test script is just missing these lines. If your manifest.xml is correct, you should just need to convert 'beginner_tutorials' to your package name.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-01 07:09:07 -0500

Seen: 1,370 times

Last updated: Jul 01 '13