February 2020
Intermediate to advanced
432 pages
10h 50m
English
To ensure we respect the acquisition rate of 1 Hz, we apply the sleep method to the rate object that we defined above (for which we set a frequency of 1 Hz, that is, one cycle per second):
rate.sleep()
Bear in mind that this does not block ROS execution (it just blocks the script of this node), that is, just the code of this distance_sensor node. If there were other nodes in the environment, then they would have their own independent execution threads. If you were using a native asynchronous language such as JavaScript, then you could also run asynchronous code within the node and also avoid the blockage in the execution of the script, that is, your node could be executing other lines while waiting for the next ...
Read now
Unlock full access