-
Notifications
You must be signed in to change notification settings - Fork 914
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
Fix rostopic hz and bw in Python 3 #1126
Changes from 3 commits
7c2d32b
4c74df9
86a2a29
3255330
37d22bb
fa21976
0abcba9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,9 +426,11 @@ def __init__(self, window_size=100): | |
self.lock = threading.Lock() | ||
self.last_printed_tn = 0 | ||
self.sizes =[] | ||
self.times =[] | ||
self.window_size = window_size or 100 | ||
|
||
self.times =[] | ||
if window_size < 0: | ||
window_size = 100 | ||
self.window_size = window_size | ||
|
||
def callback(self, data): | ||
"""ros sub callback""" | ||
with self.lock: | ||
|
@@ -1488,11 +1490,7 @@ def _rostopic_cmd_hz(argv): | |
if len(args) == 0: | ||
parser.error("topic must be specified") | ||
try: | ||
if options.window_size != -1: | ||
import string | ||
window_size = string.atoi(options.window_size) | ||
else: | ||
window_size = options.window_size | ||
window_size = int(options.window_size) | ||
except: | ||
parser.error("window size must be an integer") | ||
|
||
|
@@ -1532,19 +1530,15 @@ def _rostopic_cmd_bw(argv=sys.argv): | |
from optparse import OptionParser | ||
parser = OptionParser(usage="usage: %prog bw /topic", prog=NAME) | ||
parser.add_option("-w", "--window", | ||
dest="window_size", default=None, | ||
dest="window_size", default=-1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change necessary for Python 3 support? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not required but I did this for simplification of the following logic for converting |
||
help="window size, in # of messages, for calculating rate", metavar="WINDOW") | ||
options, args = parser.parse_args(args) | ||
if len(args) == 0: | ||
parser.error("topic must be specified") | ||
if len(args) > 1: | ||
parser.error("you may only specify one input topic") | ||
try: | ||
if options.window_size: | ||
import string | ||
window_size = string.atoi(options.window_size) | ||
else: | ||
window_size = options.window_size | ||
window_size = int(options.window_size) | ||
except: | ||
parser.error("window size must be an integer") | ||
topic = rosgraph.names.script_resolve_name('rostopic', args[0]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this logic change necessary for Python 3 support?