Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
fix: set storage_type
Browse files Browse the repository at this point in the history
  • Loading branch information
hayato-m126 committed Jul 29, 2024
1 parent a16e40a commit cd3ec25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 8 additions & 1 deletion autoware_msg_bag_converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# https://github.com/ros2/rosbag2/blob/rolling/rosbag2_py/test/test_sequential_writer.py
# https://github.com/ros2/rosbag2/blob/rolling/rosbag2_py/test/test_reindexer.py

from pathlib import Path

from rosbag2_py import Reindexer
from rosbag2_py import TopicMetadata

Expand All @@ -33,7 +35,12 @@ def change_topic_type(old_type: TopicMetadata) -> TopicMetadata:
)


def convert_bag(input_bag_path: str, output_bag_path: str, storage_type: str) -> None:
def convert_bag(input_bag_path: str, output_bag_path: str) -> None:
p_input = Path(input_bag_path)
storage_type = "mcap"
for _ in p_input.glob("*.db3"):
storage_type = "sqlite3"
break
# open reader
reader = create_reader(input_bag_path, storage_type)
# open writer
Expand Down
3 changes: 1 addition & 2 deletions autoware_msg_bag_converter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ def convert_bag_in_directory(input_dir: str, output_dir: str) -> None:
pattern = re.compile(r".*\.(db3|mcap)$")
bag_paths = [p for p in input_root.rglob("*") if pattern.match(str(p))]
for db3_or_mcap_path in bag_paths:
storage_type = "mcap" if db3_or_mcap_path.suffix == ".mcap" else "sqlite3"
input_bag_dir = db3_or_mcap_path.parent
rel_path = input_bag_dir.relative_to(input_root)
output_bag_dir = output_root.joinpath(rel_path)
convert_bag(input_bag_dir.as_posix(), output_bag_dir.as_posix(), storage_type)
convert_bag(input_bag_dir.as_posix(), output_bag_dir.as_posix())


def main() -> None:
Expand Down

0 comments on commit cd3ec25

Please sign in to comment.