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

Auto discovery of new topics #63

Merged

Conversation

Martin-Idel-SI
Copy link
Contributor

@Martin-Idel-SI Martin-Idel-SI commented Nov 26, 2018

Using ros2 bag record: Poll regularly for new topics if not all topics have been found yet or ros2 bag record is used with the --all option to subscribe to all topics.

The polling interval is currently set to 100ms and not exposed to the user, but this can easily be amended if necessary.

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@anhosi anhosi force-pushed the feature/auto_discovery_of_new_topics branch from 224a8a2 to d3cd7c6 Compare November 30, 2018 12:04
@anhosi
Copy link
Contributor

anhosi commented Nov 30, 2018

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@anhosi
Copy link
Contributor

anhosi commented Nov 30, 2018

The macOS slave seems to have a connection problem.

@anhosi
Copy link
Contributor

anhosi commented Nov 30, 2018

Trying macOS again: Build Status

@anhosi
Copy link
Contributor

anhosi commented Nov 30, 2018

The macOS build fails because of Clang warnings in non rosbag2 code.

@anhosi
Copy link
Contributor

anhosi commented Dec 4, 2018

We added the option --no-discovery that allows to disable the auto discovery. If this option is used the resulting bag may be empty if the initial (and only) subscription fails. We consider this option "advanced" and did not implement checks whether all requested topics could be subscribed as this hard to do consistently.

New round of CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

ros2bag/ros2bag/verb/record.py Show resolved Hide resolved
@@ -41,9 +41,6 @@ class PublisherManager
auto publisher_node = std::make_shared<rclcpp::Node>("publisher" + std::to_string(counter++));
auto publisher = publisher_node->create_publisher<T>(topic_name);

// We need to publish one message to set up the topic for discovery
publisher->publish(message);
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this just legacy or why is this code removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

With auto discovery we no longer need to advertise the topic before starting rosbag in the test.

rosbag2_transport/src/rosbag2_transport/recorder.hpp Outdated Show resolved Hide resolved
auto subscribe_to_topics =
[this, topics_to_record, topic_polling_interval, is_discovery_disabled] {
do {
auto all_topics_and_types_to_subscribe = topics_to_record.empty() ?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is pretty complicated for what it is.
wouldn't it be easier to have this function called once as a blocking call to start the recording and then asynchronously call node_->get_topics_with_types and subscribe to the not-yet-subscribed once? I think this makes it easier to follow what's happening here.

By extracting the new topics, the call to is_every_topic_subscribed is then not necessary anymore, because we know which topics to subscribe.

Copy link
Contributor

Choose a reason for hiding this comment

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

By extracting the new topics, the call to is_every_topic_subscribed is then not necessary anymore, because we know which topics to subscribe.

I don't understand. In the --all case we do not know what topics to expect.

rosbag2_transport/src/rosbag2_transport/recorder.cpp Outdated Show resolved Hide resolved
rosbag2_transport/src/rosbag2_transport/recorder.cpp Outdated Show resolved Hide resolved
@botteroa-si
Copy link
Contributor

New CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

1 similar comment
@botteroa-si
Copy link
Contributor

New CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

botteroa-si and others added 10 commits December 6, 2018 19:29
- this allows new topics to be discovered also after startup.
- as a consquence, ros2 bag record won't throw any exception anymore if the specified topics are not available at startup
- each time the recorder subscribes to a new topic, this will be logged to console
- make option available in RecordOptions
- set to 100ms for now
- use set for subscribed topics instead of vector
- perform the asynchronous call only when discovery is needed
- naming of methods
- emphasize similarity between first subscription and discovery loop
@anhosi anhosi force-pushed the feature/auto_discovery_of_new_topics branch from 6c0d458 to ee11257 Compare December 6, 2018 18:38
@anhosi
Copy link
Contributor

anhosi commented Dec 6, 2018

New CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987 Karsten1987 merged commit eb785b8 into ros2:master Dec 7, 2018
@Karsten1987 Karsten1987 deleted the feature/auto_discovery_of_new_topics branch December 7, 2018 18:18
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.

None yet

5 participants