Ask Your Question

rospy.sleep doesn't get awaken

asked 2011-11-01 09:29:25 -0500

130s gravatar image

updated 2011-11-01 12:16:33 -0500

Only on one of my machine, this elementary subscribe/publishing tutorial (WritingPublisherSubscriber(python)) doesn't work. In, thread never returns from rospy.sleep(t) (t can be double number). On my other machine this doesn't happen. Any idea?


  • where problem occurs: Ubuntu 11.04, electric, Python 2.7.1+
  • where does not: Ubuntu 10.10, electric, Python 2.6.6

Looking at these diff, I just tried to use python 2.6.6 (by downgrading like this), and found no effect.

Source code (exactly the same with the one in the tutorial page):

#!/usr/bin/env python
import roslib; roslib.load_manifest('beginner_tutorials')
import rospy
from std_msgs.msg import String
def talker():
    pub = rospy.Publisher('chatter', String)
    while not rospy.is_shutdown():
        str = "hello world %s"%rospy.get_time()
if __name__ == '__main__':
    except rospy.ROSInterruptException: pass

Update) It also occurred when I use C++ version of the same tutorial.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-11-01 12:19:41 -0500

130s gravatar image

updated 2011-11-01 12:20:10 -0500

Solved - After I reboot OS, this phenomenon has stopped to happen. Still don't know the root cause though...The last time OS was rebooted was for a few days ago and I hibernated it a few times.

edit flag offensive delete link more

answered 2011-11-01 20:00:42 -0500

Lorenz gravatar image

I suspect that the parameter /use_sim_time was set to True. Maybe you started either stage or gazebo before?

When /use_sim_time is set and no time provider is running, all ROS sleep methods will just block infinitely.

edit flag offensive delete link more


@Lorenz thanks. I'll keep that parameter in mind although now I can't reproduce the phenom. I haven't explicitly turned it on but is there any trigger that could make the parameter on without knowing?
130s gravatar image 130s  ( 2011-11-02 03:46:19 -0500 )edit

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: 2011-11-01 09:29:25 -0500

Seen: 2,758 times

Last updated: Nov 01 '11