February 2020
Intermediate to advanced
432 pages
10h 50m
English
Using the Rate method, we can set the reading frequency to 1 Hz (this is equal to 1 sample per second; in SI units) as follows:
rate = rospy.Rate(rospy.get_param('~hz', 1))
We do this by defining a ROS parameter at the same time whose name is as follows (remember the meaning of the ~ symbol):
distance_sensor/hz
With this setup, the sensor will be read once per second.