Created
November 4, 2021 22:34
-
-
Save wkalt/19247722f966d36987fc91f01eff7574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import rosbag | |
import sys | |
_, inputfile, outputfile = sys.argv | |
bag = rosbag.Bag(inputfile) | |
message_count = bag.get_message_count() | |
c = 0 | |
with rosbag.Bag(outputfile, "w") as output: | |
for topic, msg, t in bag.read_messages(): | |
if c < message_count - 1: | |
output.write(topic, msg, msg.header.stamp if msg._has_header else t) | |
c += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment