Skip to content

Commit 440756f

Browse files
author
Sebastian Jakymiw
committed
add function to call rcl
Signed-off-by: Sebastian Jakymiw <[email protected]>
1 parent 37adc03 commit 440756f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

rclcpp/include/rclcpp/utilities.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ RCLCPP_PUBLIC
330330
std::vector<const char *>
331331
get_c_vector_string(const std::vector<std::string> & strings_in);
332332

333+
/// Call dds to notify about new network interfaces.
334+
/**
335+
* \param[in] context is the default ROS context.
336+
*/
337+
RCLCPP_PUBLIC
338+
void
339+
notify_new_networks(Context::SharedPtr context);
340+
333341
} // namespace rclcpp
334342

335343
#endif // RCLCPP__UTILITIES_HPP_

rclcpp/src/rclcpp/utilities.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "rcl/error_handling.h"
2828
#include "rcl/rcl.h"
29+
#include "rcl/node.h"
2930

3031
namespace rclcpp
3132
{
@@ -227,4 +228,15 @@ get_c_vector_string(const std::vector<std::string> & strings_in)
227228
return cstrings;
228229
}
229230

231+
void
232+
notify_new_networks(Context::SharedPtr context)
233+
{
234+
rcl_ret_t ret = rcl_notify_participant_dynamic_network_interface(context->get_rcl_context().get());
235+
if (RCL_RET_OK != ret)
236+
{
237+
exceptions::throw_from_rcl_error(
238+
ret, "failed to notify networks");
239+
}
240+
}
241+
230242
} // namespace rclcpp

0 commit comments

Comments
 (0)