Skip to content

Commit 90644d6

Browse files
author
Enrique Fernández Perdomo
committed
Merge pull request #13 from clearpathrobotics/fix_merge_new_output
Fix merge to support empty/new output bag
2 parents 5fecf59 + 5810709 commit 90644d6

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)