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

Conversation

jaisontj
Copy link
Contributor

@jaisontj jaisontj commented Oct 29, 2019

NOTE: DO NOT MERGE until rmw #186 and rmw_implementation #72 are merged.

This PR makes the necessary changes to implement this feature request. Relevant design discussions can be found here.

The changes can be summarized as follows:

  • Modified the TopicCache class (topic_cache.hpp) from holding a map of topic_name to a vector of topic_types to a map of topic_name to a vector of tuples (GUID_t, topic_type and qos_profile). The addTopic function was also modified to accept the QoS profile as an additional parameter.
  • Added tests for TopicCache
  • The qos_converter.hpp was moved from being a package-private header to being public as this needed to be accessed by topic_cache.hpp.
  • Implemented rmw_get_publishers_info_by_topic and rmw_get_subscriptions_info_by_topic inside rmw_fastrtps_cpp, rmw_fastrtps_dynamic_cpp and rmw_fastrtps_shared_cpp. These functions are defined in the rmw(PR) and rmw_implementation(PR) packages.

Related to issues in aws-roadmap #84 and #83

Closing #333 and #332 in favor of this PR.

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
topic_cache.hpp

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
- Modified call to topic_cache.addTopic at custom_participant_info.hpp
- Wrote tests for topic_cache

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
rmw_get_subscriptions_info_by_topic

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
@jaisontj
Copy link
Contributor Author

@ivanpauno

@jaisontj jaisontj force-pushed the jaisontj/impl_rmw_get_node_info_by_topic branch 2 times, most recently from 58c1fe8 to f029dac Compare November 13, 2019 20:08
@jaisontj jaisontj force-pushed the jaisontj/impl_rmw_get_node_info_by_topic branch 2 times, most recently from 176cff3 to 17f0695 Compare November 14, 2019 00:40
rmw_get_subscriptions_info_by_topic

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
@jaisontj jaisontj force-pushed the jaisontj/impl_rmw_get_node_info_by_topic branch from 17f0695 to e640479 Compare November 14, 2019 00:52
Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
- changed to using instead of typedef

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
topic_fqdns.push_back(topic_name);
// if mangle
if (!no_mangle) {
auto ros_prefixes = _get_all_ros_prefixes();
Copy link
Member

Choose a reason for hiding this comment

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

I know this is imitating the rmw_count implementation, but trying with all prefixes is wrong.
I will continue the discussion in a follow up issue.

Copy link
Member

Choose a reason for hiding this comment

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

Let's not forget this point.

- Refactor to accomodate change in rmw_topic_info_array* functions.

Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
@mm318 mm318 force-pushed the jaisontj/impl_rmw_get_node_info_by_topic branch from be2cf37 to 169f218 Compare December 11, 2019 00:32
rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
return ret;
}
for (auto i = 0u; i < count; i++) {
participants_info->info_array[i] = topic_info_vector.at(i);
Copy link
Contributor

@hidmic hidmic Dec 12, 2019

Choose a reason for hiding this comment

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

@jaisontj do we need an std::vector if we'll eventually just copy it into a primitive array?

Copy link
Member

@mm318 mm318 Dec 14, 2019

Choose a reason for hiding this comment

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

It doesn't look trivial to determine what size of a primitive array would need be initially allocated.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's because of how the loop is written. If iterators that refer to matching topic data were collected first, then it'd be straightforward. This somewhat connects to @ivanpauno 's previous comment here. I can understand why it was done this way initially but the overhead is not necessary. I'm fine with deferring though.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also ok with deferring, but I would really like to see it cleaned up at some point. My experience has been that clean up things like this tend to get overlooked though.

rmw_fastrtps_shared_cpp/test/test_topic_cache.cpp Outdated Show resolved Hide resolved
Signed-off-by: Miaofei <miaofei@amazon.com>
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

One last observation is that this patch abuses auto a bit. It's a great feature to deal with iterator types and such, but if used even in lieu of int types it obscures code.

rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
return ret;
}
for (auto i = 0u; i < count; i++) {
participants_info->info_array[i] = topic_info_vector.at(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's because of how the loop is written. If iterators that refer to matching topic data were collected first, then it'd be straightforward. This somewhat connects to @ivanpauno 's previous comment here. I can understand why it was done this way initially but the overhead is not necessary. I'm fine with deferring though.

Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
@mm318 mm318 force-pushed the jaisontj/impl_rmw_get_node_info_by_topic branch from 8a72fc0 to 38dec2a Compare December 28, 2019 03:29
Signed-off-by: Miaofei <miaofei@amazon.com>
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm, with some comments

topic_fqdns.push_back(topic_name);
// if mangle
if (!no_mangle) {
auto ros_prefixes = _get_all_ros_prefixes();
Copy link
Member

Choose a reason for hiding this comment

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

Let's not forget this point.

rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
return ret;
}
for (auto i = 0u; i < count; i++) {
participants_info->info_array[i] = topic_info_vector.at(i);
Copy link
Member

Choose a reason for hiding this comment

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

I'm also ok with deferring, but I would really like to see it cleaned up at some point. My experience has been that clean up things like this tend to get overlooked though.

rmw_fastrtps_shared_cpp/src/rmw_get_topic_info.cpp Outdated Show resolved Hide resolved
mm318 added 3 commits January 9, 2020 16:16
Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
Signed-off-by: Miaofei <miaofei@amazon.com>
@ivanpauno ivanpauno merged commit 465d15e into ros2:master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants