Use of sleep() on real hardware

asked 2013-09-18 02:57:10 -0600

alfa_80 gravatar image

updated 2014-01-28 17:17:59 -0600

ngrennan gravatar image

I found an inconsistent behaviour between using on simulation environment and on real hardware(robot). The following code snippet is what has been used on a real hardware(by commenting r.sleep() and rospy.sleep(1)). What I don't understand is that why the code that works on simulation requires commenting on those sleep() functions in order to make it working on a real hardware.

if __name__ == '__main__':               
rospy.init_node('my_node', anonymous=True)    
oaa = obs_armj_all()    
r = rospy.Rate(100)   
while not rospy.is_shutdown():
   try:
       oaa.listener()
       #r.sleep()
       #rospy.sleep(1)
       #rospy.spin()
   except rospy.ROSInterruptException:
       pass

I would highly appreciate if somebody can explain on the underlying concept behind this kind of behaviour.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

Do you still have using_sim_time set on the real hardware tests?

tfoote gravatar image tfoote  ( 2013-11-12 06:36:53 -0600 )edit

No, "using_sim_time" is only set on the simulation.

alfa_80 gravatar image alfa_80  ( 2013-12-17 20:03:40 -0600 )edit

can you clarify what the different behaviors are that you are seeing more clearly in each case and what you expect in each case?

tfoote gravatar image tfoote  ( 2013-12-21 21:29:20 -0600 )edit

Why do you use all these different sleeps together? Also the while construction that you use seems very strange to me. Firstly, you somehow use 3 different sleeps, since rospy.spin is somehow a sleep https://answers.ros.org/question/3321... also rospy.spin() and while rospy.is_shutdown() are not the same but it seems strange to use them together, see https://get-help.robotigniteacademy.c...

Bernat Gaston gravatar image Bernat Gaston  ( 2020-07-28 03:57:40 -0600 )edit