Skip to content

Commit

Permalink
add convert to ros2 bag
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBrizi committed May 31, 2024
1 parent dfadac0 commit 9da999b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "vbr-devkit"
version = "0.0.3"
version = "0.0.4"
description = "Development kit for VBR SLAM dataset"
readme = "README.md"
authors = [
Expand Down
20 changes: 15 additions & 5 deletions python/vbr_devkit/datasets/convert_bag.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import sys
sys.path.append("/home/eg/source/vbr-devkit/python")

from pathlib import Path

from vbr_devkit.datasets import KittiWriter, RosReader
import typer
from enum import Enum
from rich.progress import track
from rosbags import convert


class OutputDataInterface(str, Enum):
kitti = "kitti",
ros2 = "ros2",
# Can insert additional conversion formats


Expand All @@ -19,10 +20,19 @@ class OutputDataInterface(str, Enum):
}

def main(to: OutputDataInterface, input_dir: Path, output_dir: Path) -> None:
with RosReader(input_dir) as reader:
with OutputDataInterface_lut[to](output_dir) as writer:
for timestamp, topic, message in track(reader, description="Processing..."):
writer.publish(timestamp, topic, message)
if to == OutputDataInterface.ros2:
if not input_dir.is_dir():
print("Processing...")
convert.convert(input_dir, output_dir / input_dir.stem)
else:
for item in track(list(input_dir.iterdir()), description="Processing..."):
if item.suffix == '.bag':
convert.convert(item, output_dir / item.stem)
else:
with RosReader(input_dir) as reader:
with OutputDataInterface_lut[to](output_dir) as writer:
for timestamp, topic, message in track(reader, description="Processing..."):
writer.publish(timestamp, topic, message)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion python/vbr_devkit/tools/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys

sys.path.append("/home/eg/source/vbr-devkit/python")
import typer
from pathlib import Path
from rich.console import Group
Expand Down

0 comments on commit 9da999b

Please sign in to comment.