ImportError: No module named my_tutorials.srv [closed]
Hi,
I am trying to learn ROS service and client feature following the tutorial here and here. After following the instructions given in those tutorials, I did catkin_make
and then source devel/setup.bash
and no error message were thrown. To check if the service is in ROS workspace I also performed rossrv show AddTwoInts.srv
and found the following,
[my_tutorials/AddTwoInts]:
int64 a
int64 b
---
int64 sum
[rospy_tutorials/AddTwoInts]:
int64 a
int64 b
---
int64 sum
But after that when I run the server node by doing rosrun my_tutorials add_two_ints_server.py
, I get the following error
ImportError: No module named my_tutorials.srv
. I am not able to figure out the reason of getting this error. Any help to solve the problem is appreciated. For your reference, the catkin workspace can be found here.
Update
The add_two_ints_server.py
is below.
#!/usr/bin/env python
from my_tutorials.srv import AddTwoInts,AddTwoIntsResponse
import rospy
def handle_add_two_ints(req):
print "Returning [%s + %s = %s]"%(req.a, req.b, (req.a + req.b))
return AddTwoIntsResponse(req.a + req.b)
def add_two_ints_server():
rospy.init_node('add_two_ints_server')
s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)
print "Ready to add two ints."
rospy.spin()
if __name__ == "__main__":
add_two_ints_server()
Please provide your add_two_ints_service.py file, your CMakelists. As a side note, for python compiling isn't really going to do much so you really wont ever see errors.
Hi you can find my ros workspace here. Let me know if you need more information.
@anirban can you please put them directly into your question. This way the question is self-contained and won't go stale in the future
Your CMakelists is nearly entirely commented out -- you need to fill out the message definitions and macros at bare minimum.
@jayess I have updated the question with the service node.
@stevemacenski I just have updated the CmakeLists.txt file inside the package. Please let me know if you need more information.
I'm not going to be compiling this myself to debug for you, try some stuff out, I think you're learning and the best way to learn is by doing :)
@stevemacenski I can compile my code. I uploaded the code to get some feedback from those who had this problem before and can point me towards fixing it :)