Use of sleep() on real hardware
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.
Asked by alfa_80 on 2013-09-18 02:57:10 UTC
Comments
Do you still have using_sim_time set on the real hardware tests?
Asked by tfoote on 2013-11-12 07:36:53 UTC
No, "using_sim_time" is only set on the simulation.
Asked by alfa_80 on 2013-12-17 21:03:40 UTC
can you clarify what the different behaviors are that you are seeing more clearly in each case and what you expect in each case?
Asked by tfoote on 2013-12-21 22:29:20 UTC
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/332192/difference-between-rospyspin-and-rospysleep/ 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.com/t/what-is-difference-between-rospy-spin-and-while-not-rospy-is-shutdown/1849
Asked by Bernat Gaston on 2020-07-28 03:57:40 UTC