Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to call through to dds layer to notify about new network interfaces #2086

Draft
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions rclcpp/include/rclcpp/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ RCLCPP_PUBLIC
std::vector<const char *>
get_c_vector_string(const std::vector<std::string> & strings_in);

/// Call dds to notify about new network interfaces.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This layer shouldn't assume that the underlying middleware is a DDS.
Maybe the comment should say something like "Notify middleware to refresh available network interfaces?"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alsora good point - will change that.

/**
* \param[in] context is the default ROS context.
*/
RCLCPP_PUBLIC
void
notify_new_networks(Context::SharedPtr context);

} // namespace rclcpp

#endif // RCLCPP__UTILITIES_HPP_
12 changes: 12 additions & 0 deletions rclcpp/src/rclcpp/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "rcl/error_handling.h"
#include "rcl/rcl.h"
#include "rcl/node.h"

namespace rclcpp
{
Expand Down Expand Up @@ -227,4 +228,15 @@ get_c_vector_string(const std::vector<std::string> & 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