ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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]

asked 2016-10-18 14:12:22 -0500

zeynep gravatar image

updated 2016-10-19 01:34:01 -0500

mgruhler gravatar image

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")
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by zeynep
close date 2016-10-19 15:30:02.540318

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?

ahendrix gravatar image ahendrix  ( 2016-10-19 02:30:09 -0500 )edit

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

abrzozowski gravatar image abrzozowski  ( 2016-10-19 11:55:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-19 15:29:35 -0500

zeynep gravatar image

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-18 14:06:39 -0500

Seen: 1,667 times

Last updated: Oct 19 '16