Ask Your Question

rospy service question, how to specify service type

asked 2013-03-13 22:02:03 -0500

mugetsu gravatar image

I'm trying to understand the tutorial here for rospy and services: When the code does:

s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)

I dont see how AddTwoInts is specified in the example code. I have a vague understanding that it should be an object storing all the data from AddTwoInts.srv, i dont know if thats correct?

But in python, how do I actually load the contents of AddTwoInts.srv into the object AddTwoInts?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-14 05:49:20 -0500

tbh gravatar image

You are correct that AddTwoInts is an object. You imported it with the from beginner_tutorials.srv import * command.

Please note that the following explanation applies to rosbuild. I haven't tried catkin just yet, and things are different there.

Anyway, in rosbuild, the generation of the python module happens when you run the command rosmake. There's a macro you put in the CMakeLists.txt file, rosbuild_gensrv() that does it for you. This is why you still have to occasionally run rosmake even if you're using python.

(If I understand correctly, the same thing is happening in catkin, just without macros and using python or built in cmake macros instead. But like I said, I haven't actually tried it...)

If you'd like to look at the generated code, it should be in beginner_tutorials/src/beginner_tutorials/srv/

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-03-13 22:02:03 -0500

Seen: 264 times

Last updated: Mar 14 '13