Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Implement the rmw_get_publishers/subscriptions_info_by_topic() methods (
Browse files Browse the repository at this point in the history
#391)

Signed-off-by: Miaofei <[email protected]>
  • Loading branch information
mm318 authored Feb 27, 2020
1 parent 72d171c commit ae7117e
Show file tree
Hide file tree
Showing 18 changed files with 874 additions and 148 deletions.
24 changes: 19 additions & 5 deletions rmw_connext_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ rmw_create_client(
RMW_SET_ERROR_MSG("callbacks handle is null");
return NULL;
}

// Past this point, a failure results in unrolling code in the goto fail block.
DDS::SubscriberQos subscriber_qos;
DDS::ReturnCode_t status;
Expand All @@ -90,6 +91,7 @@ rmw_create_client(
ConnextStaticClientInfo * client_info = nullptr;
rmw_client_t * client = nullptr;
std::string mangled_name = "";
rmw_qos_profile_t actual_qos_profile;

// memory allocations for namespacing
char * request_topic_str = nullptr;
Expand Down Expand Up @@ -156,7 +158,7 @@ rmw_create_client(
dds_publisher = request_datawriter->get_publisher();
status = participant->get_default_publisher_qos(publisher_qos);
if (status != DDS::RETCODE_OK) {
RMW_SET_ERROR_MSG("failed to get default subscriber qos");
RMW_SET_ERROR_MSG("failed to get default publisher qos");
goto fail;
}

Expand Down Expand Up @@ -196,23 +198,35 @@ rmw_create_client(
}
memcpy(const_cast<char *>(client->service_name), service_name, strlen(service_name) + 1);

mangled_name =
response_datareader->get_topicdescription()->get_name();
mangled_name = response_datareader->get_topicdescription()->get_name();
status = response_datareader->get_qos(datareader_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("response_datareader can't get data reader qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datareader_qos, &actual_qos_profile);
node_info->subscriber_listener->add_information(
node_info->participant->get_instance_handle(),
response_datareader->get_instance_handle(),
mangled_name,
response_datareader->get_topicdescription()->get_type_name(),
actual_qos_profile,
EntityType::Subscriber);
node_info->subscriber_listener->trigger_graph_guard_condition();

mangled_name =
request_datawriter->get_topic()->get_name();
mangled_name = request_datawriter->get_topic()->get_name();
status = request_datawriter->get_qos(datawriter_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("request_datawriter can't get data writer qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datawriter_qos, &actual_qos_profile);
node_info->publisher_listener->add_information(
node_info->participant->get_instance_handle(),
request_datawriter->get_instance_handle(),
mangled_name,
request_datawriter->get_topic()->get_type_name(),
actual_qos_profile,
EntityType::Publisher);
node_info->publisher_listener->trigger_graph_guard_condition();

Expand Down
11 changes: 9 additions & 2 deletions rmw_connext_cpp/src/rmw_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ rmw_create_publisher(
ConnextStaticPublisherInfo * publisher_info = nullptr;
rmw_publisher_t * publisher = nullptr;
std::string mangled_name = "";
rmw_qos_profile_t actual_qos_profile;

char * topic_str = nullptr;

Expand Down Expand Up @@ -269,16 +270,22 @@ rmw_create_publisher(
publisher->options = *publisher_options;

if (!qos_profile->avoid_ros_namespace_conventions) {
mangled_name =
topic_writer->get_topic()->get_name();
mangled_name = topic_writer->get_topic()->get_name();
} else {
mangled_name = topic_name;
}
status = topic_writer->get_qos(datawriter_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("topic_writer can't get data reader qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datawriter_qos, &actual_qos_profile);
node_info->publisher_listener->add_information(
node_info->participant->get_instance_handle(),
dds_publisher->get_instance_handle(),
mangled_name,
type_name,
actual_qos_profile,
EntityType::Publisher);
node_info->publisher_listener->trigger_graph_guard_condition();

Expand Down
23 changes: 18 additions & 5 deletions rmw_connext_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ rmw_create_service(
ConnextStaticServiceInfo * service_info = nullptr;
rmw_service_t * service = nullptr;
std::string mangled_name = "";
rmw_qos_profile_t actual_qos_profile;

// memory allocations for namespacing
char * request_topic_str = nullptr;
Expand Down Expand Up @@ -164,7 +165,7 @@ rmw_create_service(
dds_publisher = response_datawriter->get_publisher();
status = participant->get_default_publisher_qos(publisher_qos);
if (status != DDS::RETCODE_OK) {
RMW_SET_ERROR_MSG("failed to get default subscriber qos");
RMW_SET_ERROR_MSG("failed to get default publisher qos");
goto fail;
}

Expand Down Expand Up @@ -197,23 +198,35 @@ rmw_create_service(
}
memcpy(const_cast<char *>(service->service_name), service_name, strlen(service_name) + 1);

mangled_name =
request_datareader->get_topicdescription()->get_name();
mangled_name = request_datareader->get_topicdescription()->get_name();
status = request_datareader->get_qos(datareader_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("request_datareader can't get data reader qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datareader_qos, &actual_qos_profile);
node_info->subscriber_listener->add_information(
node_info->participant->get_instance_handle(),
request_datareader->get_instance_handle(),
mangled_name,
request_datareader->get_topicdescription()->get_type_name(),
actual_qos_profile,
EntityType::Subscriber);
node_info->subscriber_listener->trigger_graph_guard_condition();

mangled_name =
response_datawriter->get_topic()->get_name();
mangled_name = response_datawriter->get_topic()->get_name();
status = response_datawriter->get_qos(datawriter_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("response_datawriter can't get data writer qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datawriter_qos, &actual_qos_profile);
node_info->publisher_listener->add_information(
node_info->participant->get_instance_handle(),
response_datawriter->get_instance_handle(),
mangled_name,
response_datawriter->get_topic()->get_type_name(),
actual_qos_profile,
EntityType::Publisher);
node_info->publisher_listener->trigger_graph_guard_condition();

Expand Down
11 changes: 9 additions & 2 deletions rmw_connext_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ rmw_create_subscription(
ConnextStaticSubscriberInfo * subscriber_info = nullptr;
rmw_subscription_t * subscription = nullptr;
std::string mangled_name;
rmw_qos_profile_t actual_qos_profile;

char * topic_str = nullptr;

Expand Down Expand Up @@ -262,16 +263,22 @@ rmw_create_subscription(
subscription->options = *subscription_options;

if (!qos_profile->avoid_ros_namespace_conventions) {
mangled_name =
topic_reader->get_topicdescription()->get_name();
mangled_name = topic_reader->get_topicdescription()->get_name();
} else {
mangled_name = topic_name;
}
status = topic_reader->get_qos(datareader_qos);
if (DDS::RETCODE_OK != status) {
RMW_SET_ERROR_MSG("topic_reader can't get data reader qos policies");
goto fail;
}
dds_qos_to_rmw_qos(datareader_qos, &actual_qos_profile);
node_info->subscriber_listener->add_information(
node_info->participant->get_instance_handle(),
dds_subscriber->get_instance_handle(),
mangled_name,
type_name,
actual_qos_profile,
EntityType::Subscriber);
node_info->subscriber_listener->trigger_graph_guard_condition();

Expand Down
3 changes: 2 additions & 1 deletion rmw_connext_shared_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_ros REQUIRED)
find_package(connext_cmake_module REQUIRED)
find_package(Connext QUIET MODULE)
if(Connext_FOUND)
Expand Down Expand Up @@ -76,6 +76,7 @@ if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS ${rmw_INCLUDE_DIRS})
ament_lint_auto_find_test_dependencies()
add_subdirectory(test)
endif()

ament_package(
Expand Down
18 changes: 18 additions & 0 deletions rmw_connext_shared_cpp/include/rmw_connext_shared_cpp/qos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ dds_qos_to_rmw_qos<DDS::DataReaderQos>(
const DDS::DataReaderQos & dds_qos,
rmw_qos_profile_t * qos);

template<typename AttributeT>
void
dds_remote_qos_to_rmw_qos(
const AttributeT & dds_qos,
rmw_qos_profile_t * qos);

extern template RMW_CONNEXT_SHARED_CPP_PUBLIC
void
dds_remote_qos_to_rmw_qos<DDS::PublicationBuiltinTopicData>(
const DDS::PublicationBuiltinTopicData & dds_qos,
rmw_qos_profile_t * qos);

extern template RMW_CONNEXT_SHARED_CPP_PUBLIC
void
dds_remote_qos_to_rmw_qos<DDS::SubscriptionBuiltinTopicData>(
const DDS::SubscriptionBuiltinTopicData & dds_qos,
rmw_qos_profile_t * qos);

#endif // RMW_CONNEXT_SHARED_CPP__QOS_HPP_
Loading

0 comments on commit ae7117e

Please sign in to comment.