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

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 talker.py, thread never returns from rospy.sleep(t) (t can be double number). On my other machine this doesn't happen. Any idea?

Environment:

  • 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)
    rospy.init_node('talker')
    while not rospy.is_shutdown():
        str = "hello world %s"%rospy.get_time()
        rospy.loginfo(str)
        pub.publish(String(str))
        rospy.sleep(1.0)
if __name__ == '__main__':
    try:
        talker()
    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
1

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
7

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

Comments

1
@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

Question Tools

Stats

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

Seen: 3,311 times

Last updated: Nov 01 '11