Hello , I m new in ROS. When I try to run the program below I get error..Program is not working. I can't understand why it is not running. [closed]
code:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Int32
rospy.init_node('topic_publisher')
pub = rospy.Publisher('counter', Int32, queue_size = 10)
r = rospy.Rate(1)
count = 0
while not rospy.is_shutdown():
pub.publish(count)
count += 1
r.sleep()
ERROR:
File "/home/baris/catkin_ws/src/basics/src/deneme.py", line 12, in <module>
r.sleep()
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 99, in sleep
sleep(self._remaining(curr_time))
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/timer.py", line 157, in sleep
raise rospy.exceptions.ROSInterruptException("ROS shutdown request")
Looks OK to me. Does it print the error message as soon as you start it, or does it only print the error when you stop it with Ctrl-C?
This code is right, you can check this out by invoke
$ rostopic echo /counter
(called after:$ roscore
and$ rosrun basics deneme.py
)