ros::sleep::sleep()
时间: 2023-09-07 16:13:16 浏览: 150
sleep
The sleep() function in ROS (Robot Operating System) is a function that causes the current thread to sleep for a specified amount of time. It is used to delay the execution of a program or a specific part of a program in order to synchronize with other processes, wait for data to arrive, or simply to avoid overloading the system.
The syntax for the sleep() function is:
```
void sleep(double sec);
```
Here, sec is the number of seconds to sleep.
For example, if we want to make the current thread sleep for 1 second, we can use the following code:
```
ros::Duration(1.0).sleep();
```
This will pause the execution of the current thread for 1 second.
Note that the sleep() function is a blocking function, which means that it will prevent the current thread from executing any other code until the sleep time is completed.
阅读全文