cmu-rss-lab / roswire

A library for static and dynamic analysis of ROS applications via Docker 🔌
http://christimperley.co.uk/roswire
Apache License 2.0
8 stars 0 forks source link

Implemented exclude_topics for ROS bag recorder (fixes #7) #340

Closed ChrisTimperley closed 4 years ago

DebyKatz commented 4 years ago

I got the following error, when using exclude_topics=['/clock']:


  File "run_fetch.py", line 67, in <module>
    main()
  File "run_fetch.py", line 61, in main
    with ros.record(bagfile, exclude_topics=to_exclude) as recorder:
  File "/usr0/home/dskatz/.local/share/virtualenvs/overhead-timing-effects-in-ROS-Wl9qFQgJ/lib/python3.6/site-packages/roswire/proxy/bag.py", line 188, in __enter__
    self.start()
  File "/usr0/home/dskatz/.local/share/virtualenvs/overhead-timing-effects-in-ROS-Wl9qFQgJ/lib/python3.6/site-packages/roswire/proxy/bag.py", line 216, in start
    args += ['-x', shlex.quote(self.__exclude_topics)]
  File "/usr/lib/python3.6/shlex.py", line 314, in quote
    if _find_unsafe(s) is None:
TypeError: expected string or bytes-like object```
ChrisTimperley commented 4 years ago

I got the following error, when using exclude_topics=['/clock']:

  File "run_fetch.py", line 67, in <module>
    main()
  File "run_fetch.py", line 61, in main
    with ros.record(bagfile, exclude_topics=to_exclude) as recorder:
  File "/usr0/home/dskatz/.local/share/virtualenvs/overhead-timing-effects-in-ROS-Wl9qFQgJ/lib/python3.6/site-packages/roswire/proxy/bag.py", line 188, in __enter__
    self.start()
  File "/usr0/home/dskatz/.local/share/virtualenvs/overhead-timing-effects-in-ROS-Wl9qFQgJ/lib/python3.6/site-packages/roswire/proxy/bag.py", line 216, in start
    args += ['-x', shlex.quote(self.__exclude_topics)]
  File "/usr/lib/python3.6/shlex.py", line 314, in quote
    if _find_unsafe(s) is None:
TypeError: expected string or bytes-like object```

Sorry about this. I've changed the API to match the rosbag record command line, which accepts a single regular expression rather than a list of topics (or regular expressions).

DebyKatz commented 4 years ago

Ok, this appears to work when using the syntax of a single regex. ROS can be a little sensitive about the regex format, but it appears to work as expected on regexes that rosbag record --exclude would accept.

ChrisTimperley commented 4 years ago

@DebyKatz, do you think that the name exclude rather than exclude_topics would do a better job of suggesting that the input is not a list?

DebyKatz commented 4 years ago

@ChrisTimperley , maybe, but I think it's a less descriptive and less useful name overall. With the name exclude, we might be talking about excluding, e.g., message types instead of topics.