ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want.

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want.want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf except the ones that had /odom either as a frame_id or as a child_frame_id.

in your case you can use only the condition 'topic != "/tf"' to filter out the /tf topic

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf except the ones that had /odom either as a frame_id or as a child_frame_id.

in your case you can use only the condition 'topic != "/tf"' to filter out the /tf topictopic:

rosbag filter input.bag output.bag 'topic != "/tf"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf except EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id.child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use only the condition 'topic != "/tf"' to filter out the /tf topic:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/tf"'
"/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use only adapt the condition 'topic != "/tf"' above example to filter out the /tf topic:fit your needs:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use adapt the above example to fit your needs:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

EDIT: as pointed by @Ben_S, this is a more concise form, with the same results (from this answer):

rosbag filter input.bag output.bag 'topic != "tf" or m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use adapt the above example to fit your needs:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

EDIT: as pointed by @Ben_S, this is a more concise form, with the same results (from this answer):

rosbag filter input.bag output.bag 'topic != "tf" or m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use adapt the above example to fit your needs:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

EDIT: as pointed by @Ben_S, this is a more concise form, with the same results (from this answer):

rosbag filter input.bag output.bag 'topic != "tf" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

You can use the rosbag filter command to generate a new bag file filtering out the topics you do not want. For example, I used this command

rosbag filter input.bag output.bag 'topic == "/camera/image_raw/compressed" or topic == "/scan" or topic == "/timetag" or  topic == "/tf" and m.transforms[0].header.frame_id != "/odom" and m.transforms[0].child_frame_id != "/odom"'

here I want to keep the topics /camera/image_raw/compressed , /scan and /timetag and also the /tf EXCEPT the ones that had /odom either as a frame_id or as a child_frame_id, effectively removing only some /tf messages instead of all of them.

in your case you can use adapt the above example to fit your needs:

rosbag filter input.bag output.bag 'topic == "ALL THE TOPICS YOU WANT TO KEEP" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'

EDIT: as pointed by @Ben_S, this is a more concise form, with the same results (from this answer):

rosbag filter input.bag output.bag 'topic != "tf" "/tf" or topic == "/tf" and m.transforms[0].header.frame_id != "/base_link" and m.transforms[0].child_frame_id != "/virtual_cam"'