Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions src/rqt_topic/topic_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ def stop_monitoring(self):
self.monitoring = False
self._reset_data()
if self._subscriber is not None:
qWarning('TopicInfo.stop_monitoring(): '
'Unsubscribing from a topic while the executor is spinning may segfault. '
'This is a known bug in rclpy and is being addressed')
qWarning('TopicInfo.stop_monitoring(): See: https://github.com/ros2/rclpy/issues/255')
self._node.destroy_subscription(self._subscriber)
self._subscriber = None

Expand Down
17 changes: 14 additions & 3 deletions src/rqt_topic/topic_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
from python_qt_binding.QtCore import Qt, QTimer, qWarning, Slot
from python_qt_binding.QtGui import QIcon
from python_qt_binding.QtWidgets import QHeaderView, QMenu, QTreeWidgetItem, QWidget
from rqt_gui_py.rclpy_spinner import RclpySpinner
from rqt_py_common.message_helpers import get_message_class

import rclpy

from .topic_info import TopicInfo


Expand Down Expand Up @@ -115,6 +118,12 @@ def __init__(self, node, plugin=None, selected_topics=None,
self._timer_refresh_topics = QTimer(self)
self._timer_refresh_topics.timeout.connect(self.refresh_topics)

# Create a ROS node to handle the subscriptions
self._local_node = rclpy.create_node('rqt_topic_plugin_%d' % os.getpid(),
start_parameter_services=False)
self._spinner = RclpySpinner(self._local_node)
self._spinner.start()

def set_topic_specifier(self, specifier):
self._select_topic_type = specifier

Expand Down Expand Up @@ -178,7 +187,7 @@ def refresh_topics(self):
qWarning('rqt_topic: Topic "' + topic_name +
'" has more than one type, choosing the first one of type ' +
topic_types[0])
topic_info = TopicInfo(self._node, topic_name, topic_types[0])
topic_info = TopicInfo(self._local_node, topic_name, topic_types[0])
message_instance = None
if topic_info.message_class is not None:
message_instance = topic_info.message_class()
Expand Down Expand Up @@ -406,9 +415,11 @@ def recursive_set_expanded(item):
recursive_set_expanded(item)

def shutdown_plugin(self):
for topic in self._topics.values():
topic['info'].stop_monitoring()
self._timer_refresh_topics.stop()
self._spinner.quit()
self._spinner.wait(msecs=2000) # Wait for the _spinner (a QThread) to finish
self._local_node.destroy_node()


def set_selected_topics(self, selected_topics):
"""
Expand Down