Skip to content

Commit

Permalink
[CR-578] Add expected output directory for rosbag2 conversion script …
Browse files Browse the repository at this point in the history
…- executed with dummy plugin - don't install ros2 when publishing to PYPI

Also includes:

* Amend changelog
* Add examples in slamcore-convert-rosbag2 script epilog
* [STYLE] Fix linter issues
  • Loading branch information
nikoskoukis-slamcore committed Jun 1, 2023
1 parent 3a03e98 commit bf418bc
Show file tree
Hide file tree
Showing 35 changed files with 5,694 additions and 24 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Setup ROS
uses: ros-tooling/setup-ros@v0.6
with:
use-ros2-testing: false
required-ros-distributions: humble
- name: Publish package to pypi
uses: JRubics/poetry-publish@v1.9
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
27 changes: 19 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,38 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## 0.1.6 (2022-05-31)

### Added

- New script: `slamcore-convert-rosbag2`
- New package extra - `ros2`

### Fixed

- Bug in test_utils - assertions on stdout / stderr were not working properly

## 0.1.4 (2022-04-07)

### Changed

* Support `python >= 3.6.8` instead of `>=3.7`
- Support `python >= 3.6.8` instead of `>=3.7`

## 0.1.3 (2022-02-08)

### Changed

* Amend `capture_info.json` files that are to be embedded in the supported
datasets. Make them reflect the structure of the dataset and sensors
modality more accurately.
- Amend `capture_info.json` files that are to be embedded in the supported
datasets. Make them reflect the structure of the dataset and sensors
modality more accurately.

## 0.1.0 (2021-12-07)

* Add scripts for OpenLORIS dataset conversion (`convert_openrloris.py`) and
- Add scripts for OpenLORIS dataset conversion (`convert_openrloris.py`) and
interactive `setup-dataset` script
* First minor version 🎉
* Bootstrap project via
[python_bootstrap](https://github.com/bergercookie/python_package_cookiecutter)
- First minor version 🎉
- Bootstrap project via
[python_bootstrap](https://github.com/bergercookie/python_package_cookiecutter)

<!-- ### Added -->
<!-- ### Changed -->
Expand Down
2 changes: 1 addition & 1 deletion slamcore_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from slamcore_utils.dataset_dir_converter import DatasetDirConverter
from slamcore_utils.dataset_subdir_writer import DatasetSubdirWriter
from slamcore_utils.logging import setup_pkg_logging
from slamcore_utils.openloris_converter import OpenLORISConverter
from slamcore_utils.measurement_type import MeasurementType
from slamcore_utils.openloris_converter import OpenLORISConverter

__all__ = [
"DataConverter",
Expand Down
2 changes: 1 addition & 1 deletion slamcore_utils/measurement_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
__license__ = "SLAMcore Confidential"


from functools import lru_cache
import re
from functools import lru_cache
from typing import Dict, Optional, Sequence


Expand Down
1 change: 0 additions & 1 deletion slamcore_utils/ros2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
Ros2ConverterPlugin,
Ros2PluginInitializationFailureError,
)

from .ros2_utils import (
get_topic_names_to_message_counts,
get_topic_names_to_types,
Expand Down
5 changes: 2 additions & 3 deletions slamcore_utils/ros2/ros2_converter_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ def description_long(self) -> str:
)

def description_short(self) -> str:
return (
f"Msgs: {self.msg_type:20}, Writer {self.writer_type.__name__}"
)
return f"Msgs: {self.msg_type:20}, Writer {self.writer_type.__name__}"

def __str__(self):
return self.description_short()


class Ros2PluginInitializationFailureError(BaseException):
"""Exception raised when the plugin at hand could not be initailized correctly."""

Expand Down
40 changes: 36 additions & 4 deletions slamcore_utils/scripts/convert_rosbag2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


import sys

from slamcore_utils.logging import logger
from slamcore_utils.utils import inform_about_app_extras

Expand Down Expand Up @@ -77,7 +78,7 @@
)
from slamcore_utils.progress_bar import progress_bar
from slamcore_utils.ros_utils import add_parser_args
from slamcore_utils.utils import format_dict, valid_path
from slamcore_utils.utils import format_dict, format_list, valid_path

"""
Convert rosbag2 to Slamcore Euroc dataset format.
Expand Down Expand Up @@ -139,8 +140,10 @@ def load_converter_plugins(plugin_path: Path) -> Sequence[Ros2ConverterPlugin]:
if "converter_plugins" not in ns_dict:
raise RuntimeError(
f"No converter plugins were exported in specified plugin -> {plugin_path}\n",
'Make sure that you have initialized a variable named "converter_plugins" '
"at the top-level of the said plugin.",
(
'Make sure that you have initialized a variable named "converter_plugins" '
"at the top-level of the said plugin."
),
)

converter_plugins = ns_dict["converter_plugins"]
Expand Down Expand Up @@ -314,12 +317,18 @@ def teardown(self):
}


class ArgumentDefaultsHelpAndRawFormatter(
argparse.RawDescriptionHelpFormatter, argparse.ArgumentDefaultsHelpFormatter
):
pass


# main ----------------------------------------------------------------------------------------
def main():
# argument parsing and sanity checks ------------------------------------------------------
parser = argparse.ArgumentParser(
description="Convert ROS2 Bags to the Slamcore Dataset Reader format.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
formatter_class=ArgumentDefaultsHelpAndRawFormatter,
)
add_parser_args(parser)

Expand All @@ -332,6 +341,29 @@ def main():
nargs="*",
default=[],
)

executable = Path(sys.argv[0]).stem
usecases = {
"Convert the sample rosbag2 to the Slamcore dataset format": (
"-c tests/test_data/trimmed_rosbag2.json -b"
" tests/tests/test_data/trimmed_rosbag2/trimmed_rosbag2_0.db3 -o output"
),
"Convert the sample rosbag2 to the Slamcore dataset format, in verbose mode + ovewrite if exists": (
"-c tests/test_data/trimmed_rosbag2.json -b"
" tests/tests/test_data/trimmed_rosbag2/trimmed_rosbag2_0.db3 -o output -vv"
" --overwrite"
),
"Convert the sample rosbag2 to the Slamcore dataset format - use sample conversion plugin": (
"-c tests/test_data/executables/slamcore_convert_rosbag2_with_plugin/cfg.jsonc -b"
" tests/tests/test_data/trimmed_rosbag2/trimmed_rosbag2_0.db3 -o output"
" tests/test_data/executables/slamcore_convert_rosbag2_with_plugin/distance_travelled_conversion_plugin.py"
),
}
parser.epilog = format_list(
header="Usage examples:",
items=[f"{k}\n {executable} {v}\n" for k, v in usecases.items()],
)

parser_args = vars(parser.parse_args())

# converter_plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

import csv

from std_msgs.msg import Float64

from slamcore_utils import DatasetSubdirWriter, MeasurementType, setup_pkg_logging
from slamcore_utils.ros2 import Ros2ConverterPlugin
from std_msgs.msg import Float64

plugin_name = __file__.replace(".py", "")
logger = setup_pkg_logging(plugin_name)


class DistanceTravelledWriter(DatasetSubdirWriter):
def __init__(self, directory):
super().__init__(directory=directory)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distance_travelled
7.870008438305277
16.34458932731422
30.356390538783874
47.659025826456315
61.64726739375633
72.14834892047361
Loading

0 comments on commit bf418bc

Please sign in to comment.