Skip to content

Commit

Permalink
Merge pull request #137 from ablasdel/issue_110
Browse files Browse the repository at this point in the history
fixes #110: no waiting on unpublished topics
  • Loading branch information
Aaron Blasdel committed Aug 15, 2013
2 parents 6045b0e + 6b285a4 commit 362a621
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 7 additions & 3 deletions rqt_plot/src/rqt_plot/plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 6 additions & 10 deletions rqt_plot/src/rqt_plot/rosplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
Expand Down

0 comments on commit 362a621

Please sign in to comment.