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

Implement functions to get publisher and subcription informations like QoS policies from topic name #336

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6721292
Simpled test for topic_cache
jaisontj Oct 17, 2019
944e1f3
Moved qos_converter to include/ since it needs to be accessible to
jaisontj Oct 18, 2019
e7a4a7e
- Modified topic_cache to include qos policies
jaisontj Oct 18, 2019
d0ac7e0
Stubs for rmw_get_publishers_info_by_topic and
jaisontj Oct 16, 2019
e640479
Implemented rmw_get_publishers_info_by_topic and
jaisontj Oct 23, 2019
1a80e44
- Addressing code review changes: Using const auto instead of auto
jaisontj Nov 14, 2019
30a2a56
- Alpha sorted cmakelist.txt
jaisontj Nov 16, 2019
dbfe0b4
- Alphasort
jaisontj Nov 16, 2019
04b29c8
- Refactor to accomodate change in rmw_topic_info_set* functions.
jaisontj Nov 22, 2019
af1e536
Refactor to accomodate change of gid from const char * to uint8_t[]
jaisontj Nov 22, 2019
e87e83c
Moved dds_qos_to_rmw_qos from qos_converter to qos.hpp
jaisontj Nov 22, 2019
16fcaed
- Modified topic cache to store participant guid and
jaisontj Nov 23, 2019
fea85a6
- Handled changes in headers from rmw
jaisontj Nov 27, 2019
1a4d9fa
Better error handling.
jaisontj Nov 27, 2019
169f218
fix error handling in _handle_topic_info_fini()
mm318 Dec 11, 2019
36e9718
address PR comments
mm318 Dec 14, 2019
8152876
address PR comments
mm318 Dec 18, 2019
642d9ed
conditionally demangle type name
mm318 Dec 19, 2019
38dec2a
reverse condition for demangling type name
mm318 Dec 28, 2019
c231f14
properly initialize history and history depth in topic info
mm318 Jan 2, 2020
a1a5e79
address more PR comments
mm318 Jan 10, 2020
354cae2
rename *topic_info* to *topic_endpoint_info*
mm318 Jan 10, 2020
1fe66ed
fix formatting
mm318 Jan 10, 2020
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
1 change: 1 addition & 0 deletions rmw_fastrtps_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ add_library(rmw_fastrtps_cpp
src/rmw_get_gid_for_publisher.cpp
src/rmw_get_implementation_identifier.cpp
src/rmw_get_serialization_format.cpp
src/rmw_get_topic_endpoint_info.cpp
src/rmw_guard_condition.cpp
src/rmw_init.cpp
src/rmw_node.cpp
Expand Down
46 changes: 46 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_get_topic_endpoint_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw/get_topic_endpoint_info.h"
#include "rmw/topic_endpoint_info_array.h"
#include "rmw/types.h"
#include "rmw_fastrtps_cpp/identifier.hpp"
#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"

extern "C"
{
rmw_ret_t
rmw_get_publishers_info_by_topic(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * publishers_info)
{
return rmw_fastrtps_shared_cpp::__rmw_get_publishers_info_by_topic(
eprosima_fastrtps_identifier, node, allocator, topic_name, no_mangle, publishers_info);
}

rmw_ret_t
rmw_get_subscriptions_info_by_topic(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * subscriptions_info)
{
return rmw_fastrtps_shared_cpp::__rmw_get_subscriptions_info_by_topic(
eprosima_fastrtps_identifier, node, allocator, topic_name, no_mangle, subscriptions_info);
}
} // extern "C"
1 change: 1 addition & 0 deletions rmw_fastrtps_dynamic_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ add_library(rmw_fastrtps_dynamic_cpp
src/rmw_get_gid_for_publisher.cpp
src/rmw_get_implementation_identifier.cpp
src/rmw_get_serialization_format.cpp
src/rmw_get_topic_endpoint_info.cpp
src/rmw_guard_condition.cpp
src/rmw_init.cpp
src/rmw_node.cpp
Expand Down
46 changes: 46 additions & 0 deletions rmw_fastrtps_dynamic_cpp/src/rmw_get_topic_endpoint_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rmw/get_topic_endpoint_info.h"
#include "rmw/topic_endpoint_info_array.h"
#include "rmw/types.h"
#include "rmw_fastrtps_dynamic_cpp/identifier.hpp"
#include "rmw_fastrtps_shared_cpp/rmw_common.hpp"

extern "C"
{
rmw_ret_t
rmw_get_publishers_info_by_topic(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * publishers_info)
{
return rmw_fastrtps_shared_cpp::__rmw_get_publishers_info_by_topic(
eprosima_fastrtps_identifier, node, allocator, topic_name, no_mangle, publishers_info);
}

rmw_ret_t
rmw_get_subscriptions_info_by_topic(
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * subscriptions_info)
{
return rmw_fastrtps_shared_cpp::__rmw_get_subscriptions_info_by_topic(
eprosima_fastrtps_identifier, node, allocator, topic_name, no_mangle, subscriptions_info);
}
} // extern "C"
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_library(rmw_fastrtps_shared_cpp
src/rmw_compare_gids_equal.cpp
src/rmw_count.cpp
src/rmw_get_gid_for_publisher.cpp
src/rmw_get_topic_endpoint_info.cpp
src/rmw_guard_condition.cpp
src/rmw_logging.cpp
src/rmw_node.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,22 @@ class ParticipantListener : public eprosima::fastrtps::ParticipantListener
{
auto & topic_cache =
is_reader ? reader_topic_cache : writer_topic_cache;

bool trigger;
{
std::lock_guard<std::mutex> guard(topic_cache.getMutex());
if (is_alive) {
trigger = topic_cache().addTopic(proxyData.RTPSParticipantKey(),
proxyData.topicName().to_string(), proxyData.typeName().to_string());
trigger = topic_cache().addTopic(
proxyData.RTPSParticipantKey(),
proxyData.guid(),
proxyData.topicName().to_string(),
proxyData.typeName().to_string(),
proxyData.m_qos);
} else {
trigger = topic_cache().removeTopic(proxyData.RTPSParticipantKey(),
proxyData.topicName().to_string(), proxyData.typeName().to_string());
trigger = topic_cache().removeTopic(
proxyData.RTPSParticipantKey(),
proxyData.guid(),
proxyData.topicName().to_string(),
proxyData.typeName().to_string());
}
}
if (trigger) {
Expand Down
64 changes: 64 additions & 0 deletions rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/qos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "rmw/rmw.h"

#include "./visibility_control.h"
#include "fastrtps/qos/WriterQos.h"
#include "fastrtps/qos/ReaderQos.h"

namespace eprosima
{
Expand All @@ -44,6 +46,68 @@ get_datawriter_qos(
const rmw_qos_profile_t & qos_policies,
eprosima::fastrtps::PublisherAttributes & pattr);

/*
* Converts the low-level QOS Policy; of type WriterQos or ReaderQos into rmw_qos_profile_t.
* Since WriterQos or ReaderQos does not have information about history and depth, these values are not set
* by this function.
*
* \param[in] dds_qos of type WriterQos or ReaderQos
* \param[out] qos the equivalent of the data in WriterQos or ReaderQos in rmw_qos_profile_t
*/
template<typename DDSQoSPolicyT>
void
dds_qos_to_rmw_qos(
const DDSQoSPolicyT & dds_qos,
rmw_qos_profile_t * qos)
{
switch (dds_qos.m_reliability.kind) {
case eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT;
break;
case eprosima::fastrtps::RELIABLE_RELIABILITY_QOS:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
break;
default:
qos->reliability = RMW_QOS_POLICY_RELIABILITY_UNKNOWN;
break;
}

switch (dds_qos.m_durability.kind) {
case eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS:
qos->durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL;
break;
case eprosima::fastrtps::VOLATILE_DURABILITY_QOS:
qos->durability = RMW_QOS_POLICY_DURABILITY_VOLATILE;
break;
default:
qos->durability = RMW_QOS_POLICY_DURABILITY_UNKNOWN;
break;
}

qos->deadline.sec = dds_qos.m_deadline.period.seconds;
qos->deadline.nsec = dds_qos.m_deadline.period.nanosec;

qos->lifespan.sec = dds_qos.m_lifespan.duration.seconds;
qos->lifespan.nsec = dds_qos.m_lifespan.duration.nanosec;

switch (dds_qos.m_liveliness.kind) {
case eprosima::fastrtps::AUTOMATIC_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_AUTOMATIC;
break;
case eprosima::fastrtps::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE;
break;
case eprosima::fastrtps::MANUAL_BY_TOPIC_LIVELINESS_QOS:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC;
break;
default:
qos->liveliness = RMW_QOS_POLICY_LIVELINESS_UNKNOWN;
break;
}
qos->liveliness_lease_duration.sec = dds_qos.m_liveliness.lease_duration.seconds;
qos->liveliness_lease_duration.nsec = dds_qos.m_liveliness.lease_duration.nanosec;
}

template<typename AttributeT>
void
dds_attributes_to_rmw_qos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#include "./visibility_control.h"

#include "rmw/error_handling.h"
#include "rmw/event.h"
#include "rmw/rmw.h"
#include "rmw/topic_endpoint_info_array.h"
#include "rmw/types.h"
#include "rmw/event.h"
#include "rmw/names_and_types.h"

namespace rmw_fastrtps_shared_cpp
Expand Down Expand Up @@ -349,6 +350,26 @@ RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_destroy_wait_set(const char * identifier, rmw_wait_set_t * wait_set);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_get_publishers_info_by_topic(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * publishers_info);

RMW_FASTRTPS_SHARED_CPP_PUBLIC
rmw_ret_t
__rmw_get_subscriptions_info_by_topic(
const char * identifier,
const rmw_node_t * node,
rcutils_allocator_t * allocator,
const char * topic_name,
bool no_mangle,
rmw_topic_endpoint_info_array_t * subscriptions_info);

} // namespace rmw_fastrtps_shared_cpp

#endif // RMW_FASTRTPS_SHARED_CPP__RMW_COMMON_HPP_
Loading