Skip to content

Commit 5810709

Browse files
author
Enrique Fernandez
committed
Fix merge to support empty/new output bag
1 parent 5fecf59 commit 5810709

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bag_tools/scripts/merge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
import rosbag
3434

3535
import argparse
36+
import os
3637

3738
def merge(inbags, outbag='output.bag', topics=None, exclude_topics=[], raw=True):
3839
# Open output bag file:
3940
try:
40-
out = rosbag.Bag(outbag, 'a')
41+
out = rosbag.Bag(outbag, 'a' if os.path.exists(outbag) else 'w')
4142
except IOError as e:
4243
rospy.logerr('Failed to open output bag file %s!: %s' % (outbag, e.message))
4344
rospy.signal_shutdown('Failed to open output bag file %s!: %s' % (outbag, e.message))

0 commit comments

Comments
 (0)