Ask Your Question

can't access std_srvs

asked 2012-02-24 08:09:05 -0500

cassander gravatar image

The turtlesim node offers a service called "/reset" that allows me to reset the position of the turtle. The type of message accepted by the "/reset" service is of type


I tried to do,

import std_srvs
from std_srvs.srv import Empty

but it didn't work. I kept getting error messages saying std_srvs couldn't be found. I then tried adding 'std_srvs' as one of the dependencies in the manifest file of the package. Now the node was able to access std_srvs but not 'Empty'. Finally I had to do,

roscp std_srvs Empty mypackage/srv

and then rosmake and finally it worked.

Could someone please tell me, why I wasn't able to access std_srv.Empty before copying it to the srv folder in my package?


edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2012-02-24 08:16:21 -0500

DimitriProsser gravatar image

updated 2012-02-24 08:26:17 -0500

You must include the following before importing any ROS packages:

import roslib; roslib.load_manifest('package_name')


You must also have the packages that you want to use in your manifest.xml.

Here's an example... If your package is called "beginner_tutorials", you would put the following in your node:

import roslib; roslib.load_manifest('beginner_tutorials')

If your node uses the std_srvs package, your manifest.xml file must contain the following line:

<depend package="std_srvs" />
edit flag offensive delete link more


I got those errors I mentioned earlier in spite of having that line which you have mentioned. But did you mean to say I should have had the line "import roslib; roslib.load_manifest('std_srvs')"? I don't suppose so..

cassander gravatar image cassander  ( 2012-02-24 08:19:45 -0500 )edit

answered 2014-03-25 08:31:52 -0500

updated 2014-03-25 08:34:02 -0500

i did try this: atention for type Empty into msg and srv

for import msg

from std_msgs.msg import String, Float32, Empty

for import service - without problem Empty

import std_srvs.srv

publish message


call service

rospy.ServiceProxy('ardrone/flattrim', std_srvs.srv.Empty())

good luck!

edit flag offensive delete link more

answered 2022-04-01 16:10:02 -0500

dsoike gravatar image

updated 2022-04-01 16:11:41 -0500

Verify CMakeLists.txt and package.xml Specify std_srvs

If you want to use std_srvs in one of your packages via:

from std_srvs.srv import Trigger, TriggerRequest, TriggerResponse

Make sure your CMakeLists.txt file contains references to std_srvs:

find_package(catkin REQUIRED COMPONENTS
  std_srvs # <-- HERE

  std_srvs # <-- HERE

  CATKIN_DEPENDS rospy std_msgs std_srvs message_runtime # <-- HERE

And your package.xml file contains:

<!-- standard service dependencies -->
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

1 follower


Asked: 2012-02-24 08:09:05 -0500

Seen: 3,923 times

Last updated: Apr 01