v01
This commit is contained in:
69
thirdparty/ros/ros_comm/tools/rosbag/scripts/bag2png.py
vendored
Executable file
69
thirdparty/ros/ros_comm/tools/rosbag/scripts/bag2png.py
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys
|
||||
import array
|
||||
import Image
|
||||
|
||||
import rospy
|
||||
import rosbag
|
||||
|
||||
def int16_str(d):
|
||||
return array.array('B', [ min(x, 255) for x in d ]).tostring()
|
||||
#return array.array('f', [ float(x) for x in d ]).tostring()
|
||||
|
||||
def msg2im(msg):
|
||||
"""Take an sensor_msgs/Image and return a PIL image"""
|
||||
if len(msg.uint8_data.data) == 0 and len(msg.int16_data.data) == 0:
|
||||
return None
|
||||
|
||||
if msg.depth == 'uint8':
|
||||
ma, image_data = msg.uint8_data, ma.data
|
||||
else:
|
||||
ma, image_data = msg.int16_data, int16_str(ma.data)
|
||||
|
||||
dim = dict([(d.label, d.size) for d in ma.layout.dim])
|
||||
mode = { ('uint8',1) : "L", ('uint8',3) : "RGB", ('int16',1) : "L" }[msg.depth, dim['channel']]
|
||||
(w, h) = (dim['width'], dim['height'])
|
||||
|
||||
return Image.fromstring(mode, (w, h), image_data)
|
||||
|
||||
counter = 0
|
||||
for topic, msg, t in rosbag.Bag(sys.argv[1]).read_messages():
|
||||
if topic.endswith('stereo/raw_stereo'):
|
||||
for (mi, c) in [ (msg.left_image, 'L'), (msg.right_image, 'R'), (msg.disparity_image, 'D')]:
|
||||
im = msg2im(mi)
|
||||
if im:
|
||||
ext = { 'L':'png', 'RGB':'png', 'F':'tiff' }[im.mode]
|
||||
im.save('%06d%s.%s' % (counter, c, ext))
|
||||
counter += 1
|
||||
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/bagsort.py
vendored
Executable file
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/bagsort.py
vendored
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import rospy
|
||||
import rosbag
|
||||
|
||||
def sortbags(inbag, outbag):
|
||||
rebag = rosbag.Bag(outbag, 'w')
|
||||
|
||||
try:
|
||||
schedule = [(t, i) for i, (topic, msg, t) in enumerate(rosbag.Bag(inbag).read_messages(raw=True))]
|
||||
|
||||
schedule = [i for (t, i) in sorted(schedule)]
|
||||
print(schedule)
|
||||
|
||||
stage = {}
|
||||
for i, (topic, msg, t) in enumerate(rosbag.Bag(inbag).read_messages(raw=True)):
|
||||
stage[i] = (topic, msg, t)
|
||||
while (len(schedule) > 0) and (schedule[0] in stage):
|
||||
(topic, msg, t) = stage[schedule[0]]
|
||||
rebag.write(topic, msg, t, raw=True)
|
||||
del stage[schedule[0]]
|
||||
schedule = schedule[1:]
|
||||
|
||||
assert schedule == []
|
||||
assert stage == {}
|
||||
finally:
|
||||
rebag.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) == 3:
|
||||
sortbags(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
print("usage: bagsort.py <inbag> <outbag>")
|
||||
49
thirdparty/ros/ros_comm/tools/rosbag/scripts/fastrebag.py
vendored
Executable file
49
thirdparty/ros/ros_comm/tools/rosbag/scripts/fastrebag.py
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import rosbag
|
||||
|
||||
def fastrebag(inbag, outbag):
|
||||
rebag = rosbag.Bag(outbag, 'w')
|
||||
for i, (topic, msg, t) in enumerate(rosbag.Bag(inbag).read_messages(raw=True)):
|
||||
rebag.write(topic, msg, t, raw=True)
|
||||
rebag.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) == 3:
|
||||
fastrebag(sys.argv[1], sys.argv[2])
|
||||
else:
|
||||
print('usage: fastrebag.py <inbag> <outbag>')
|
||||
69
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_md5sums.py
vendored
Executable file
69
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_md5sums.py
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import rospy
|
||||
import rosbag
|
||||
|
||||
def fix_md5sums(inbags):
|
||||
for b in inbags:
|
||||
print('Trying to migrating file: %s' % b)
|
||||
outbag = b + '.tmp'
|
||||
rebag = rosbag.Bag(outbag, 'w')
|
||||
try:
|
||||
for i,(topic, msg, t) in enumerate(rosbag.Bag(b).read_messages(raw=True)):
|
||||
rebag.write(topic, msg, t, raw=True)
|
||||
rebag.close()
|
||||
except rosbag.ROSBagException as e:
|
||||
print(' Migration failed: %s' % str(e))
|
||||
os.remove(outbag)
|
||||
continue
|
||||
|
||||
oldnamebase = b + '.old'
|
||||
oldname = oldnamebase
|
||||
i = 1
|
||||
while os.path.isfile(oldname):
|
||||
i += 1
|
||||
oldname = oldnamebase + str(i)
|
||||
os.rename(b, oldname)
|
||||
os.rename(outbag, b)
|
||||
print(' Migration successful. Original stored as: %s' % oldname)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) >= 2:
|
||||
fix_md5sums(sys.argv[1:])
|
||||
else:
|
||||
print("usage: fix_md5sums.py bag1 [bag2 bag3 ...]")
|
||||
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_moved_messages.py
vendored
Executable file
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_moved_messages.py
vendored
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import rospy
|
||||
import rosbag
|
||||
import fileinput
|
||||
|
||||
def fixbags(md5file, inbag, outbag):
|
||||
d = {}
|
||||
for line in fileinput.input(md5file):
|
||||
sp = line.split()
|
||||
d[sp[1]] = [sp[0], sp[2], sp[3]]
|
||||
|
||||
rebag = rosbag.Bag(outbag, 'w')
|
||||
|
||||
for topic, msg, t in rosbag.Bag(inbag).read_messages(raw=True):
|
||||
type, bytes, md5 = msg[0], msg[1], msg[2]
|
||||
|
||||
if md5 in d:
|
||||
if type != d[md5][0]:
|
||||
print('WARNING: found matching md5, but non-matching name')
|
||||
continue
|
||||
msg = (d[md5][1], msg[1], d[md5][2])
|
||||
|
||||
rebag.write(topic, msg, t, raw=True)
|
||||
|
||||
rebag.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) == 4:
|
||||
fixbags(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
else:
|
||||
print('usage: fix_moved_messages.py <name_md5_file> <inbag> <outbag>')
|
||||
exit(2)
|
||||
79
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_msg_defs.py
vendored
Executable file
79
thirdparty/ros/ros_comm/tools/rosbag/scripts/fix_msg_defs.py
vendored
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import rosbag.migration
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print('usage: fix_msg_defs.py <inbag> <outbag>')
|
||||
exit(2)
|
||||
|
||||
mm = rosbag.migration.MessageMigrator()
|
||||
|
||||
checked = set()
|
||||
migrations = []
|
||||
|
||||
inbag = rosbag.Bag(sys.argv[1], 'r')
|
||||
outbag = rosbag.Bag(sys.argv[2], 'w')
|
||||
lookup_cache = {}
|
||||
|
||||
#msg is: datatype, data, pytype._md5sum, bag_pos, pytype
|
||||
for topic, msg, t in inbag.read_messages(raw=True):
|
||||
if msg[4]._md5sum != msg[2]:
|
||||
k = (msg[0], msg[2])
|
||||
if k in lookup_cache:
|
||||
real_msg_type = lookup_cache[k]
|
||||
else:
|
||||
real_msg_type = mm.lookup_type(k)
|
||||
if real_msg_type != None:
|
||||
print("FOUND: %s [%s] was defined in migration system\n"%(msg[0], msg[2]), file=sys.stderr)
|
||||
else:
|
||||
systype = roslib.message.get_message_class(msg[0])
|
||||
if systype != None and systype._md5sum == msg[2]:
|
||||
real_msg_type = systype
|
||||
print("FOUND: %s [%s] was defined on your package path\n"%(msg[0], msg[2]), file=sys.stderr)
|
||||
if real_msg_type == None:
|
||||
real_msg_type = msg[4]
|
||||
print("WARNING: Type [%s] with md5sum [%s] has an unknown definition.\n"%(msg[0], msg[2]), file=sys.stderr)
|
||||
lookup_cache[k] = real_msg_type
|
||||
outbag.write(topic, (msg[0], msg[1], msg[2], msg[3], real_msg_type), t, raw=True)
|
||||
else:
|
||||
outbag.write(topic, msg, t, raw=True)
|
||||
|
||||
inbag.close()
|
||||
outbag.close()
|
||||
|
||||
exit(0)
|
||||
54
thirdparty/ros/ros_comm/tools/rosbag/scripts/fixbag.py
vendored
Executable file
54
thirdparty/ros/ros_comm/tools/rosbag/scripts/fixbag.py
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import rosbag.migration
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 3:
|
||||
print('usage: fixbag.py <inbag> <outbag> [rulefile1, rulefile2, ...]')
|
||||
exit(2)
|
||||
|
||||
if sys.argv[2].split('.')[-1] == 'bmr':
|
||||
print('Second argument should be a bag, not a rule file.', file=sys.stderr)
|
||||
exit(2)
|
||||
|
||||
mm = rosbag.migration.MessageMigrator(sys.argv[3:])
|
||||
if not rosbag.migration.fixbag(mm, sys.argv[1], sys.argv[2]):
|
||||
print('Bag could not be migrated.')
|
||||
exit(1)
|
||||
|
||||
print('Bag migrated successfully.')
|
||||
exit(0)
|
||||
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/fixbag_batch.py
vendored
Executable file
67
thirdparty/ros/ros_comm/tools/rosbag/scripts/fixbag_batch.py
vendored
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import rosbag.migration
|
||||
|
||||
def fixbag_batch(inbags):
|
||||
mm = rosbag.migration.MessageMigrator()
|
||||
|
||||
for b in inbags:
|
||||
print('Trying to migrate: %s' % b)
|
||||
outbag = b + '.tmp'
|
||||
if not rosbag.migration.fixbag(mm, b, outbag):
|
||||
os.remove(outbag)
|
||||
print(' Migration failed.')
|
||||
continue
|
||||
|
||||
oldnamebase = b + '.old'
|
||||
oldname = oldnamebase
|
||||
i = 1
|
||||
while os.path.isfile(oldname):
|
||||
i += 1
|
||||
oldname = oldnamebase + str(i)
|
||||
os.rename(b, oldname)
|
||||
os.rename(outbag, b)
|
||||
print(' Migration successful. Original stored as: %s' % oldname)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) >= 2:
|
||||
fixbag_batch(sys.argv[1:])
|
||||
else:
|
||||
print('usage: fixbag_batch.py bag1 [bag2 bag3 ...]')
|
||||
exit(2)
|
||||
157
thirdparty/ros/ros_comm/tools/rosbag/scripts/makerule.py
vendored
Executable file
157
thirdparty/ros/ros_comm/tools/rosbag/scripts/makerule.py
vendored
Executable file
@@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import rosbag.migration
|
||||
|
||||
import genpy.message
|
||||
import genpy.dynamic
|
||||
|
||||
def print_trans(old, new, indent):
|
||||
from_txt = '%s [%s]' % (old._type, old._md5sum)
|
||||
if new is not None:
|
||||
to_txt= '%s [%s]' % (new._type, new._md5sum)
|
||||
else:
|
||||
to_txt = 'Unknown'
|
||||
print(' ' * indent + ' * From: %s' % from_txt)
|
||||
print(' ' * indent + ' To: %s' % to_txt)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(usage='usage: makerule.py msg.saved [-a] output_rulefile [rulefile1, rulefile2, ...] [-n]')
|
||||
parser.add_option('-a', '--append', action='store_true', dest='append', default=False)
|
||||
parser.add_option('-n', '--noplugins', action='store_true', dest='noplugins', default=False)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) < 2:
|
||||
parser.error("Incorrect number of arguments")
|
||||
|
||||
rulefile = args[1]
|
||||
|
||||
if os.path.isfile(rulefile) and not options.append:
|
||||
print("The file %s already exists. Include -a if you intend to append." % rulefile, file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
if not os.path.isfile(rulefile) and options.append:
|
||||
print("The file %s does not exist, and so -a is invalid." % rulefile, file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
if options.append:
|
||||
append_rule = [rulefile]
|
||||
else:
|
||||
append_rule = []
|
||||
|
||||
f = open(args[0])
|
||||
if f is None:
|
||||
print('Could not open message full definition: %s', file=sys.stderr)
|
||||
sys.exit()
|
||||
|
||||
type_line = f.readline()
|
||||
pat = re.compile(r"\[(.*)]:")
|
||||
type_match = pat.match(type_line)
|
||||
if type_match is None:
|
||||
print("Full definition file malformed. First line should be: '[my_package/my_msg]:'", file=sys.stderr)
|
||||
sys.exit()
|
||||
|
||||
old_type = type_match.groups()[0]
|
||||
old_full_text = f.read()
|
||||
f.close()
|
||||
|
||||
old_class = genpy.dynamic.generate_dynamic(old_type,old_full_text)[old_type]
|
||||
|
||||
if old_class is None:
|
||||
print('Could not generate class from full definition file.', file=sys.stderr)
|
||||
sys.exit()
|
||||
|
||||
mm = rosbag.migration.MessageMigrator(args[2:]+append_rule,not options.noplugins)
|
||||
|
||||
migrations = rosbag.migration.checkmessages(mm, [old_class])
|
||||
|
||||
if migrations == []:
|
||||
print('Saved definition is up to date.')
|
||||
exit(0)
|
||||
|
||||
print('The following migrations need to occur:')
|
||||
|
||||
all_rules = []
|
||||
for m in migrations:
|
||||
all_rules.extend(m[1])
|
||||
|
||||
print_trans(m[0][0].old_class, m[0][-1].new_class, 0)
|
||||
if len(m[1]) > 0:
|
||||
print(" %d rules missing:" % len(m[1]))
|
||||
for r in m[1]:
|
||||
print_trans(r.old_class, r.new_class, 1)
|
||||
|
||||
if rulefile is None:
|
||||
print("rulefile not specified")
|
||||
else:
|
||||
output = ''
|
||||
rules_left = mm.filter_rules_unique(all_rules)
|
||||
|
||||
if rules_left == []:
|
||||
print("\nNo additional rule files needed to be generated. %s not created." % rulefile)
|
||||
exit(0)
|
||||
|
||||
while rules_left != []:
|
||||
extra_rules = []
|
||||
|
||||
for r in rules_left:
|
||||
if r.new_class is None:
|
||||
print("The message type %s appears to have moved. Please enter the type to migrate it to." % r.old_class._type)
|
||||
new_type = raw_input('>')
|
||||
new_class = genpy.message.get_message_class(new_type)
|
||||
while new_class is None:
|
||||
print("\'%s\' could not be found in your system. Please make sure it is built." % new_type)
|
||||
new_type = raw_input('>')
|
||||
new_class = genpy.message.get_message_class(new_type)
|
||||
new_rule = mm.make_update_rule(r.old_class, new_class)
|
||||
R = new_rule(mm, 'GENERATED.' + new_rule.__name__)
|
||||
R.find_sub_paths()
|
||||
new_rules = [r for r in mm.expand_rules(R.sub_rules) if r.valid == False]
|
||||
extra_rules.extend(new_rules)
|
||||
print('Creating the migration rule for %s requires additional missing rules:' % new_type)
|
||||
for nr in new_rules:
|
||||
print_trans(nr.old_class, nr.new_class,1)
|
||||
output += R.get_class_def()
|
||||
else:
|
||||
output += r.get_class_def()
|
||||
rules_left = mm.filter_rules_unique(extra_rules)
|
||||
f = open(rulefile, 'a')
|
||||
f.write(output)
|
||||
f.close()
|
||||
print("\nThe necessary rule files have been written to: %s" % rulefile)
|
||||
35
thirdparty/ros/ros_comm/tools/rosbag/scripts/rosbag
vendored
Executable file
35
thirdparty/ros/ros_comm/tools/rosbag/scripts/rosbag
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2008, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import rosbag
|
||||
rosbag.rosbagmain()
|
||||
64
thirdparty/ros/ros_comm/tools/rosbag/scripts/savemsg.py
vendored
Executable file
64
thirdparty/ros/ros_comm/tools/rosbag/scripts/savemsg.py
vendored
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import optparse
|
||||
import sys
|
||||
import roslib.message
|
||||
import rosbag
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(usage='usage: savemsg.py [-b <bagfile] type')
|
||||
parser.add_option('-b', '--bagfiles', action='store', dest='bagfile', default=None, help='Save message from a bagfile rather than system definition')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) < 1:
|
||||
parser.error('Message type not specified.')
|
||||
|
||||
if options.bagfile is None:
|
||||
sys_class = roslib.message.get_message_class(args[0])
|
||||
if sys_class is None:
|
||||
print('Could not find message %s.' % args[0], file=sys.stderr)
|
||||
else:
|
||||
print('[%s]:' % args[0])
|
||||
print(sys_class._full_text)
|
||||
else:
|
||||
for topic, msg, t in rosbag.Bag(options.bagfile).read_messages(raw=True):
|
||||
if msg[0] == args[0]:
|
||||
print('[%s]:' % args[0])
|
||||
print(msg[4]._full_text)
|
||||
exit(0)
|
||||
|
||||
print('Could not find message %s in bag %s.' % (args[0], options.bagfile), file=sys.stderr)
|
||||
50
thirdparty/ros/ros_comm/tools/rosbag/scripts/topic_renamer.py
vendored
Executable file
50
thirdparty/ros/ros_comm/tools/rosbag/scripts/topic_renamer.py
vendored
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2009, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import rospy
|
||||
import rosbag
|
||||
|
||||
def rename_topic(intopic, inbag, outtopic, outbag):
|
||||
rebag = rosbag.Bag(outbag, 'w')
|
||||
for topic, msg, t in rosbag.Bag(inbag).read_messages(raw=True):
|
||||
rebag.write(outtopic if topic == intopic else topic, msg, t, raw=True)
|
||||
rebag.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) == 5:
|
||||
rename_topic(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
||||
else:
|
||||
print("usage: topic_renamer.py <intopic> <inbag> <outtopic> <outbag>")
|
||||
Reference in New Issue
Block a user