Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 """A simple tool to remove leading slashes from frame names."""
00018
00019 import argparse
00020 import os
00021 import rosbag
00022
00023
00024 def ParseArgs():
00025 argument_parser = argparse.ArgumentParser(
00026 description="Removes leading slashes from frame names.")
00027 argument_parser.add_argument("input", type=str, help="Input bag")
00028 return argument_parser.parse_args()
00029
00030
00031 def RewriteMsg(msg):
00032 if hasattr(msg, "header"):
00033 if msg.header.frame_id.startswith("/"):
00034 msg.header.frame_id = msg.header.frame_id[1:]
00035 if hasattr(msg, "child_frame_id"):
00036 if msg.child_frame_id.startswith("/"):
00037 msg.child_frame_id = msg.child_frame_id[1:]
00038 if hasattr(msg, "transforms"):
00039 for transform_msg in msg.transforms:
00040 RewriteMsg(transform_msg)
00041
00042
00043 def Main():
00044 options = ParseArgs()
00045 with rosbag.Bag(os.path.splitext(options.input)[0] + ".filtered.bag",
00046 "w") as outbag:
00047 for topic, msg, t in rosbag.Bag(options.input).read_messages():
00048 RewriteMsg(msg)
00049 outbag.write(topic, msg, msg.header.stamp if msg._has_header else t)
00050
00051
00052 if __name__ == "__main__":
00053 Main()