diff --git a/rqt_plot/src/rqt_plot/plot_widget.py b/rqt_plot/src/rqt_plot/plot_widget.py index 7657d75c..3574c35b 100644 --- a/rqt_plot/src/rqt_plot/plot_widget.py +++ b/rqt_plot/src/rqt_plot/plot_widget.py @@ -191,10 +191,14 @@ def add_topic(self, topic_name): return self._rosdata[topic_name] = ROSData(topic_name, self._start_time) - data_x, data_y = self._rosdata[topic_name].next() - self.data_plot.add_curve(topic_name, topic_name, data_x, data_y) + if self._rosdata[topic_name].error is not None: + qWarning(str(self._rosdata[topic_name].error)) + del self._rosdata[topic_name] + else: + data_x, data_y = self._rosdata[topic_name].next() + self.data_plot.add_curve(topic_name, topic_name, data_x, data_y) - self._subscribed_topics_changed() + self._subscribed_topics_changed() def remove_topic(self, topic_name): self._rosdata[topic_name].close() diff --git a/rqt_plot/src/rqt_plot/rosplot.py b/rqt_plot/src/rqt_plot/rosplot.py index 8b1515d3..75f0e2b8 100644 --- a/rqt_plot/src/rqt_plot/rosplot.py +++ b/rqt_plot/src/rqt_plot/rosplot.py @@ -84,13 +84,6 @@ def get_topic_type(topic): if topic_type: return topic_type, real_topic, rest else: - print >> sys.stderr, "WARNING: topic [%s] does not appear to be published yet. Waiting..." % topic - while not rospy.is_shutdown(): - topic_type, real_topic, rest = _get_topic_type(topic) - if topic_type: - return topic_type, real_topic, rest - else: - time.sleep(0.1) return None, None, None @@ -109,9 +102,12 @@ def __init__(self, topic, start_time): self.buff_y = [] topic_type, real_topic, fields = get_topic_type(topic) - self.field_evals = generate_field_evals(fields) - data_class = roslib.message.get_message_class(topic_type) - self.sub = rospy.Subscriber(real_topic, data_class, self._ros_cb) + if topic_type is not None: + self.field_evals = generate_field_evals(fields) + data_class = roslib.message.get_message_class(topic_type) + self.sub = rospy.Subscriber(real_topic, data_class, self._ros_cb) + else: + self.error = RosPlotException("Can not resolve topic type of %s" % topic) def close(self): self.sub.unregister()