Error while writing from bag file to csv
Hi all!
I'm trying to extract data from a bag file and save it into a csv. For this I've been using:
rostopic echo -p --nosstr --noarr -b bagfile.bag /topic > name.csv
But now I also want to filter the data before storing it into the csv file. I've checked rostopic echo and found that it has a filter command. I've tried to use it:
rostopic echo --filter "m.header.stamp.secs>=1342763900 and m.header.stamp.secs<=1342763990" -p --nosstr --noarr -b bagfile.bag /topic > name.csv
And got this error:
Traceback (most recent call last): File "/opt/ros/electric/ros/bin/rostopic", line 45, in <module> rostopic.rostopicmain() File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 1696, in rostopicmain _rostopic_cmd_echo(argv) File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 1041, in _rostopic_cmd_echo _rostopic_echo(topic, callback_echo, bag_file=options.bag) File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 689, in _rostopic_echo _rostopic_echo_bag(callback_echo, bag_file) File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 670, in _rostopic_echo_bag callback_echo.callback(msg, t, current_time=timestamp) File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 577, in callback if self.filter_fn is not None and not self.filter_fn(data): File "/opt/ros/electric/stacks/ros_comm/tools/rostopic/src/rostopic.py", line 967, in eval_fn return eval(expr) File "<string>", line 1, in <module> AttributeError: '_std_msgs__String' object has no attribute 'header'
But if instead of trying to save the data to a csv I just do the rostopic echo with the filter while a rosbag play is publishing the messages I have no problem.
Can somebody help please??
Cheers!