Skip to content

Commit a437435

Browse files
authored
Small cleanups to the topic monitor. (#517)
In particular: 1. Revamp the README so it is more up-to-date. 2. Remove the unused and uninstalled data_pub_ros1.py script 3. Remove some unnecessary indirection in the topic_monitor code. 4. Fix up a warning that topic_monitor throws on startup about duplicate axes. Signed-off-by: Chris Lalancette <[email protected]>
1 parent ae639cd commit a437435

File tree

3 files changed

+7
-83
lines changed

3 files changed

+7
-83
lines changed

topic_monitor/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Visualizing the effector of QoS policies
1+
# Visualizing the effect of QoS policies
22

33
This demo uses a “topic monitor” that can be used to visualize the statistics of ROS 2 topics that are publishing sequential data.
44

55
## Background
6-
Please read the [About Quality of Service Settings](https://github.com/ros2/ros2/wiki/About-Quality-of-Service-Settings) page for background information about the Quality of Service settings available in ROS 2.
6+
Please read the [About Quality of Service Settings](https://docs.ros.org/en/rolling/Concepts/About-Quality-of-Service-Settings.html) page for background information about the Quality of Service settings available in ROS 2.
77

88
## Running the demo
99
To visualize the reception rate, we will use a “topic monitor” that periodically calculates the reception rate of topics with publishers of periodic, sequential data.
@@ -13,9 +13,6 @@ If you have the Python3 `matplotlib` and `tkinter` packages installed, you can u
1313
ros2 run topic_monitor topic_monitor --display
1414
```
1515

16-
Alternatively, if you have ROS 1 installed, you can use the ROS 1 - ROS 2 bridge to plot the reception rate using ROS 1 tools such as `rqt`, or log it using `rosbag`.
17-
Be sure to run the bridge with `--bridge-all-2to1-topics` so that all topics will be bridged, that way `rqt` will be able to list the topics before it has subscribed to them.
18-
1916
**For all invocations that follow make sure the same `ROS_DOMAIN_ID` has been set to the same value on the respective machines.**
2017

2118

@@ -68,7 +65,7 @@ You should see that the reception rate of the publishers with the higher depth i
6865
### Comparing the effect of data size
6966
The maximum message size in UDP (the underlying transport for ROS 2) is 64KB, after which messages get fragmented into smaller parts and sent individually.
7067
Larger message requires multiple fragments to be sent, and unless all fragments are received, the reception rate of the data declines.
71-
For connections with "reliable" reliability policy, when the lost fragments will be re-sent.
68+
For connections with "reliable" reliability policy, lost fragments will be re-sent.
7269
For connections with "best effort" reliability, the loss of any fragment causes the whole message to be discarded by the subscriber.
7370

7471
You will need two machines running ROS 2: one stationary and one mobile.

topic_monitor/topic_monitor/scripts/ros1/data_pub_ros1.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

topic_monitor/topic_monitor/scripts/topic_monitor.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
class MonitoredTopic:
3333
"""Monitor for the statistics and status of a single topic."""
3434

35-
def __init__(self, topic_id, stale_time, lock=None):
35+
def __init__(self, topic_id, stale_time, lock):
3636
self.expected_value = None
3737
self.expected_value_timer = None
3838
self.initial_value = None
39-
self.lock = lock or Lock()
39+
self.lock = lock
4040
self.received_values = []
4141
self.reception_rate_over_time = []
4242
self.stale_time = stale_time
@@ -128,7 +128,6 @@ def add_monitored_topic(
128128
expected_period=1.0, allowed_latency=1.0, stale_time=1.0):
129129
# Create a subscription to the topic
130130
monitored_topic = MonitoredTopic(topic_name, stale_time, lock=self.monitored_topics_lock)
131-
monitored_topic.topic_name = topic_name
132131
node_logger = node.get_logger()
133132
node_logger.info('Subscribing to topic: %s' % topic_name)
134133
sub = node.create_subscription(
@@ -210,9 +209,6 @@ def check_status(self):
210209
return status_changed
211210

212211
def calculate_statistics(self):
213-
self.calculate_reception_rates()
214-
215-
def calculate_reception_rates(self):
216212
with self.monitored_topics_lock:
217213
for topic_id, monitored_topic in self.monitored_topics.items():
218214
rate = monitored_topic.current_reception_rate(self.window_size)
@@ -247,7 +243,7 @@ def make_plot(self):
247243
plt.title('Reception rate over time')
248244
plt.xlabel('Time (s)')
249245
plt.ylabel('Reception rate (last %i msgs)' % self.topic_monitor.get_window_size())
250-
self.ax = self.fig.add_subplot(111)
246+
self.ax = self.fig.get_axes()[0]
251247
self.ax.axis([0, self.x_range_s, 0, 1.1])
252248

253249
# Shrink axis' height to make room for legend
@@ -344,7 +340,7 @@ def run_topic_listening(node, topic_monitor, options):
344340
if topic_name not in already_ignored_topics:
345341
node.get_logger().info(
346342
"Warning: ignoring topic '%s' because its message type (%s)"
347-
'is not suported.'
343+
'is not supported.'
348344
% (topic_name, type_name))
349345
already_ignored_topics.add(topic_name)
350346
continue

0 commit comments

Comments
 (0)