diff --git a/rclcpp/include/rclcpp/utilities.hpp b/rclcpp/include/rclcpp/utilities.hpp index 5b4ea86a6d..5043d8989c 100644 --- a/rclcpp/include/rclcpp/utilities.hpp +++ b/rclcpp/include/rclcpp/utilities.hpp @@ -330,6 +330,14 @@ RCLCPP_PUBLIC std::vector get_c_vector_string(const std::vector & strings_in); +/// Call dds to notify about new network interfaces. +/** + * \param[in] context is the default ROS context. + */ +RCLCPP_PUBLIC +void +notify_new_networks(Context::SharedPtr context); + } // namespace rclcpp #endif // RCLCPP__UTILITIES_HPP_ diff --git a/rclcpp/src/rclcpp/utilities.cpp b/rclcpp/src/rclcpp/utilities.cpp index f300060010..86c28eefa7 100644 --- a/rclcpp/src/rclcpp/utilities.cpp +++ b/rclcpp/src/rclcpp/utilities.cpp @@ -26,6 +26,7 @@ #include "rcl/error_handling.h" #include "rcl/rcl.h" +#include "rcl/node.h" namespace rclcpp { @@ -227,4 +228,15 @@ get_c_vector_string(const std::vector & strings_in) return cstrings; } +void +notify_new_networks(Context::SharedPtr context) +{ + rcl_ret_t ret = rcl_notify_participant_dynamic_network_interface(context->get_rcl_context().get()); + if (RCL_RET_OK != ret) + { + exceptions::throw_from_rcl_error( + ret, "failed to notify networks"); + } +} + } // namespace rclcpp