subscriber node showing error while try running
whenever I want to run the following code in http://wiki.ros.org/rospy_tutorials/T... , that is:
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
def callback(data):
rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)
def listener():
# In ROS, nodes are uniquely named. If two nodes with the same
# node are launched, the previous one is kicked off. The
# anonymous=True flag means that rospy will choose a unique
# name for our 'talker' node so that multiple talkers can
# run simultaneously.
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("chatter", String, callback)
# spin() simply keeps python from exiting until this node
#is stopped
rospy.spin()
if __name__ == '__main__':
listener()
I get the following error at terminal:
from: can't read /var/mail/std_msgs.msg
/home/labid52/catkin_ws/src/hello_world/script/listener.py: line 3: syntax error near unexpected token `('
/home/labid52/catkin_ws/src/hello_world/script/listener.py: line 3: `def callback(data):'