ZeroDivisionError: float division by zero
How to fix this issue. I followed this video here
This full code:
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
rate1 = 30
rate2 = 1
msg1 = "30 hz"
msg2 = "1 hz"
def callbsck1(event):
pub_1.publish(msg1)
def callbsck2(event):
pub_2.publish(msg2)
if __name__ == '__main__':
rospy.init_node('async_publish')
pub_1 = rospy.Publisher ('topic1', String, queue_size=10)
pub_2 = rospy.Publisher('topic2', String, queue_size=10)
rospy.Timer(rospy.Duration(1/rate1), callbsck1)
rospy.Timer(rospy.Duration(1 / rate2), callbsck2)
rospy.spin()
This error:
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/timer.py", line 221, in run
r = Rate(1.0 / self._period.to_sec(), reset=self._reset)
ZeroDivisionError: float division by zero