Ask Your Question

Problems with ROS/Tutorials/ WritingServiceClient(python)

asked 2014-04-07 15:53:52 -0600

Morpheus gravatar image

I am trying to run tutorial , WritingServiceClient(python) on Hydro. After rosrun beginner_tutorials, I get the following errors :

from: can't read /var/mail/beginner_tutorials.srv /home/brent/catkin_ws/src/beginner_tutorials/scripts/ line 4: import: command not found /home/brent/catkin_ws/src/beginner_tutorials/scripts/ line 6: syntax error near unexpected token (' /home/brent/catkin_ws/src/beginner_tutorials/scripts/ line 6: def handle_add_two_ints(req):'

The text was copied and pasted from the tutorial text accept the line numbers.

Any help would be appreciated.

Thank you.

edit retag flag offensive close merge delete


!/usr/bin/env python

from beginner_tutorials.srv import * 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()

you can find it here

naaj gravatar image naaj  ( 2021-01-20 10:22:44 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-04-27 20:33:06 -0600

Yantian_Zha gravatar image

Hi Morpheus, add #!/usr/bin/env python at your first line.

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: 2014-04-07 15:53:52 -0600

Seen: 1,132 times

Last updated: Apr 27 '14