Skip to content

Commit

Permalink
Update to latest rmw API
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <grey@openrobotics.org>
  • Loading branch information
mxgrey authored and wjwwood committed Mar 21, 2023
1 parent 4e6b4fd commit 4b756ca
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp
Expand Up @@ -63,7 +63,7 @@ init_context_impl(
eprosima_fastrtps_identifier,
context->actual_domain_id,
&context->options.security_options,
&context->options.discovery_params,
&context->options.discovery_options,
context->options.enclave,
common_context.get()),
[&](CustomParticipantInfo * participant_info)
Expand Down
2 changes: 1 addition & 1 deletion rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp
Expand Up @@ -63,7 +63,7 @@ init_context_impl(
eprosima_fastrtps_identifier,
context->actual_domain_id,
&context->options.security_options,
&context->options.discovery_params,
&context->options.discovery_options,
context->options.enclave,
common_context.get()),
[&](CustomParticipantInfo * participant_info)
Expand Down
Expand Up @@ -143,9 +143,9 @@ class ParticipantListener
explicit ParticipantListener(const char *identifier,
rmw_dds_common::Context *context,
const std::string &hostname,
const rmw_discovery_params_t *discovery_params)
const rmw_discovery_options_t *discovery_options)
: context(context), identifier_(identifier), my_hostname_(hostname),
discovery_params_(*discovery_params) {}
discovery_options_(*discovery_options) {}

void on_participant_discovery(
eprosima::fastdds::dds::DomainParticipant *participant,
Expand Down Expand Up @@ -302,14 +302,14 @@ class ParticipantListener
bool should_ignore = false;

if (RMW_AUTOMATIC_DISCOVERY_RANGE_OFF ==
discovery_params_.automatic_discovery_range) {
discovery_options_.automatic_discovery_range) {
return true;
}
if (hostname != my_hostname_) {
if (RMW_AUTOMATIC_DISCOVERY_RANGE_LOCALHOST ==
discovery_params_.automatic_discovery_range ||
discovery_options_.automatic_discovery_range ||
RMW_AUTOMATIC_DISCOVERY_RANGE_DEFAULT ==
discovery_params_.automatic_discovery_range) {
discovery_options_.automatic_discovery_range) {

if (!is_static_peer(hostname, other_static_peers)) {
should_ignore = true;
Expand All @@ -327,14 +327,14 @@ class ParticipantListener
using namespace rmw_fastrtps_shared_cpp;
// Check if the host is a static peer on our list
auto aliases = utils::get_peer_aliases(hostname);
for (size_t ii = 0; ii < discovery_params_.static_peers_count; ++ii) {
if (hostname == discovery_params_.static_peers[ii].peer_address) {
for (size_t ii = 0; ii < discovery_options_.static_peers_count; ++ii) {
if (hostname == discovery_options_.static_peers[ii].peer_address) {
RCUTILS_LOG_DEBUG_NAMED("rmw_fastrtps_shared_cpp",
"Matching host in our static peer list");
return true;
}
if (aliases.count(discovery_params_.static_peers[ii].peer_address) > 0)

if (aliases.count(discovery_options_.static_peers[ii].peer_address) > 0)
{
RCUTILS_LOG_DEBUG_NAMED("rmw_fastrtps_shared_cpp",
"Matching host in our static peer list");
Expand All @@ -358,7 +358,7 @@ class ParticipantListener
rmw_dds_common::Context *context;
const char *const identifier_;
std::string my_hostname_;
rmw_discovery_params_t discovery_params_;
rmw_discovery_options_t discovery_options_;
};

#endif // RMW_FASTRTPS_SHARED_CPP__CUSTOM_PARTICIPANT_INFO_HPP_
Expand Up @@ -37,7 +37,7 @@ create_participant(
const char * identifier,
size_t domain_id,
const rmw_security_options_t * security_options,
const rmw_discovery_params_t * discovery_params,
const rmw_discovery_options_t * discovery_options,
const char * enclave,
rmw_dds_common::Context * common_context);

Expand Down
28 changes: 14 additions & 14 deletions rmw_fastrtps_shared_cpp/src/participant.cpp
Expand Up @@ -64,7 +64,7 @@ static CustomParticipantInfo *__create_participant(
const eprosima::fastdds::dds::DomainParticipantQos &domainParticipantQos,
bool leave_middleware_default_qos, publishing_mode_t publishing_mode,
rmw_dds_common::Context *common_context, size_t domain_id,
const rmw_discovery_params_t *discovery_params, const char *hostname) {
const rmw_discovery_options_t *discovery_options, const char *hostname) {
CustomParticipantInfo *participant_info = nullptr;

/////
Expand Down Expand Up @@ -93,7 +93,7 @@ static CustomParticipantInfo *__create_participant(
// Create Participant listener
try {
participant_info->listener_ = new ParticipantListener(
identifier, common_context, hostname, discovery_params);
identifier, common_context, hostname, discovery_options);
} catch (std::bad_alloc &) {
RMW_SET_ERROR_MSG(
"__create_participant failed to allocate participant listener");
Expand Down Expand Up @@ -190,7 +190,7 @@ int ip_version(const std::string& peer) {
CustomParticipantInfo *rmw_fastrtps_shared_cpp::create_participant(
const char *identifier, size_t domain_id,
const rmw_security_options_t *security_options,
const rmw_discovery_params_t *discovery_params, const char *enclave,
const rmw_discovery_options_t *discovery_options, const char *enclave,
rmw_dds_common::Context *common_context) {
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);

Expand All @@ -207,7 +207,7 @@ CustomParticipantInfo *rmw_fastrtps_shared_cpp::create_participant(
->get_default_participant_qos();

// Configure discovery
switch (discovery_params->automatic_discovery_range) {
switch (discovery_options->automatic_discovery_range) {
case RMW_AUTOMATIC_DISCOVERY_RANGE_OFF: {
// Clear the list of multicast listening locators
domainParticipantQos.wire_protocol()
Expand Down Expand Up @@ -241,18 +241,18 @@ CustomParticipantInfo *rmw_fastrtps_shared_cpp::create_participant(
std::stringstream user_data;

// Add any initial peers
if (discovery_params->static_peers_count > 0 &&
discovery_params->automatic_discovery_range != RMW_AUTOMATIC_DISCOVERY_RANGE_OFF) {
if (discovery_options->static_peers_count > 0 &&
discovery_options->automatic_discovery_range != RMW_AUTOMATIC_DISCOVERY_RANGE_OFF) {
user_data << "staticpeers=";
for (size_t ii = 0; ii < discovery_params->static_peers_count; ++ii) {
for (size_t ii = 0; ii < discovery_options->static_peers_count; ++ii) {
eprosima::fastrtps::rtps::Locator_t peer;
if (ip_version(discovery_params->static_peers[ii].peer_address) == 4) {
if (ip_version(discovery_options->static_peers[ii].peer_address) == 4) {
eprosima::fastrtps::rtps::IPLocator::setIPv4(
peer, discovery_params->static_peers[ii].peer_address);
peer, discovery_options->static_peers[ii].peer_address);
}
else if (ip_version(discovery_params->static_peers[ii].peer_address) == 6) {
else if (ip_version(discovery_options->static_peers[ii].peer_address) == 6) {
eprosima::fastrtps::rtps::IPLocator::setIPv6(
peer, discovery_params->static_peers[ii].peer_address);
peer, discovery_options->static_peers[ii].peer_address);
}
// Not specifying the port of the peer means FastDDS will try all
// possible participant ports according to the port calculation equation
Expand All @@ -261,11 +261,11 @@ CustomParticipantInfo *rmw_fastrtps_shared_cpp::create_participant(
domainParticipantQos.wire_protocol().builtin.initialPeersList.push_back(
peer);

user_data << discovery_params->static_peers[ii].peer_address << ',';
user_data << discovery_options->static_peers[ii].peer_address << ',';

// Add any aliases (IPs for hostnames, hostnames for IPs)
auto aliases = utils::get_peer_aliases(
discovery_params->static_peers[ii].peer_address);
discovery_options->static_peers[ii].peer_address);
for (const auto &alias : aliases) {
user_data << alias << ',';
}
Expand Down Expand Up @@ -396,7 +396,7 @@ CustomParticipantInfo *rmw_fastrtps_shared_cpp::create_participant(
}
return __create_participant(
identifier, domainParticipantQos, leave_middleware_default_qos,
publishing_mode, common_context, domain_id, discovery_params, hostname);
publishing_mode, common_context, domain_id, discovery_options, hostname);
}

rmw_ret_t rmw_fastrtps_shared_cpp::destroy_participant(
Expand Down
14 changes: 7 additions & 7 deletions rmw_fastrtps_shared_cpp/src/rmw_init.cpp
Expand Up @@ -81,11 +81,11 @@ rmw_init_options_copy(
allocator->deallocate(tmp.enclave, allocator->state);
return ret;
}
tmp.discovery_params = rmw_get_zero_initialized_discovery_params();
ret = rmw_discovery_params_copy(
&src->discovery_params,
allocator,
&tmp.discovery_params);
tmp.discovery_options = rmw_get_zero_initialized_discovery_options();
ret = rmw_discovery_options_copy(
&src->discovery_options,
*allocator,
&tmp.discovery_options);
*dst = tmp;
return RMW_RET_OK;
}
Expand All @@ -111,8 +111,8 @@ rmw_init_options_fini(const char * identifier, rmw_init_options_t * init_options
rmw_ret_t ret = rmw_security_options_fini(&init_options->security_options, allocator);
if (ret != RMW_RET_OK)
return ret;
ret = rmw_discovery_params_fini(&init_options->discovery_params, allocator);

ret = rmw_discovery_options_fini(&init_options->discovery_options, *allocator);
*init_options = rmw_get_zero_initialized_init_options();
return ret;
}
Expand Down

0 comments on commit 4b756ca

Please sign in to comment.