Function rclcpp::on_shutdown

Function Documentation

void rclcpp::on_shutdown(std::function<void()> callback, rclcpp::Context::SharedPtr context = nullptr)

Register a function to be called when shutdown is called on the context.

If nullptr is given for the context, then the global context is used, i.e. the context initialized by rclcpp::init().

These callbacks are called when the associated Context is shutdown with the Context::shutdown() method. When shutdown by the SIGINT handler, shutdown, and therefore these callbacks, is called asynchronously from the dedicated signal handling thread, at some point after the SIGINT signal is received.

See also

rclcpp::Context::on_shutdown()

Parameters:
  • callback[in] to be called when the given context is shutdown

  • context[in] with which to associate the context