Robotics StackExchange | Archived questions

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.

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")

Asked by zeynep on 2016-10-18 14:06:39 UTC

Comments

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?

Asked by ahendrix on 2016-10-19 02:30:09 UTC

This code is right, you can check this out by invoke $ rostopic echo /counter (called after: $ roscore and $ rosrun basics deneme.py)

Asked by abrzozowski on 2016-10-19 11:55:33 UTC

Answers

I got it..I was expecting the program to print the screen but it just publishes the message. It is ok now.

Asked by zeynep on 2016-10-19 15:29:35 UTC

Comments