Function rclcpp::sleep_for

Function Documentation

bool rclcpp::sleep_for(const std::chrono::nanoseconds &nanoseconds, rclcpp::Context::SharedPtr context = nullptr)

Use the global condition variable to block for the specified amount of time.

This function can be interrupted early if the associated context becomes invalid due to shutdown()

or the signal handler.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by

rclcpp::init().

Parameters:
  • nanoseconds[in] A std::chrono::duration representing how long to sleep for.

  • context[in] Optional which may interrupt this sleep

Returns:

true if the condition variable did not timeout.