ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
765 stars 913 forks source link

rostopic echo --bag --filter /topicname does not limit messages filtered to /topicname #2304

Open phil-marble opened 1 year ago

phil-marble commented 1 year ago

rostopic echo --bag --filter /topicname does not limit messages filtered to /topicname

rosbag play & rostopic echo -filter /topicname seems to work as expected

Bug reproduced in: ii ros-noetic-rostopic 1.15.14-1focal.20220926.212026 amd64

$ rostopic echo --bag=$HOME/bagfiles/XXX.bag /topicname --filter="status=='something'"
Traceback (most recent call last):
  File "/opt/ros/noetic/bin/rostopic", line 35, in <module>
    rostopic.rostopicmain()
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 2130, in rostopicmain
    _rostopic_cmd_echo(argv)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 1406, in _rostopic_cmd_echo
    _rostopic_echo(topic, callback_echo, bag_file=options.bag)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 1015, in _rostopic_echo
    _rostopic_echo_bag(callback_echo, bag_file)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 998, in _rostopic_echo_bag
    callback_echo.callback(msg, {'topic': t}, current_time=timestamp)
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 898, in callback
    if self.filter_fn is not None and not self.filter_fn(data):
  File "/opt/ros/noetic/lib/python3/dist-packages/rostopic/__init__.py", line 1314, in eval_fn
    return eval(expr)
  File "<string>", line 1, in <module>
NameError: name 'status' is not defined