From c16fab70b11782d5a40a513a67cfa5c851f850bb Mon Sep 17 00:00:00 2001 From: Benjamin Morgan Date: Mon, 25 Mar 2024 11:10:49 +0100 Subject: [PATCH] esmini: Move from optional to base The optional directory contains projects that are hard to build. ESMini does not fall into this category, since the sources are freely available. This commit does the following: - Move optional/esmini to plugins/esmini - Move optional/osi to osi - Replace Conan recipe for vendor/esmini and vendor/esmini-data - Replace Conan recipe for vendor/open-simulation-interface - Patch the esmini and osi Cloe libraries for compatibility with new open-simulation-interface. In particular, the generated headers are now namespaced with osi3/ - Fix several findings in esmini and osi Cloe libraries highlighted by clang-tidy. The vendored libraries are written in a manner similar to how it is done in the Conan-Center-Index. --- .github/workflows/build-cloe.yaml | 2 +- .gitignore | 3 + Dockerfile | 2 +- Makefile.all | 28 +- conanfile.py | 203 ++---- optional/esmini/.gitignore | 1 - optional/esmini/Makefile | 43 -- optional/esmini/README.md | 15 - optional/esmini/vendor/esmini/.gitignore | 8 - optional/esmini/vendor/esmini/CMakeLists.txt | 15 - optional/esmini/vendor/esmini/Makefile | 7 - optional/esmini/vendor/esmini/conanfile.py | 172 ----- .../vendor/esmini/patches/esmini_2_23_2.patch | 74 --- .../vendor/esmini/patches/esmini_2_25_1.patch | 117 ---- optional/osi/.gitignore | 1 - optional/osi/Makefile | 45 -- .../.gitignore | 1 - .../CMakeLists.txt | 80 --- .../conanfile.py | 74 --- optional/osi/vendor/protoc/conanfile.py | 34 - optional/vtd/src/osi_sensor_component.hpp | 5 +- optional/vtd/src/vtd_osi_test.cpp | 4 +- {optional/osi => osi}/CMakeLists.txt | 18 +- osi/Makefile | 1 + {optional/osi => osi}/conanfile.py | 20 +- .../include/cloe}/component/osi_sensor.hpp | 21 +- .../cloe}/utility/osi_ground_truth.hpp | 32 +- .../cloe}/utility/osi_message_handler.hpp | 91 ++- .../include/cloe}/utility/osi_transceiver.hpp | 23 +- .../cloe}/utility/osi_transceiver_tcp.hpp | 30 +- .../include/cloe}/utility/osi_utils.hpp | 20 +- .../src/cloe}/component/osi_sensor_test.cpp | 22 +- .../src/cloe}/utility/osi_ground_truth.cpp | 18 +- .../src/cloe}/utility/osi_message_handler.cpp | 268 ++++---- .../osi => osi/src/cloe}/utility/osi_test.cpp | 16 +- .../src/cloe}/utility/osi_transceiver_tcp.cpp | 15 +- .../src/cloe}/utility/osi_utils.cpp | 27 +- {optional => plugins}/esmini/CMakeLists.txt | 11 +- plugins/esmini/Makefile | 1 + {optional => plugins}/esmini/conanfile.py | 14 +- {optional => plugins}/esmini/src/esmini.cpp | 38 +- .../esmini/src/esmini_conf.hpp | 31 +- .../esmini/src/esmini_ego_control.hpp | 19 +- .../esmini/src/esmini_logger.hpp | 2 +- .../esmini/src/esmini_osi_sensor.hpp | 32 +- .../esmini/src/esmini_sensor_components.hpp | 2 +- .../esmini/src/esmini_test.cpp | 4 +- .../esmini/src/esmini_vehicle.hpp | 2 +- .../esmini/src/esmini_world_data.hpp | 4 +- .../esmini/tests/conanfile_esmini.py | 14 +- .../esmini/tests/config_esmini_aeb.json | 0 .../tests/config_esmini_closed_loop.json | 0 .../esmini/tests/config_esmini_cut_in.json | 0 .../esmini/tests/config_esmini_open_loop.json | 0 .../esmini/tests/controller_basic_aeb.json | 0 .../esmini/tests/controller_virtue.json | 0 .../esmini/tests/test_esmini.bats | 0 .../esmini/tests/test_esmini_closed_loop.json | 0 .../esmini/tests/test_esmini_open_loop.json | 0 .../tests/conanfile_default.py | 6 +- .../esmini-data}/Makefile | 2 +- vendor/esmini-data/conandata.yml | 12 + vendor/esmini-data/conanfile.py | 46 ++ .../patches/2.37.0-test-driver-path.patch | 27 + .../vendor/protoc => vendor/esmini}/Makefile | 4 +- vendor/esmini/conandata.yml | 21 + vendor/esmini/conanfile.py | 179 +++++ vendor/esmini/patches/2.37.0_add_ctest.patch | 55 ++ vendor/esmini/patches/2.37.0_cloud_urls.patch | 122 ++++ .../2.37.0_remove_operating_system_test.patch | 23 + .../2.37.0_use_conan_osi_package.patch | 523 +++++++++++++++ vendor/esmini/test_package/CMakeLists.txt | 10 + vendor/esmini/test_package/conanfile.py | 30 + .../resources/VehicleCatalog.xosc | 614 ++++++++++++++++++ .../resources/curves_elevation.xodr | 163 +++++ .../esmini/test_package}/test-driver.xosc | 4 +- vendor/esmini/test_package/test_package.cpp | 20 + vendor/open-simulation-interface/Makefile | 11 + .../open-simulation-interface/conandata.yml | 45 ++ vendor/open-simulation-interface/conanfile.py | 92 +++ .../patches/3.0.1_single_lib.patch | 114 ++++ .../patches/3.1.2_single_lib.patch | 82 +++ .../patches/3.2.0_single_lib.patch | 114 ++++ .../patches/3.3.x_single_lib.patch | 81 +++ .../patches/3.4.0_single_lib.patch | 69 ++ .../patches/3.5.0_single_lib.patch | 91 +++ .../patches/3.6.0_single_lib.patch | 91 +++ .../test_package/CMakeLists.txt | 11 + .../test_package/conanfile.py | 26 + .../test_package/test_package.cpp | 18 + 90 files changed, 3153 insertions(+), 1283 deletions(-) delete mode 100644 optional/esmini/.gitignore delete mode 100644 optional/esmini/Makefile delete mode 100644 optional/esmini/README.md delete mode 100644 optional/esmini/vendor/esmini/.gitignore delete mode 100644 optional/esmini/vendor/esmini/CMakeLists.txt delete mode 100644 optional/esmini/vendor/esmini/Makefile delete mode 100644 optional/esmini/vendor/esmini/conanfile.py delete mode 100644 optional/esmini/vendor/esmini/patches/esmini_2_23_2.patch delete mode 100644 optional/esmini/vendor/esmini/patches/esmini_2_25_1.patch delete mode 100644 optional/osi/.gitignore delete mode 100644 optional/osi/Makefile delete mode 100644 optional/osi/vendor/open-simulation-interface-3.3.1/.gitignore delete mode 100644 optional/osi/vendor/open-simulation-interface-3.3.1/CMakeLists.txt delete mode 100644 optional/osi/vendor/open-simulation-interface-3.3.1/conanfile.py delete mode 100644 optional/osi/vendor/protoc/conanfile.py rename {optional/osi => osi}/CMakeLists.txt (82%) create mode 100644 osi/Makefile rename {optional/osi => osi}/conanfile.py (81%) rename {optional/osi/include/osi => osi/include/cloe}/component/osi_sensor.hpp (61%) rename {optional/osi/include/osi => osi/include/cloe}/utility/osi_ground_truth.hpp (78%) rename {optional/osi/include/osi => osi/include/cloe}/utility/osi_message_handler.hpp (78%) rename {optional/osi/include/osi => osi/include/cloe}/utility/osi_transceiver.hpp (82%) rename {optional/osi/include/osi => osi/include/cloe}/utility/osi_transceiver_tcp.hpp (81%) rename {optional/osi/include/osi => osi/include/cloe}/utility/osi_utils.hpp (76%) rename {optional/osi/src/osi => osi/src/cloe}/component/osi_sensor_test.cpp (74%) rename {optional/osi/src/osi => osi/src/cloe}/utility/osi_ground_truth.cpp (80%) rename {optional/osi/src/osi => osi/src/cloe}/utility/osi_message_handler.cpp (83%) rename {optional/osi/src/osi => osi/src/cloe}/utility/osi_test.cpp (92%) rename {optional/osi/src/osi => osi/src/cloe}/utility/osi_transceiver_tcp.cpp (87%) rename {optional/osi/src/osi => osi/src/cloe}/utility/osi_utils.cpp (91%) rename {optional => plugins}/esmini/CMakeLists.txt (78%) create mode 100644 plugins/esmini/Makefile rename {optional => plugins}/esmini/conanfile.py (87%) rename {optional => plugins}/esmini/src/esmini.cpp (87%) rename {optional => plugins}/esmini/src/esmini_conf.hpp (65%) rename {optional => plugins}/esmini/src/esmini_ego_control.hpp (95%) rename {optional => plugins}/esmini/src/esmini_logger.hpp (97%) rename {optional => plugins}/esmini/src/esmini_osi_sensor.hpp (88%) rename {optional => plugins}/esmini/src/esmini_sensor_components.hpp (99%) rename {optional => plugins}/esmini/src/esmini_test.cpp (94%) rename {optional => plugins}/esmini/src/esmini_vehicle.hpp (99%) rename {optional => plugins}/esmini/src/esmini_world_data.hpp (98%) rename {optional => plugins}/esmini/tests/conanfile_esmini.py (69%) rename {optional => plugins}/esmini/tests/config_esmini_aeb.json (100%) rename {optional => plugins}/esmini/tests/config_esmini_closed_loop.json (100%) rename {optional => plugins}/esmini/tests/config_esmini_cut_in.json (100%) rename {optional => plugins}/esmini/tests/config_esmini_open_loop.json (100%) rename {optional => plugins}/esmini/tests/controller_basic_aeb.json (100%) rename {optional => plugins}/esmini/tests/controller_virtue.json (100%) rename {optional => plugins}/esmini/tests/test_esmini.bats (100%) rename {optional => plugins}/esmini/tests/test_esmini_closed_loop.json (100%) rename {optional => plugins}/esmini/tests/test_esmini_open_loop.json (100%) rename {optional/osi/vendor/open-simulation-interface-3.3.1 => vendor/esmini-data}/Makefile (87%) create mode 100644 vendor/esmini-data/conandata.yml create mode 100644 vendor/esmini-data/conanfile.py create mode 100644 vendor/esmini-data/patches/2.37.0-test-driver-path.patch rename {optional/osi/vendor/protoc => vendor/esmini}/Makefile (71%) create mode 100644 vendor/esmini/conandata.yml create mode 100644 vendor/esmini/conanfile.py create mode 100644 vendor/esmini/patches/2.37.0_add_ctest.patch create mode 100644 vendor/esmini/patches/2.37.0_cloud_urls.patch create mode 100644 vendor/esmini/patches/2.37.0_remove_operating_system_test.patch create mode 100644 vendor/esmini/patches/2.37.0_use_conan_osi_package.patch create mode 100644 vendor/esmini/test_package/CMakeLists.txt create mode 100644 vendor/esmini/test_package/conanfile.py create mode 100644 vendor/esmini/test_package/resources/VehicleCatalog.xosc create mode 100644 vendor/esmini/test_package/resources/curves_elevation.xodr rename {optional/esmini/vendor/esmini/scenarios/xosc => vendor/esmini/test_package}/test-driver.xosc (98%) create mode 100644 vendor/esmini/test_package/test_package.cpp create mode 100644 vendor/open-simulation-interface/Makefile create mode 100644 vendor/open-simulation-interface/conandata.yml create mode 100644 vendor/open-simulation-interface/conanfile.py create mode 100644 vendor/open-simulation-interface/patches/3.0.1_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.1.2_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.2.0_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.3.x_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.4.0_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.5.0_single_lib.patch create mode 100644 vendor/open-simulation-interface/patches/3.6.0_single_lib.patch create mode 100644 vendor/open-simulation-interface/test_package/CMakeLists.txt create mode 100644 vendor/open-simulation-interface/test_package/conanfile.py create mode 100644 vendor/open-simulation-interface/test_package/test_package.cpp diff --git a/.github/workflows/build-cloe.yaml b/.github/workflows/build-cloe.yaml index 5ae969956..43eb30249 100644 --- a/.github/workflows/build-cloe.yaml +++ b/.github/workflows/build-cloe.yaml @@ -22,7 +22,7 @@ jobs: - "cloe-normal" package_target: # 1. Build each test configuration in Conan cache and run all tests - - "export smoketest-deps smoketest" + - "export export-vendor smoketest-deps smoketest" env: CONAN_NON_INTERACTIVE: "yes" DEBIAN_FRONTEND: noninteractive diff --git a/.gitignore b/.gitignore index 2bcf5c989..ded2157eb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,9 @@ setup.sh # Standard out-of-source build build/ +# Vendored Conan recipes sometimes extract fetched sources +vendor/**/src/ + # Documentation docs/_build/ docs/_extra/ diff --git a/Dockerfile b/Dockerfile index e4d10c2e8..f2960dcec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,7 +69,7 @@ WORKDIR /cloe SHELL ["/bin/bash", "-c"] ARG PROJECT_VERSION=unknown -ARG PACKAGE_TARGET="export smoketest-deps" +ARG PACKAGE_TARGET="export-vendor export smoketest-deps" ARG KEEP_SOURCES=0 COPY . /cloe diff --git a/Makefile.all b/Makefile.all index ef48dc0ee..fbf633780 100644 --- a/Makefile.all +++ b/Makefile.all @@ -37,7 +37,7 @@ SUBMAKEFLAGS := META_PKG := cloe PLUGIN_PKGS := $(wildcard plugins/*) -ALL_PKGS := fable runtime models oak engine ${PLUGIN_PKGS} ${META_PKG} +ALL_PKGS := fable runtime models oak osi engine ${PLUGIN_PKGS} ${META_PKG} WITHOUT_PKGS := UNSELECT_PKGS := ${WITHOUT_PKGS} WITH_PKGS := @@ -48,7 +48,7 @@ SELECT_PKGS := $(call uniq, $(filter-out ${UNSELECT_PKGS}, ${ALL_PKGS}) ${WITH_P ## ## Functions analogously to normal package selection. ## -ALL_VENDOR := +ALL_VENDOR := $(wildcard vendor/*) WITHOUT_VENDOR := UNSELECT_VENDOR := ${WITHOUT_VENDOR} WITH_VENDOR := @@ -61,7 +61,13 @@ runtime: fable models: runtime oak: runtime engine: models oak +osi: runtime models vendor/open-simulation-interface ${PLUGIN_PKGS}: runtime models +plugins/esmini: vendor/open-simulation-interface vendor/esmini + +vendor/esmini: vendor/open-simulation-interface +vendor/esmini-data: +vendor/open-simulation-interface: ## BUILD_POLICY ## Usage: make BUILD_POLICY="missing" @@ -119,9 +125,9 @@ ${META_PKG}: done # Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) -# define make_vendor_target -# $(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) -# endef +define make_vendor_target +$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) +endef # Usage: $(call make_every_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_every_target @@ -141,9 +147,9 @@ endef help:: $(call print_help_section, "Available build targets") -# $(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") -# $(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") -# $(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") +$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") +$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") +$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") help:: echo @@ -179,15 +185,15 @@ $(call make_select_target, clean-select, "remove build artifacts", "[in-source]" help:: echo $(call print_help_subsection, "Options") -# $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") + $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") $(call print_help_option, WITH_PKGS, "", "include optional packages from ${_grn}UNSELECT_PKGS${_rst}") $(call print_help_option, LOCKFILE_SOURCE, "", "use specified conanfile as lockfile source for build") echo $(call print_help_subsection, "Defines") $(call print_help_option, BUILD_POLICY, ${BUILD_POLICY}) $(call print_help_define, CONAN_OPTIONS, ${CONAN_OPTIONS}) -# $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) -# $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) + $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) + $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) $(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS}) $(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS}) echo diff --git a/conanfile.py b/conanfile.py index b7ede528f..42e1464f5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,9 +1,7 @@ # mypy: ignore-errors # pylint: skip-file -import os from pathlib import Path -from semver import SemVer from conan import ConanFile from conan.tools import cmake, files, scm @@ -18,56 +16,22 @@ class Cloe(ConanFile): description = "Closed-loop automated driving simulation environment" topics = ["simulation"] settings = "os", "compiler", "build_type", "arch" - provides = ( - "fable", - "cloe-runtime", - "cloe-models", - "cloe-oak", - "cloe-engine", - "cloe-plugins-core", - "cloe-plugin-basic", - "cloe-plugin-gndtruth-extractor", - "cloe-plugin-minimator", - "cloe-plugin-mocks", - "cloe-plugin-noisy-sensor", - "cloe-plugin-speedometer", - "cloe-plugin-virtue", - ) options = { - "shared": [True, False], - "fPIC": [True, False], - "fable_allow_comments": [True, False], - "engine_server": [True, False], - "engine_lrdb": [True, False] + "with_vtd": [True, False], + "with_engine": [True, False], + + # Doesn't affect package ID: + "pedantic": [True, False], } default_options = { - "shared": True, - "fPIC": True, - "fable_allow_comments": True, - "engine_server": True, - "engine_lrdb": True, - } - generators = "CMakeDeps", "VirtualRunEnv" - no_copy_source = True - exports_sources = [ - "*/cmake/*", - "*/src/*", - "*/include/*", - "*/CMakeLists.txt", + "with_vtd": False, + "with_engine": True, - "fable/examples/*", + "pedantic": True, - "engine/lua/*", - "engine/webui/*", - "engine/vendor/*", - - "plugins/*/src/*", - "plugins/*/include/*", - "plugins/*/ui/*", - "plugins/*/CMakeLists.txt", - - "CMakelists.txt" - ] + "cloe-engine:server": True, + } + no_copy_source = True def set_version(self): version_file = Path(self.recipe_folder) / "VERSION" @@ -78,120 +42,31 @@ def set_version(self): self.version = git.run("describe --dirty=-dirty")[1:] def requirements(self): - self.requires("fmt/9.1.0") - self.requires("inja/3.4.0") - self.requires("nlohmann_json/3.11.2") - self.requires("incbin/cci.20211107"), - self.requires("spdlog/1.11.0") - self.requires("eigen/3.4.0") - self.requires("cli11/2.3.2", private=True) - self.requires("sol2/3.3.1") - self.requires("boost/[>=1.65.1]") - if self.options.engine_server: - self.requires("oatpp/1.3.0") - - def build_requirements(self): - self.test_requires("gtest/1.13.0") - - def layout(self): - cmake.cmake_layout(self) - self.cpp.build.bindirs = ["bin"] - self.cpp.source.includedirs.append(os.path.join(self.folders.build, "include")) - - def generate(self): - # The version as a single 32-bit number takes the format: - # - # (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION - # - # Each version consists of at most 8 bits, so 256 potential values, including 0. - # The epoch starts with 0, and is bumped after each version naming scheme. - semver = SemVer(self.version, True) - version_u32 = (0<<24) | (semver.major << 16) | (semver.minor << 8) | semver.patch - - tc = cmake.CMakeToolchain(self) - tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True - tc.cache_variables["CMAKE_MODULE_PATH"] = self.source_folder + "/runtime/cmake" - tc.cache_variables["FABLE_VERSION"] = self.version - tc.cache_variables["FABLE_VERSION_U32"] = version_u32 - tc.cache_variables["FABLE_ALLOW_COMMENTS"] = self.options.fable_allow_comments - tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version - tc.cache_variables["CLOE_VERSION"] = self.version - tc.cache_variables["CLOE_VERSION_U32"] = version_u32 - tc.cache_variables["CLOE_ENGINE_WITH_SERVER"] = self.options.engine_server - tc.cache_variables["CLOE_ENGINE_WITH_LRDB"] = self.options.engine_lrdb - tc.generate() - - def build(self): - cm = cmake.CMake(self) - if self.should_configure: - cm.configure() - if self.should_build: - cm.build() - if self.should_test: - cm.test() - - def package(self): - if self.should_install: - cm = cmake.CMake(self) - cm.install() - - # Package license files for compliance - for meta, dep in self.dependencies.items(): - if dep.package_folder is None: - continue - ref = str(meta.ref) - name = ref[: str(ref).index("/")] - files.copy( - self, - "*", - src=os.path.join(dep.package_folder, "licenses"), - dst=os.path.join(self.package_folder, "licenses", name), - ) - - def package_info(self): - self.cpp_info.set_property("cmake_find_mode", "both") - self.cpp_info.set_property("cmake_file_name", "cloe") - self.cpp_info.set_property("pkg_config_name", "cloe") - - self.cpp_info.components["fable"].libs = ["fable"] - self.cpp_info.components["fable"].set_property("cmake_file_name", "fable") - self.cpp_info.components["fable"].set_property("cmake_target_name", "fable::fable") - self.cpp_info.components["fable"].set_property("pkg_config_name", "fable") - - self.cpp_info.components["runtime"].libs = ["cloe-runtime"] - self.cpp_info.components["runtime"].requires = ["fable"] - self.cpp_info.components["runtime"].set_property("cmake_file_name", "cloe-runtime") - self.cpp_info.components["runtime"].set_property("cmake_target_name", "cloe::runtime") - self.cpp_info.components["runtime"].set_property("pkg_config_name", "cloe-runtime") - - if self.settings.os == "Linux": - self.cpp_info.system_libs.append("pthread") - self.cpp_info.system_libs.append("dl") - - # Linking to libstdc++fs is required on GCC < 9. - # (GCC compilers with version < 7 have no std::filesystem support.) - # No consideration has been made yet for other compilers, - # please add them here as necessary. - if self.settings.get_safe("compiler") == "gcc" and self.settings.get_safe("compiler.version") in ["7", "8"]: - self.cpp_info.system_libs = ["stdc++fs"] - - self.cpp_info.libs = files.collect_libs(self) - if not self.in_local_cache: # editable build - self.cpp_info.builddirs.append(os.path.join(self.source_folder, "cmake")) - self.cpp_info.includedirs.append(os.path.join(self.build_folder, "include")) - bindir = os.path.join(self.build_folder, "bin") - luadir = os.path.join(self.source_folder, "engine/lua") - libdir = os.path.join(self.build_folder, "lib"); - else: - self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "cloe")) - bindir = os.path.join(self.package_folder, "bin") - luadir = os.path.join(self.package_folder, "lib/cloe/lua") - libdir = None - - self.output.info(f"Appending PATH environment variable: {bindir}") - self.runenv_info.prepend_path("PATH", bindir) - self.output.info(f"Appending CLOE_LUA_PATH environment variable: {luadir}") - self.runenv_info.prepend_path("CLOE_LUA_PATH", luadir) - if libdir is not None: - self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}") - self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) + def cloe_requires(dep): + self.requires(f"{dep}/{self.version}@cloe/develop") + + cloe_requires("cloe-runtime") + cloe_requires("cloe-models") + cloe_requires("cloe-plugin-basic") + cloe_requires("cloe-plugin-gndtruth-extractor") + cloe_requires("cloe-plugin-minimator") + cloe_requires("cloe-plugin-mocks") + cloe_requires("cloe-plugin-noisy-sensor") + cloe_requires("cloe-plugin-speedometer") + cloe_requires("cloe-plugin-virtue") + if self.options.with_vtd: + cloe_requires("cloe-plugin-vtd") + + boost_version = "[>=1.65.0]" + if self.options.with_engine: + cloe_requires("cloe-engine") + + # Overrides: + self.requires("fmt/9.1.0", override=True) + self.requires("inja/3.4.0", override=True) + self.requires("nlohmann_json/3.11.2", override=True) + self.requires("incbin/cci.20211107", override=True), + self.requires(f"boost/{boost_version}", override=True) + + def package_id(self): + del self.info.options.pedantic diff --git a/optional/esmini/.gitignore b/optional/esmini/.gitignore deleted file mode 100644 index 567609b12..000000000 --- a/optional/esmini/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/optional/esmini/Makefile b/optional/esmini/Makefile deleted file mode 100644 index acaeed9af..000000000 --- a/optional/esmini/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -PROJECT_ROOT := ../.. -include ${PROJECT_ROOT}/Makefile.package - -# ------------------------------------------------- - -ALL_VENDOR := $(wildcard vendor/*) -.PHONY: ${ALL_VENDOR} - -WITHOUT_VENDOR := -UNSELECT_VENDOR := ${WITHOUT_VENDOR} -WITH_VENDOR := -SELECT_VENDOR := $(call uniq, $(filter-out ${UNSELECT_VENDOR}, ${ALL_VENDOR}) ${WITH_VENDOR}) - -REGEX_TARGET := 's/(-vendor|-select)?-each//' -${SELECT_VENDOR}: - ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET}) - -# Usage: $(call _make_target_rule, TARGET-NAME, MAKE-TARGET, HELP-DESCRIPTION, MAKE-ARGUMENTS) -define _make_target_rule -${1}: - $(call print_header, "Proceeding to $(call unquote, ${3})") - ${MAKE} ${SUBMAKEFLAGS} PROJECT_ROOT=$(realpath ${PROJECT_ROOT}) ${4} ${2} -endef - -# Usage: $(call _make_target_rules, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY, PACKAGE-DIRS) -define _make_target_rules -help:: - $(call print_help_target, ${1}, ${2}, ${3}) -$(call _make_target_rule,${1},${1}-each,${2}) -${1}-each: ${4} -endef - -# Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) -define make_vendor_target -$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) -endef - -help:: - $(call print_help_section, "Available vendor targets") - -$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") -$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") -$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") diff --git a/optional/esmini/README.md b/optional/esmini/README.md deleted file mode 100644 index c9993793f..000000000 --- a/optional/esmini/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# ESMini Simulator Binding Plugin - -To prepare running the smoketests, first export required packages like so: - -``` -make export-vendor export \ - && make -C ../osi export-vendor export \ - && make -C ../../ export-all -``` - -Then, build the packages and run the smoketests: - -``` -make smoketest-deps smoketest -``` diff --git a/optional/esmini/vendor/esmini/.gitignore b/optional/esmini/vendor/esmini/.gitignore deleted file mode 100644 index 29b127750..000000000 --- a/optional/esmini/vendor/esmini/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -src/ -build/ - -# Conan -conan.lock -conaninfo.txt -conanbuildinfo.txt -graph_info.json diff --git a/optional/esmini/vendor/esmini/CMakeLists.txt b/optional/esmini/vendor/esmini/CMakeLists.txt deleted file mode 100644 index b3cad4f46..000000000 --- a/optional/esmini/vendor/esmini/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.8) - -project(esmini_conan - LANGUAGES CXX -) - -include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(NO_OUTPUT_DIRS) - -conan_set_find_paths() -conan_set_find_library_paths() - -set(CMAKE_FIND_DEBUG_MODE TRUE) - -add_subdirectory(${CMAKE_PROJECT_SUBDIR}) diff --git a/optional/esmini/vendor/esmini/Makefile b/optional/esmini/vendor/esmini/Makefile deleted file mode 100644 index 959f80fc9..000000000 --- a/optional/esmini/vendor/esmini/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Override Makefile.package settings. -override SOURCE_DIR := src -override PACKAGE_CHANNEL := cloe/stable -override CLEAN_SOURCE_DIR := true - -PROJECT_ROOT := ../../../.. -include ${PROJECT_ROOT}/Makefile.package diff --git a/optional/esmini/vendor/esmini/conanfile.py b/optional/esmini/vendor/esmini/conanfile.py deleted file mode 100644 index e869e6a9a..000000000 --- a/optional/esmini/vendor/esmini/conanfile.py +++ /dev/null @@ -1,172 +0,0 @@ -import glob -import os -from pathlib import Path -from conans import CMake, ConanFile, RunEnvironment, tools -from conans.tools import SystemPackageTool - - -class ESMini(ConanFile): - name = "esmini" - version = "2.24.0" - license = "Mozilla Public License Version 2.0" - url = "/~https://github.com/esmini/esmini" - description = "Basic OpenScenario player." - topics = ("Environment Simulator", "OpenScenario", "OpenDrive") - settings = "os", "compiler", "build_type", "arch" - options = { - "shared": [True, False], - "fPIC": [True, False], - "test": [True, False], - "with_osg": [True, False], - "with_osi": [True, False], - "with_sumo": [True, False], - } - default_options = { - "shared": True, - "fPIC": True, - "test": True, - "with_osg": True, - "with_osi": True, - "with_sumo": False, - } - generators = "cmake" - build_policy = "missing" - no_copy_source = False - requires = [] - - _patch_file = "patches/esmini_2_25_1.patch" - - _pkg_scenario_dir = "scenarios" - - exports_sources = [ - "CMakeLists.txt", - _patch_file, - f"{_pkg_scenario_dir}/*", - ] - _git_url = "/~https://github.com/esmini/esmini.git" - _git_dir = "esmini" - _git_ref = "develop" if version == "latest" else f"v{version}" - _sim_dir = "EnvironmentSimulator" - _test_deps = [_sim_dir, "resources", "scripts"] - _test_dir = f"{_git_dir}/{_sim_dir}/Unittest/" - _lib_dir = f"{_git_dir}/{_sim_dir}/Libraries/" - _bin_dir = f"{_git_dir}/{_sim_dir}/Applications/" - _resources_dir = f"{_git_dir}/resources" - - _protobuf_dyn = True - - _cmake = None - - def configure(self): - if self.options.with_osg: - self.options.with_osi = True - if self.options.with_osi: - self.options["open-simulation-interface"].shared = self.options.shared - self.options["protobuf"].shared = self._protobuf_dyn - self.options["protobuf"].debug_suffix = False - - def source(self): - git = tools.Git(folder=self._git_dir) - git.clone(self._git_url, self._git_ref, shallow=True) - - def system_requirements(self): - pkg_names = None - if self.options.with_osg: - pkg_names = [ - "libfontconfig1-dev", - "libgl-dev", - "libxrandr-dev", - "libxinerama-dev", - ] # TODO: add all system requirements - if pkg_names: - installer = SystemPackageTool() - for pkg in pkg_names: - installer.install([pkg]) - - def requirements(self): - if self.options.with_osi: - self.requires("protobuf/[~=3.15.5]", override=True) - self.requires("open-simulation-interface/3.3.1@cloe/stable") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_PROJECT_SUBDIR"] = self._git_dir - self._cmake.definitions["CMAKE_PROJECT_VERSION"] = self.version - self._cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["USE_OSG"] = self.options.with_osg - self._cmake.definitions["USE_OSI"] = self.options.with_osi - self._cmake.definitions["USE_SUMO"] = self.options.with_sumo - self._cmake.definitions["USE_GTEST"] = self.options.test - self._cmake.definitions["DYN_PROTOBUF"] = self._protobuf_dyn - self._cmake.configure() - return self._cmake - - def build(self): - trg_path = self._git_dir - patch_file = self._patch_file - if not self.in_local_cache: - trg_path = self.source_folder + "/" + trg_path - patch_file = self.recipe_folder + "/" + patch_file - tools.patch(base_path=trg_path, patch_file=patch_file) - - cmake = self._configure_cmake() - cmake.build() - if self.options.test: - self._prepare_tests() - with tools.chdir(self._test_dir): - with tools.environment_append(RunEnvironment(self).vars): - for test in glob.glob("*_test"): - self.run(Path(test).resolve().as_posix()) - self._cleanup_tests() - - def _prepare_tests(self): - for d in self._test_deps: - self.run(f"ln -sf {self.source_folder}/{self._git_dir}/{d}") - - def _cleanup_tests(self): - for d in self._test_deps: - if os.path.islink(d): - self.run(f"rm -f {d}") - - def package(self): - cmake = self._configure_cmake() - cmake.install() - self.copy( - pattern="*.hpp", - dst="include", - src=f"{self.source_folder}/{self._lib_dir}", - keep_path=False, - ) - self.copy(pattern="*.so", dst="lib", src=self._lib_dir, keep_path=False) - self.copy(pattern="*.a", dst="lib", src=self._lib_dir, keep_path=False) - apps = os.listdir(self._bin_dir) - for app in apps: - self.copy( - pattern=app, dst="bin", src=f"{self._bin_dir}/{app}", keep_path=False - ) - self.copy( - pattern="*", - dst=self._pkg_scenario_dir, - src=f"{self.source_folder}/{self._resources_dir}", - ) - assert Path(f"{self.package_folder}/{self._pkg_scenario_dir}/xosc").exists() - self.copy( - "*", - dst=self._pkg_scenario_dir, - src=f"{self.source_folder}/{self._pkg_scenario_dir}", - ) - - def package_id(self): - if self.options.with_osi: - self.info.requires["open-simulation-interface"].full_package_mode() - - def package_info(self): - self.cpp_info.set_property("cmake_find_mode", "both") - self.cpp_info.set_property("cmake_file_name", self.name) - self.cpp_info.set_property("pkg_config_name", self.name) - - self.cpp_info.libs = tools.collect_libs(self) - self.runenv_info.define("ESMINI_XOSC_PATH", f"{self.package_folder}/{self._pkg_scenario_dir}/xosc") diff --git a/optional/esmini/vendor/esmini/patches/esmini_2_23_2.patch b/optional/esmini/vendor/esmini/patches/esmini_2_23_2.patch deleted file mode 100644 index 6bdddd65a..000000000 --- a/optional/esmini/vendor/esmini/patches/esmini_2_23_2.patch +++ /dev/null @@ -1,74 +0,0 @@ -diff --git a/EnvironmentSimulator/CMakeLists.txt b/EnvironmentSimulator/CMakeLists.txt -index 12e7b75..20b3ed1 100644 ---- a/EnvironmentSimulator/CMakeLists.txt -+++ b/EnvironmentSimulator/CMakeLists.txt -@@ -27,7 +27,7 @@ set ( GTEST_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../externals/googletest" ) - set( CMAKE_VERBOSE_MAKEFILE true ) - - if ( ${FILE_STORAGE} STREQUAL "github" ) -- set ( MODELS_PACKAGE_URL /~https://github.com/esmini/resources/raw/main/models/models.7z ) -+ set ( MODELS_PACKAGE_URL https://dl.dropboxusercontent.com/s/5gk8bvgzqiaaoco/models.7z?dl=0 ) - if (APPLE) - set ( OSG_PACKAGE_URL /~https://github.com/esmini/resources/raw/main/libs/OpenSceneGraph_mac.7z ) - set ( OSI_PACKAGE_URL /~https://github.com/esmini/resources/raw/main/libs/osi_mac.7z ) -diff --git a/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.cpp b/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.cpp -index 5eee886..a246b2f 100644 ---- a/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.cpp -+++ b/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.cpp -@@ -613,9 +613,9 @@ int OSIReporter::UpdateOSIMovingObject(ObjectState *objectState) - obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_driver_id()->set_value((uint64_t)objectState->state_.info.ctrl_type); - - // Set OSI Moving Object Boundingbox -- obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_x((double)(objectState->state_.info.boundingbox.center_.x_)); -- obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_y((double)(objectState->state_.info.boundingbox.center_.y_)); -- obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_z((double)(objectState->state_.info.boundingbox.center_.z_)); -+ obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_x((double)(-1.0*objectState->state_.info.boundingbox.center_.x_)); -+ obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_y((double)(-1.0*objectState->state_.info.boundingbox.center_.y_)); -+ obj_osi_internal.mobj->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_z((double)(-1.0*objectState->state_.info.boundingbox.center_.z_)); - obj_osi_internal.mobj->mutable_base()->mutable_dimension()->set_height(objectState->state_.info.boundingbox.dimensions_.height_); - obj_osi_internal.mobj->mutable_base()->mutable_dimension()->set_width(objectState->state_.info.boundingbox.dimensions_.width_); - obj_osi_internal.mobj->mutable_base()->mutable_dimension()->set_length(objectState->state_.info.boundingbox.dimensions_.length_); -diff --git a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -index 5bfc170..79798dc 100644 ---- a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -+++ b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -@@ -265,7 +265,7 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) - SE_StepDT(0.001f); - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 68925); // initial OSI size, including static content -+ EXPECT_EQ(fileStatus.st_size, 70214); // initial OSI size, including static content - - int road_lane_size; - -@@ -277,12 +277,12 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) - SE_StepDT(0.001f); // Step for write another frame to osi file - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 69388); // slight growth due to only dynamic updates -+ EXPECT_EQ(fileStatus.st_size, 70829); // slight growth due to only dynamic updates - - SE_StepDT(0.001f); // Step for write another frame to osi file - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 69852); // slight growth due to only dynamic updates -+ EXPECT_EQ(fileStatus.st_size, 71445); // slight growth due to only dynamic updates - - SE_Close(); - } -@@ -784,13 +784,13 @@ TEST(GroundTruthTests, check_GroundTruth_including_init_state) - SE_Close(); - - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 19831); -+ EXPECT_EQ(fileStatus.st_size, 30282); - - // Read OSI file - FILE* file = fopen("gt.osi", "rb"); - ASSERT_NE(file, nullptr); - -- const int max_msg_size = 10000; -+ const int max_msg_size = 10091; - int msg_size; - char msg_buf[max_msg_size]; - diff --git a/optional/esmini/vendor/esmini/patches/esmini_2_25_1.patch b/optional/esmini/vendor/esmini/patches/esmini_2_25_1.patch deleted file mode 100644 index 91d68ca51..000000000 --- a/optional/esmini/vendor/esmini/patches/esmini_2_25_1.patch +++ /dev/null @@ -1,117 +0,0 @@ -diff --git a/EnvironmentSimulator/CMakeLists.txt b/EnvironmentSimulator/CMakeLists.txt -index 005d33e..7cb691d 100644 ---- a/EnvironmentSimulator/CMakeLists.txt -+++ b/EnvironmentSimulator/CMakeLists.txt -@@ -1,5 +1,5 @@ - --set ( FILE_STORAGE "github" ) # "github", "dropbox", "google" (Dropbox limited GB/Day) -+set ( FILE_STORAGE "dropbox" ) # "github", "dropbox", "google" (Dropbox limited GB/Day) - - set ( VIEWER_BASE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Modules/ViewerBase" ) - set ( PLAYER_BASE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Modules/PlayerBase" ) -@@ -17,7 +17,7 @@ set ( CONTROLLERS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Modules/Controllers") - # OpenSceneGraph package adapted for this project - set ( OSG_VERSION "osg161" ) - set ( OSG_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../externals/OpenSceneGraph" ) --set ( OSI_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../externals/OSI" ) -+set ( OSI_BASE_DIR "${CONAN_OPEN-SIMULATION-INTERFACE_ROOT}" ) - set ( SUMO_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../externals/SUMO" ) - - # GoogleTest package -@@ -117,7 +117,7 @@ set ( MODELS_DIR "${MODELS_BASE_DIR}/models" ) - set ( MODELS_PACKAGE_FILENAME models.7z) - - set ( OSG_DIR "${OSG_BASE_DIR}/${EXT_DIR_NAME}" ) --set ( OSI_DIR "${OSI_BASE_DIR}/${EXT_DIR_NAME}" ) -+set ( OSI_DIR "${OSI_BASE_DIR}/" ) - set ( SUMO_DIR "${SUMO_BASE_DIR}/${EXT_DIR_NAME}" ) - set ( GTEST_DIR "${GTEST_BASE_DIR}/${EXT_DIR_NAME}" ) - -@@ -132,7 +132,7 @@ set ( OSG_LIBRARIES_PATH - - set ( OSI_INCLUDE_DIR "${OSI_DIR}/include" ) - if (DYN_PROTOBUF) -- set ( OSI_LIBRARIES_PATH "${OSI_DIR}/lib-dyn" ) -+ set ( OSI_LIBRARIES_PATH "${OSI_DIR}/lib" ) - else () - set ( OSI_LIBRARIES_PATH "${OSI_DIR}/lib" ) - endif (DYN_PROTOBUF) -@@ -272,13 +272,13 @@ elseif(LINUX) - - if (DYN_PROTOBUF) - set ( OSI_LIBRARIES -- optimized open_simulation_interface debug open_simulation_interfaced -- optimized protobuf debug protobufd -+ optimized open_simulation_interface debug open_simulation_interface -+ optimized protobuf debug protobuf - ) - else () - set ( OSI_LIBRARIES -- optimized open_simulation_interface_pic debug open_simulation_interface_picd -- optimized protobuf debug protobufd -+ optimized open_simulation_interface_pic debug open_simulation_interface_pic -+ optimized protobuf debug protobuf - ) - endif (DYN_PROTOBUF) - -@@ -352,8 +352,8 @@ elseif(MSVC) - ) - - set ( OSI_LIBRARIES -- optimized libprotobuf debug libprotobufd -- optimized open_simulation_interface_pic debug open_simulation_interface_picd -+ optimized libprotobuf debug libprotobuf -+ optimized open_simulation_interface_pic debug open_simulation_interface_pic - ) - - set ( SUMO_LIBRARIES -@@ -532,9 +532,9 @@ endif() - - # download OSI - set ( OSI_PACKAGE_FILENAME "osi.7z" ) --if (DEFINED OSI_DIR AND (FORCE_DOWNLOAD_BINARIES OR NOT EXISTS ${OSI_DIR} )) -- download_and_extract( ${OSI_PACKAGE_URL} ${OSI_BASE_DIR} ${OSI_PACKAGE_FILENAME} ) --endif() -+#if (DEFINED OSI_DIR AND (FORCE_DOWNLOAD_BINARIES OR NOT EXISTS ${OSI_DIR} )) -+# download_and_extract( ${OSI_PACKAGE_URL} ${OSI_BASE_DIR} ${OSI_PACKAGE_FILENAME} ) -+#endif() - - # download SUMO - set ( SUMO_PACKAGE_FILENAME "sumo.7z" ) -diff --git a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -index 5b5edb3..f24c99c 100644 ---- a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -+++ b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp -@@ -332,7 +332,7 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) - SE_StepDT(0.001f); - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 69228); // initial OSI size, including static content -+ EXPECT_EQ(fileStatus.st_size, 70779); // initial OSI size, including static content - - int road_lane_size; - -@@ -344,12 +344,12 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) - SE_StepDT(0.001f); // Step for write another frame to osi file - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 69691); // slight growth due to only dynamic updates -+ EXPECT_EQ(fileStatus.st_size, 71394); // slight growth due to only dynamic updates - - SE_StepDT(0.001f); // Step for write another frame to osi file - SE_FlushOSIFile(); - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 70155); // slight growth due to only dynamic updates -+ EXPECT_EQ(fileStatus.st_size, 72010); // slight growth due to only dynamic updates - - SE_Close(); - } -@@ -851,7 +851,7 @@ TEST(GroundTruthTests, check_GroundTruth_including_init_state) - SE_Close(); - - ASSERT_EQ(stat("gt.osi", &fileStatus), 0); -- EXPECT_EQ(fileStatus.st_size, 19471); -+ EXPECT_EQ(fileStatus.st_size, 29760); - - // Read OSI file - FILE* file = fopen("gt.osi", "rb"); diff --git a/optional/osi/.gitignore b/optional/osi/.gitignore deleted file mode 100644 index 567609b12..000000000 --- a/optional/osi/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/optional/osi/Makefile b/optional/osi/Makefile deleted file mode 100644 index e3ed7a1b4..000000000 --- a/optional/osi/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -PROJECT_ROOT := ../.. -include ${PROJECT_ROOT}/Makefile.package - -# ------------------------------------------------- - -ALL_VENDOR := $(wildcard vendor/*) -.PHONY: ${ALL_VENDOR} - -WITHOUT_VENDOR := -UNSELECT_VENDOR := ${WITHOUT_VENDOR} -WITH_VENDOR := -SELECT_VENDOR := $(call uniq, $(filter-out ${UNSELECT_VENDOR}, ${ALL_VENDOR}) ${WITH_VENDOR}) - -vendor/open-simulation-interface-3.3.1: vendor/protoc - -REGEX_TARGET := 's/(-vendor|-select)?-each//' -${SELECT_VENDOR}: - ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET}) - -# Usage: $(call _make_target_rule, TARGET-NAME, MAKE-TARGET, HELP-DESCRIPTION, MAKE-ARGUMENTS) -define _make_target_rule -${1}: - $(call print_header, "Proceeding to $(call unquote, ${3})") - ${MAKE} ${SUBMAKEFLAGS} PROJECT_ROOT=$(realpath ${PROJECT_ROOT}) ${4} ${2} -endef - -# Usage: $(call _make_target_rules, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY, PACKAGE-DIRS) -define _make_target_rules -help:: - $(call print_help_target, ${1}, ${2}, ${3}) -$(call _make_target_rule,${1},${1}-each,${2}) -${1}-each: ${4} -endef - -# Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) -define make_vendor_target -$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) -endef - -help:: - $(call print_help_section, "Available vendor targets") - -$(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") -$(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") -$(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") diff --git a/optional/osi/vendor/open-simulation-interface-3.3.1/.gitignore b/optional/osi/vendor/open-simulation-interface-3.3.1/.gitignore deleted file mode 100644 index 8eba6c8dd..000000000 --- a/optional/osi/vendor/open-simulation-interface-3.3.1/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/ diff --git a/optional/osi/vendor/open-simulation-interface-3.3.1/CMakeLists.txt b/optional/osi/vendor/open-simulation-interface-3.3.1/CMakeLists.txt deleted file mode 100644 index 96825a461..000000000 --- a/optional/osi/vendor/open-simulation-interface-3.3.1/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) - -project(open_simulation_interface - LANGUAGES CXX -) - -include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS NO_OUTPUT_DIRS) - -find_package(Protobuf REQUIRED) -# make sure that protobuf_generate_cpp finds the protobuf headers -set(Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIRS}) - -set(VERSION_MAJOR 3) -set(VERSION_MINOR 3) -set(VERSION_PATCH 1) -configure_file(osi_version.proto.in ${CMAKE_CURRENT_SOURCE_DIR}/osi_version.proto) - -set(OSI_SOURCE_FILES - osi_version.proto - osi_common.proto - osi_datarecording.proto - osi_detectedtrafficsign.proto - osi_detectedtrafficlight.proto - osi_detectedroadmarking.proto - osi_detectedlane.proto - osi_detectedobject.proto - osi_detectedoccupant.proto - osi_environment.proto - osi_groundtruth.proto - osi_hostvehicledata.proto - osi_trafficsign.proto - osi_trafficlight.proto - osi_trafficupdate.proto - osi_trafficcommand.proto - osi_roadmarking.proto - osi_lane.proto - osi_featuredata.proto - osi_logicaldetectiondata.proto - osi_object.proto - osi_occupant.proto - osi_sensordata.proto - osi_sensorviewconfiguration.proto - osi_sensorspecific.proto - osi_sensorview.proto -) -protobuf_generate_cpp(OSI_PROTO_SRCS OSI_PROTO_HDRS ${OSI_SOURCE_FILES}) - -add_library(${PROJECT_NAME} - ${OSI_PROTO_SRCS} -) -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON -) -target_include_directories(${PROJECT_NAME} - PUBLIC - $ - $ - $ -) -target_link_libraries(${PROJECT_NAME} - PUBLIC - # todo: migrate to conan 2.0 - CONAN_PKG::protobuf -) - -include(GNUInstallDirs) -install(TARGETS ${PROJECT_NAME} - LIBRARY - DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE - DESTINATION ${CMAKE_INSTALL_LIBDIR} -) - -# Install generated headers -install( - FILES ${OSI_PROTO_HDRS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) diff --git a/optional/osi/vendor/open-simulation-interface-3.3.1/conanfile.py b/optional/osi/vendor/open-simulation-interface-3.3.1/conanfile.py deleted file mode 100644 index 16ee14b19..000000000 --- a/optional/osi/vendor/open-simulation-interface-3.3.1/conanfile.py +++ /dev/null @@ -1,74 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -import os -import shutil - -from conans import CMake, ConanFile, tools - - -class OpenSimulationInterfaceConan(ConanFile): - name = "open-simulation-interface" - version = "3.3.1" - license = "Mozilla Public License 2.0" - url = "/~https://github.com/OpenSimulationInterface/open-simulation-interface" - description = "A generic interface for the environmental perception of automated driving functions in virtual scenarios." - topics = ("Sensor Simulation", "HAD") - settings = "os", "compiler", "build_type", "arch" - options = { - "shared": [True, False], - "fPIC": [True, False], - } - default_options = { - "shared": True, - "fPIC": True, - } - generators = "cmake" - build_policy = "missing" - no_copy_source = False - exports_sources = [ - "CMakeLists.txt", - ] - requires = [ - "protobuf/[~=3.15.2]", - ] - - _git_url = ( - "/~https://github.com/OpenSimulationInterface/open-simulation-interface.git" - ) - _git_dir = "osi" - _git_ref = f"v{version}" - - _cmake = None - - def configure(self): - self.options["protobuf"].shared = self.options.shared - - def source(self): - git = tools.Git(folder=self._git_dir) - git.clone(self._git_url, self._git_ref, shallow=True) - dst = os.path.join(self.source_folder, self._git_dir) - shutil.copy("CMakeLists.txt", dst) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_PROJECT_VERSION"] = self.version - self._cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True - self._cmake.configure(source_folder=self._git_dir) - return self._cmake - - def build(self): - cmake = self._configure_cmake() - cmake.build() - - def package(self): - cmake = self._configure_cmake() - cmake.install() - - def package_id(self): - self.info.requires["protobuf"].full_package_mode() - - def package_info(self): - self.cpp_info.libs = tools.collect_libs(self) diff --git a/optional/osi/vendor/protoc/conanfile.py b/optional/osi/vendor/protoc/conanfile.py deleted file mode 100644 index 015809e9b..000000000 --- a/optional/osi/vendor/protoc/conanfile.py +++ /dev/null @@ -1,34 +0,0 @@ -from conans import CMake, ConanFile, RunEnvironment, tools -from conans.errors import ConanInvalidConfiguration -from pathlib import Path - - -class Protoc(ConanFile): - name = "protoc" - version = "3.15.5" - license = "proprietary" - url = "/~https://github.com/protocolbuffers/protobuf/releases" - description = "Google Protocol Buffers Compiler" - topics = ("serialization", "protobuf") - settings = {"os": ["Linux"], "arch": ["x86_64"]} - - no_copy_source = True - build_policy = "missing" - - _filename = f"protoc-{version}-linux-x86_64.zip" - - def source(self): - tools.download( - f"{self.url}/download/v{self.version}/{self._filename}", self._filename - ) - - def build(self): - tools.unzip( - f"{self.source_folder}/{self._filename}", - self.build_folder, - keep_permissions=True, - ) - - def package(self): - self.copy("*", src="bin", dst="bin") - self.copy("*", src="include", dst="include") diff --git a/optional/vtd/src/osi_sensor_component.hpp b/optional/vtd/src/osi_sensor_component.hpp index 3fb37f851..7b5457009 100644 --- a/optional/vtd/src/osi_sensor_component.hpp +++ b/optional/vtd/src/osi_sensor_component.hpp @@ -29,9 +29,8 @@ #include // for Object #include // for quaternion_from_rpy - -#include // for OsiMsgHandler -#include // for OsiTransceiver +#include // for OsiMsgHandler +#include // for OsiTransceiver #include "vtd_conf.hpp" // for VtdSensorConfig #include "vtd_sensor_data.hpp" // for VtdSensorData diff --git a/optional/vtd/src/vtd_osi_test.cpp b/optional/vtd/src/vtd_osi_test.cpp index e42e6641f..f712b4336 100644 --- a/optional/vtd/src/vtd_osi_test.cpp +++ b/optional/vtd/src/vtd_osi_test.cpp @@ -36,8 +36,8 @@ #include // for SensorData, DetectedEntityHeader #include // for SensorView -#include -#include +#include +#include #include "osi_sensor_component.hpp" // for transform_... diff --git a/optional/osi/CMakeLists.txt b/osi/CMakeLists.txt similarity index 82% rename from optional/osi/CMakeLists.txt rename to osi/CMakeLists.txt index 1417da7f2..b103390de 100644 --- a/optional/osi/CMakeLists.txt +++ b/osi/CMakeLists.txt @@ -10,16 +10,16 @@ find_package(cloe-models REQUIRED) find_package(cloe-runtime REQUIRED) find_package(Eigen3 REQUIRED) find_package(Boost COMPONENTS headers REQUIRED) -find_package(open-simulation-interface REQUIRED) +find_package(open_simulation_interface REQUIRED) message(STATUS "-> Building cloe-osi library.") file(GLOB cloe-osi_PUBLIC_HEADERS "include/**/*.hpp") add_library(cloe-osi # find src -type f -name "*.cpp" \! -name "*_test.cpp" - src/osi/utility/osi_ground_truth.cpp - src/osi/utility/osi_message_handler.cpp - src/osi/utility/osi_transceiver_tcp.cpp - src/osi/utility/osi_utils.cpp + src/cloe/utility/osi_ground_truth.cpp + src/cloe/utility/osi_message_handler.cpp + src/cloe/utility/osi_transceiver_tcp.cpp + src/cloe/utility/osi_utils.cpp # For IDE integration ${cloe-osi_PUBLIC_HEADERS} @@ -41,7 +41,7 @@ target_link_libraries(cloe-osi cloe::runtime Boost::headers Eigen3::Eigen - open-simulation-interface::open-simulation-interface + open_simulation_interface::open_simulation_interface ) # Testing ------------------------------------------------------------- @@ -52,8 +52,8 @@ if(BUILD_TESTING) add_executable(test-osi # find src -type f -name "*_test.cpp" - src/osi/component/osi_sensor_test.cpp - src/osi/utility/osi_test.cpp + src/cloe/component/osi_sensor_test.cpp + src/cloe/utility/osi_test.cpp ) set_target_properties(test-osi PROPERTIES CXX_STANDARD 17 @@ -67,7 +67,7 @@ if(BUILD_TESTING) cloe::runtime cloe::models cloe::osi - open-simulation-interface::open-simulation-interface + open_simulation_interface::open_simulation_interface ) gtest_add_tests(TARGET test-osi) endif() diff --git a/osi/Makefile b/osi/Makefile new file mode 100644 index 000000000..87c6e44df --- /dev/null +++ b/osi/Makefile @@ -0,0 +1 @@ +include ../Makefile.package diff --git a/optional/osi/conanfile.py b/osi/conanfile.py similarity index 81% rename from optional/osi/conanfile.py rename to osi/conanfile.py index a074186a3..91fac54b8 100644 --- a/optional/osi/conanfile.py +++ b/osi/conanfile.py @@ -15,14 +15,12 @@ class CloeOsi(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], - "pedantic": [True, False], } default_options = { "shared": True, "fPIC": True, - "pedantic": True, } - generators = "CMakeDeps", "VirtualRunEnv" + generators = "CMakeDeps" no_copy_source = True exports_sources = [ "include/*", @@ -31,7 +29,7 @@ class CloeOsi(ConanFile): ] def set_version(self): - version_file = Path(self.recipe_folder) / "../../VERSION" + version_file = Path(self.recipe_folder) / "../VERSION" if version_file.exists(): self.version = files.load(self, version_file).strip() else: @@ -41,16 +39,18 @@ def set_version(self): def requirements(self): self.requires(f"cloe-models/{self.version}@cloe/develop") self.requires(f"cloe-runtime/{self.version}@cloe/develop") - self.requires("open-simulation-interface/3.3.1@cloe/stable") - self.requires("boost/[>=1.65.1]") + self.requires("open-simulation-interface/3.5.0@cloe/stable") + self.requires("boost/[>=1.65.0]") self.requires("eigen/3.4.0") + self.requires("zlib/1.2.13", override=True) def configure(self): - self.options["open-simulation-interface"].shared = self.options.shared - self.options["open-simulation-interface"].fPIC = True + if self.options.shared: + self.options.rm_safe("fPIC") + # self.options["open-simulation-interface"].shared = self.options.shared def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -59,7 +59,6 @@ def generate(self): tc = cmake.CMakeToolchain(self) tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version - tc.cache_variables["TargetLintingExtended"] = self.options.pedantic tc.generate() def build(self): @@ -79,7 +78,6 @@ def package(self): def package_id(self): self.info.requires["boost"].full_package_mode() self.info.requires["open-simulation-interface"].full_package_mode() - del self.info.options.pedantic def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") diff --git a/optional/osi/include/osi/component/osi_sensor.hpp b/osi/include/cloe/component/osi_sensor.hpp similarity index 61% rename from optional/osi/include/osi/component/osi_sensor.hpp rename to osi/include/cloe/component/osi_sensor.hpp index ebd82c34f..b806d2bde 100644 --- a/optional/osi/include/osi/component/osi_sensor.hpp +++ b/osi/include/cloe/component/osi_sensor.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023 Robert Bosch GmbH + * Copyright 2024 Robert Bosch GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,28 +17,31 @@ */ /** * \file cloe/component/osi_sensor.hpp - * \see cloe/component/osi.hpp */ #pragma once -#include // for SensorData +#include // for SensorData #include // for Component -namespace cloe_osi { +namespace cloe { -class OsiSensor : public cloe::Component { +class OsiSensor : public Component { public: using cloe::Component::Component; OsiSensor() : Component("osi_sensor") {} - virtual ~OsiSensor() noexcept = default; + OsiSensor(const OsiSensor&) = default; + OsiSensor(OsiSensor&&) = delete; + OsiSensor& operator=(const OsiSensor&) = default; + OsiSensor& operator=(OsiSensor&&) = delete; + ~OsiSensor() noexcept override = default; /** * Return OSI-SensorData */ - virtual const std::shared_ptr& get() const = 0; - virtual std::shared_ptr& get() = 0; + [[nodiscard]] virtual const std::shared_ptr& get() const = 0; + [[nodiscard]] virtual std::shared_ptr& get() = 0; }; -} // namespace cloe_osi +} // namespace cloe diff --git a/optional/osi/include/osi/utility/osi_ground_truth.hpp b/osi/include/cloe/utility/osi_ground_truth.hpp similarity index 78% rename from optional/osi/include/osi/utility/osi_ground_truth.hpp rename to osi/include/cloe/utility/osi_ground_truth.hpp index c3c4087b1..8546a6020 100644 --- a/optional/osi/include/osi/utility/osi_ground_truth.hpp +++ b/osi/include/cloe/utility/osi_ground_truth.hpp @@ -22,16 +22,17 @@ #pragma once -#include // for Vector3d +#include // for std::map<> + +#include // for Vector3d #include // for GroundTruth #include // for MovingObject -#include // for ModelError - -#include "osi/utility/osi_utils.hpp" // for osi_require, .. +#include // for ModelError +#include // for osi_require, .. -namespace cloeosi { +namespace cloe::utility { /** * OsiGroundTruth provides convenient access to auxiliary ground truth @@ -40,7 +41,10 @@ namespace cloeosi { class OsiGroundTruth { public: OsiGroundTruth() = default; - + OsiGroundTruth(const OsiGroundTruth&) = default; + OsiGroundTruth(OsiGroundTruth&&) = delete; + OsiGroundTruth& operator=(const OsiGroundTruth&) = default; + OsiGroundTruth& operator=(OsiGroundTruth&&) = delete; virtual ~OsiGroundTruth() = default; /** @@ -49,8 +53,10 @@ class OsiGroundTruth { */ void set(const osi3::GroundTruth& osi_gt); - const osi3::GroundTruth& get_gt() const { - if (!gt_ptr_) error(); + [[nodiscard]] const osi3::GroundTruth& get_gt() const { + if (gt_ptr_ == nullptr) { + error(); + } return *gt_ptr_; } @@ -63,7 +69,7 @@ class OsiGroundTruth { * Get the offset between coordinate reference frames of a vehicle (rear axle * center) and the bounding box center, e.g. for coordinate transformations. */ - const Eigen::Vector3d& get_veh_coord_sys_info(int obj_id) const { + [[nodiscard]] const Eigen::Vector3d& get_veh_coord_sys_info(int obj_id) const { return veh_bbcenter_to_rear_.at(obj_id); } @@ -75,7 +81,7 @@ class OsiGroundTruth { /** * Get dimensions of a moving object, e.g. for coordinate transformations. */ - const Eigen::Vector3d& get_mov_obj_dimensions(int obj_id) const { + [[nodiscard]] const Eigen::Vector3d& get_mov_obj_dimensions(int obj_id) const { return mov_obj_dimensions_.at(obj_id); } @@ -91,7 +97,7 @@ class OsiGroundTruth { /** * Get the ground truth id of the ego vehicle. */ - uint64_t get_ego_id() const { + [[nodiscard]] uint64_t get_ego_id() const { osi_require("GroundTruth::host_vehicle_id", gt_ptr_->has_host_vehicle_id()); return gt_ptr_->host_vehicle_id().value(); } @@ -99,7 +105,7 @@ class OsiGroundTruth { /** * Get ground truth information for the requested moving object. */ - const osi3::MovingObject* get_moving_object(const uint64_t id) const; + [[nodiscard]] const osi3::MovingObject* get_moving_object(uint64_t id) const; private: void error() const { throw cloe::ModelError("OsiGroundTruth not set"); } @@ -115,4 +121,4 @@ class OsiGroundTruth { std::map mov_obj_dimensions_; }; -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/include/osi/utility/osi_message_handler.hpp b/osi/include/cloe/utility/osi_message_handler.hpp similarity index 78% rename from optional/osi/include/osi/utility/osi_message_handler.hpp rename to osi/include/cloe/utility/osi_message_handler.hpp index 87ce07b5b..0c3af2a91 100644 --- a/optional/osi/include/osi/utility/osi_message_handler.hpp +++ b/osi/include/cloe/utility/osi_message_handler.hpp @@ -22,45 +22,46 @@ #pragma once -#include // for shared_ptr<>, unique_ptr<> +#include // for shared_ptr<>, unique_ptr<> #include // for Isometry3d, Vector3d -#include // for LaneBoundary -#include // for Object -#include // for Json, Duration -#include // for ModelError -#include // for Sync - #include // for Timestamp, Identifier, BaseMoving, .. #include // for DetectedMovingObject #include // for HostVehicleData #include // for MovingObject #include // for SensorData, DetectedEntityHeader -#include "osi/utility/osi_ground_truth.hpp" // for OsiGroundTruth -#include "osi/utility/osi_transceiver.hpp" // for OsiTransceiver -#include "osi/utility/osi_utils.hpp" +#include // for LaneBoundary +#include // for Object +#include // for Duration +#include // for ModelError +#include // for Sync +#include // for OsiGroundTruth +#include // for OsiTransceiver +#include +#include // for Confable +#include // for Json -namespace cloeosi { +namespace cloe::utility { /** * Convert OSI timestamp to Cloe time format. */ -cloe::Duration osi_timestamp_to_time(const osi3::Timestamp& timestamp); +Duration osi_timestamp_to_time(const osi3::Timestamp& timestamp); /** * OSI host vehicle coordinates/orientations are relative to the global ground * truth coordinate system. Here, this data is stored in a Cloe object. */ -void from_osi_host_vehicle_data(const osi3::HostVehicleData& osi_hv, cloe::Object& obj); +void from_osi_host_vehicle_data(const osi3::HostVehicleData& osi_hv, Object& obj); /** * Map the OSI data fields without taking care of transformations to the Cloe * reference frame convention. * Note that the OSI reference frame may differ for different object data types. */ -void from_osi_base_moving(const osi3::BaseMoving& osi_bm, cloe::Object& obj); +void from_osi_base_moving(const osi3::BaseMoving& osi_bm, Object& obj); /** * As from_osi_base_moving, but use ground truth information if required data is @@ -68,24 +69,24 @@ void from_osi_base_moving(const osi3::BaseMoving& osi_bm, cloe::Object& obj); */ void from_osi_base_moving_alt(const osi3::BaseMoving& osi_bm, const osi3::BaseMoving& osi_bm_gt, - cloe::Object& obj); + Object& obj); /** * As from_osi_base_moving, but for stationary objects. */ -void from_osi_base_stationary(const osi3::BaseStationary& osi_bs, cloe::Object& obj); +void from_osi_base_stationary(const osi3::BaseStationary& osi_bs, Object& obj); template -void from_osi_mov_obj_type_classification(const T& osi_mo, cloe::Object::Class& oc); +void from_osi_mov_obj_type_classification(const T& osi_mo, Object::Class& oc); void from_osi_mov_obj_type_classification( const osi3::MovingObject::Type& osi_ot, const osi3::MovingObject::VehicleClassification::Type& osi_vt, - cloe::Object::Class& oc); + Object::Class& oc); void from_osi_detected_moving_object_alt(const osi3::DetectedMovingObject& osi_mo, - const OsiGroundTruth& ground_truth, cloe::Object& obj); + const OsiGroundTruth& ground_truth, Object& obj); -void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, cloe::Object& obj); +void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, Object& obj); /** * \param sensor_pose: Relation between the sensor frame and the ego vehicle @@ -95,14 +96,11 @@ void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, clo */ void transform_obj_coord_from_osi_data(const Eigen::Isometry3d& sensor_pose, const Eigen::Vector3d& dimensions_gt, - cloe::Object& obj); + Object& obj); Eigen::Isometry3d osi_position_orientation_to_pose_alt(const osi3::BaseMoving& base, const osi3::BaseMoving& base_gt); -Eigen::Vector3d osi_vehicle_attrib_rear_offset_to_vector3d( - const osi3::MovingObject::VehicleAttributes& osi_va); - /** * OSI messages of the listed data types may be overwritten by ground truth * information, if requested by the user. @@ -134,13 +132,12 @@ ENUM_SERIALIZATION(SensorMockLevel, ({ /** * Configure sensor mock level. */ -struct SensorMockConf : public cloe::Confable { +struct SensorMockConf : public fable::Confable { using Target = SensorMockTarget; using Level = SensorMockLevel; SensorMockConf() = default; - - virtual ~SensorMockConf() noexcept = default; + ~SensorMockConf() noexcept override = default; std::map level = {{Target::MountingPosition, Level::OverwriteNone}, {Target::DetectedMovingObject, Level::OverwriteNone}, @@ -150,15 +147,15 @@ struct SensorMockConf : public cloe::Confable { CONFABLE_SCHEMA(SensorMockConf) { return fable::Schema{ // clang-format off - {"mounting_position", cloe::Schema(&level[Target::MountingPosition], "mock level for sensor mounting position")}, - {"detected_moving_objects", cloe::Schema(&level[Target::DetectedMovingObject], "mock level for detected moving objects")}, - {"detected_static_objects", cloe::Schema(&level[Target::DetectedStaticObject], "mock level for detected stationary objects")}, - {"detected_lane_boundaries", cloe::Schema(&level[Target::DetectedLaneBoundary], "mock level for detected lane boundaries")}, + {"mounting_position", fable::Schema(&level[Target::MountingPosition], "mock level for sensor mounting position")}, + {"detected_moving_objects", fable::Schema(&level[Target::DetectedMovingObject], "mock level for detected moving objects")}, + {"detected_static_objects", fable::Schema(&level[Target::DetectedStaticObject], "mock level for detected stationary objects")}, + {"detected_lane_boundaries", fable::Schema(&level[Target::DetectedLaneBoundary], "mock level for detected lane boundaries")}, // clang-format on }; } - void to_json(cloe::Json& j) const override { + void to_json(fable::Json& j) const override { j["mounting_position"] = level.at(SensorMockTarget::MountingPosition); j["detected_moving_objects"] = level.at(SensorMockTarget::DetectedMovingObject); j["detected_static_objects"] = level.at(SensorMockTarget::DetectedStaticObject); @@ -197,7 +194,7 @@ class OsiMsgHandler { * Receive and process the incoming osi3 messages. */ template - void process_osi_msgs(const cloe::Sync& s, const bool& restart, cloe::Duration& osi_time); + void process_osi_msgs(const Sync& s, const bool& restart, Duration& osi_time); /** * Store the initial timestamp. @@ -211,7 +208,7 @@ class OsiMsgHandler { * \param osi_sd SensorData message to be processed. * \param osi_time Timestamp of the OSI message. */ - virtual void process_received_msg(osi3::SensorData* osi_sd, cloe::Duration& osi_time); + virtual void process_received_msg(osi3::SensorData* osi_sd, Duration& osi_time); /** * Translate OSI SensorView to Cloe data objects. @@ -219,7 +216,7 @@ class OsiMsgHandler { * \param osi_sv SensorView message to be processed. * \param osi_time Timestamp of the OSI message. */ - virtual void process_received_msg(osi3::SensorView* osi_sv, cloe::Duration& osi_time); + virtual void process_received_msg(osi3::SensorView* osi_sv, Duration& osi_time); /** * Translate OSI GroundTruth to Cloe data objects. @@ -227,7 +224,7 @@ class OsiMsgHandler { * \param osi_gt GroundTruth message to be processed. * \param osi_time Timestamp of the OSI message. */ - virtual void process_received_msg(osi3::GroundTruth* osi_gt, cloe::Duration& osi_time); + virtual void process_received_msg(osi3::GroundTruth* osi_gt, Duration& osi_time); /** * Translate OSI GroundTruth to Cloe data objects. @@ -258,7 +255,7 @@ class OsiMsgHandler { * \param osi_eh DetectedEntityHeader message to be processed (if available). * \param osi_mo DetectedMovingObject message to be processed. */ - virtual void convert_to_cloe_data(const bool has_eh, + virtual void convert_to_cloe_data(bool has_eh, const osi3::DetectedEntityHeader& osi_eh, const osi3::DetectedMovingObject& osi_mo); @@ -268,7 +265,7 @@ class OsiMsgHandler { void detected_lane_boundaries_from_ground_truth(); - void from_osi_boundary_points(const osi3::LaneBoundary& osi_lb, cloe::LaneBoundary& lb, + void from_osi_boundary_points(const osi3::LaneBoundary& osi_lb, LaneBoundary& lb, bool reverse_pt_order); /** @@ -276,21 +273,21 @@ class OsiMsgHandler { * * \param ego_obj Ego object to be stored. */ - virtual void store_ego_object(std::shared_ptr ego_obj) = 0; + virtual void store_ego_object(std::shared_ptr ego_obj) = 0; /** * Store a detected object in a list of Cloe data objects. * * \param obj Object to be stored. */ - virtual void store_object(std::shared_ptr obj) = 0; + virtual void store_object(std::shared_ptr obj) = 0; /** * Store a detected lane boundary in a map of Cloe data objects. * * \param lb Lane boundary to be stored. */ - virtual void store_lane_boundary(const cloe::LaneBoundary& lb) = 0; + virtual void store_lane_boundary(const LaneBoundary& lb) = 0; /** * Store the sensor pose etc. in the corresponding Cloe sensor component. @@ -301,7 +298,7 @@ class OsiMsgHandler { /** * Get the current simulation time (t-t0). */ - cloe::Duration osi_timestamp_to_simtime(const osi3::Timestamp& timestamp) const; + [[nodiscard]] Duration osi_timestamp_to_simtime(const osi3::Timestamp& timestamp) const; /** * Get sensor pose in OSI vehicle reference frame, e.g. from simulator configuration. @@ -311,7 +308,7 @@ class OsiMsgHandler { virtual void set_mock_conf(std::shared_ptr mock) = 0; - SensorMockLevel get_mock_level(SensorMockTarget trg_type) const { + [[nodiscard]] SensorMockLevel get_mock_level(SensorMockTarget trg_type) const { return mock_->level.at(trg_type); } @@ -320,8 +317,8 @@ class OsiMsgHandler { */ virtual void clear_cache() { osi_comm_->clear_cache(); } - friend void to_json(cloe::Json& j, const OsiMsgHandler& c) { - j = cloe::Json{ + friend void to_json(fable::Json& j, const OsiMsgHandler& c) { + j = fable::Json{ {"osi_connection", *c.osi_comm_}, }; } @@ -344,9 +341,9 @@ class OsiMsgHandler { Eigen::Isometry3d osi_sensor_pose_; /// Initial simulation time. - cloe::Duration init_time_ = cloe::Duration(-1); + Duration init_time_ = Duration(-1); /// Use alternative source for required data or overwrite incoming data, if requested. std::shared_ptr mock_{nullptr}; }; -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/include/osi/utility/osi_transceiver.hpp b/osi/include/cloe/utility/osi_transceiver.hpp similarity index 82% rename from optional/osi/include/osi/utility/osi_transceiver.hpp rename to osi/include/cloe/utility/osi_transceiver.hpp index c4aeee463..ea62bd352 100644 --- a/optional/osi/include/osi/utility/osi_transceiver.hpp +++ b/osi/include/cloe/utility/osi_transceiver.hpp @@ -22,12 +22,13 @@ #pragma once -#include // for Json, Error - -#include // for SensorData #include // for GroundTruth +#include // for SensorData + +#include // for Error +#include // for Json -namespace cloeosi { +namespace cloe::utility { /** * OsiError may be thrown when an error is detected in the OSI protocol. @@ -36,7 +37,7 @@ namespace cloeosi { * * \see cloe::utility::TcpReadError */ -class OsiError : public cloe::Error { +class OsiError : public Error { public: using Error::Error; virtual ~OsiError() noexcept = default; @@ -56,7 +57,7 @@ class OsiTransceiver { * That is, if true, then a call to receive() will return a vector * that is not empty. */ - virtual bool has_sensor_data() const = 0; + [[nodiscard]] virtual bool has_sensor_data() const = 0; /** * Return true when the transceiver has a SensorView message that @@ -65,7 +66,7 @@ class OsiTransceiver { * That is, if true, then a call to receive() will return a vector * that is not empty. */ - virtual bool has_sensor_view() const = 0; + [[nodiscard]] virtual bool has_sensor_view() const = 0; /** * Return true when the transceiver has a GroundTruth message that @@ -74,7 +75,7 @@ class OsiTransceiver { * That is, if true, then a call to receive() will return a vector * that is not empty. */ - virtual bool has_ground_truth() const = 0; + [[nodiscard]] virtual bool has_ground_truth() const = 0; /** * Clear simulator and/or reveiver cache, if applicable. @@ -96,9 +97,9 @@ class OsiTransceiver { */ virtual void receive_osi_msgs(std::vector>& msgs) = 0; - virtual void to_json(cloe::Json& j) const = 0; + virtual void to_json(fable::Json& j) const = 0; - friend void to_json(cloe::Json& j, const OsiTransceiver& t) { t.to_json(j); } + friend void to_json(fable::Json& j, const OsiTransceiver& t) { t.to_json(j); } }; -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/include/osi/utility/osi_transceiver_tcp.hpp b/osi/include/cloe/utility/osi_transceiver_tcp.hpp similarity index 81% rename from optional/osi/include/osi/utility/osi_transceiver_tcp.hpp rename to osi/include/cloe/utility/osi_transceiver_tcp.hpp index 1d5a6c146..235acf8f5 100644 --- a/optional/osi/include/osi/utility/osi_transceiver_tcp.hpp +++ b/osi/include/cloe/utility/osi_transceiver_tcp.hpp @@ -27,21 +27,21 @@ #include // for streamsize -#include // for Json, Logger -#include // for TcpTransceiver - -#include // for SensorData #include // for GroundTruth +#include // for SensorData -#include "osi/utility/osi_transceiver.hpp" // for OsiTransceiver -#include "osi/utility/osi_utils.hpp" // for osi_logger +#include // for Logger +#include // for OsiTransceiver +#include // for osi_logger +#include // for TcpTransceiver +#include // for Json -namespace cloeosi { +namespace cloe::utility { /** * OsiTransceiverTcp implements an OsiTransceiver via TCP. */ -class OsiTransceiverTcp : public OsiTransceiver, public cloe::utility::TcpTransceiver { +class OsiTransceiverTcp : public OsiTransceiver, public TcpTransceiver { public: using TcpTransceiver::TcpTransceiver; @@ -58,7 +58,7 @@ class OsiTransceiverTcp : public OsiTransceiver, public cloe::utility::TcpTransc } void receive_osi_msgs(std::vector>& msgs) override { - if (msgs.size() > 0) { + if (!msgs.empty()) { osi_logger()->warn( "OsiTransceiverTcp: Non-zero length of message vector before retrieval: {}", msgs.size()); } @@ -76,8 +76,8 @@ class OsiTransceiverTcp : public OsiTransceiver, public cloe::utility::TcpTransc throw OsiError("OsiTransceiverTcp: Retrieval of osi3::GroundTruth not yet implemented."); } - void to_json(cloe::Json& j) const override { - j = cloe::Json{ + void to_json(fable::Json& j) const override { + j = fable::Json{ {"connection_endpoint", this->tcp_endpoint()}, {"connection_ok", this->tcp_is_ok()}, {"num_errors", this->num_errors_}, @@ -86,7 +86,7 @@ class OsiTransceiverTcp : public OsiTransceiver, public cloe::utility::TcpTransc }; } - friend void to_json(cloe::Json& j, const OsiTransceiverTcp& t) { t.to_json(j); } + friend void to_json(fable::Json& j, const OsiTransceiverTcp& t) { t.to_json(j); } protected: /** @@ -101,13 +101,13 @@ class OsiTransceiverTcp : public OsiTransceiver, public cloe::utility::TcpTransc uint64_t num_received_{0}; }; -class OsiTransceiverTcpFactory : public cloe::utility::TcpTransceiverFactory { +class OsiTransceiverTcpFactory : public TcpTransceiverFactory { public: using TcpTransceiverFactory::TcpTransceiverFactory; protected: - cloe::Logger factory_logger() const override { return osi_logger(); } + Logger factory_logger() const override { return osi_logger(); } const char* instance_name() const override { return "OsiTransceiverTcp"; } }; -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/include/osi/utility/osi_utils.hpp b/osi/include/cloe/utility/osi_utils.hpp similarity index 76% rename from optional/osi/include/osi/utility/osi_utils.hpp rename to osi/include/cloe/utility/osi_utils.hpp index 4e94af8f3..a9e785115 100644 --- a/optional/osi/include/osi/utility/osi_utils.hpp +++ b/osi/include/cloe/utility/osi_utils.hpp @@ -38,12 +38,12 @@ #define osi_require(name, test_expr) ((void)0) #else #define osi_require(name, test_expr) \ - ((test_expr) ? (void)0 : throw cloe::ModelError("OSI message: {} required!", name)) + ((test_expr) ? (void)0 : throw ::cloe::ModelError("OSI message: {} required!", name)) #endif -namespace cloeosi { +namespace cloe::utility { -inline cloe::Logger osi_logger() { return cloe::logger::get("vtd/osi"); } +inline Logger osi_logger() { return logger::get("vtd/osi"); } /** * Write OSI message to a .json file. @@ -51,12 +51,12 @@ inline cloe::Logger osi_logger() { return cloe::logger::get("vtd/osi"); } template void osi_to_file(const OSI_T& msg, const std::string& fname); -void osi_identifier_to_int(const osi3::Identifier& osi_id, int& id); +[[nodiscard]] int osi_identifier(const osi3::Identifier& osi_id); /** * Convert osi3::Vector3d (x, y, z) into Eigen::Vector3d. */ -Eigen::Vector3d osi_vector3d_xyz_to_vector3d(const osi3::Vector3d osi_coord); +[[nodiscard]] Eigen::Vector3d osi_vector3d_xyz_to_vector3d(const osi3::Vector3d& osi_coord); /** * Convert Eigen::Vector3d into osi3::Vector3d (x, y, z). @@ -66,24 +66,24 @@ void vector3d_to_osi_vector3d_xyz(const Eigen::Vector3d& vec, osi3::Vector3d* os /** * Convert a osi3::Dimension3d (l, w, h) into Eigen::Vector3d. */ -Eigen::Vector3d osi_dimension3d_lwh_to_vector3d(const osi3::Dimension3d osi_dim); +[[nodiscard]] Eigen::Vector3d osi_dimension3d_lwh_to_vector3d(const osi3::Dimension3d& osi_dim); /** * Convert a osi3::Orientation3d (r, p, y) into Eigen::Vector3d. */ -Eigen::Vector3d osi_orientation3d_rpy_to_vector3d(const osi3::Orientation3d osi_ori); +[[nodiscard]] Eigen::Vector3d osi_orientation3d_rpy_to_vector3d(const osi3::Orientation3d& osi_ori); /** * Convert vehicle attribute bbcenter_to_rear into Eigen::Vector3d. */ -Eigen::Vector3d osi_vehicle_attrib_rear_offset_to_vector3d( +[[nodiscard]] Eigen::Vector3d osi_vehicle_attrib_rear_offset_to_vector3d( const osi3::MovingObject::VehicleAttributes& osi_va); /** * Convert OSI position and orientation to pose. */ template -Eigen::Isometry3d osi_position_orientation_to_pose(const T& osi_T); +[[nodiscard]] Eigen::Isometry3d osi_position_orientation_to_pose(const T& osi_T); /** * Convert object pose to OSI BaseMoving. @@ -98,4 +98,4 @@ void pose_to_osi_position_orientation(const Eigen::Isometry3d&, osi3::BaseMoving */ void osi_transform_base_moving(const osi3::BaseMoving& base_ref, osi3::BaseMoving& base); -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/src/osi/component/osi_sensor_test.cpp b/osi/src/cloe/component/osi_sensor_test.cpp similarity index 74% rename from optional/osi/src/osi/component/osi_sensor_test.cpp rename to osi/src/cloe/component/osi_sensor_test.cpp index fff0552c2..a05c48832 100644 --- a/optional/osi/src/osi/component/osi_sensor_test.cpp +++ b/osi/src/cloe/component/osi_sensor_test.cpp @@ -20,19 +20,25 @@ * \see osi/component/osi_sensor.hpp */ -#include #include -#include -#include +#include + +#include -class TestOsiSensor : public ::cloe_osi::OsiSensor { +class TestOsiSensor : public ::cloe::OsiSensor { public: using OsiSensor::OsiSensor; TestOsiSensor() : OsiSensor("nop_osi_sensor") {} - virtual ~TestOsiSensor() noexcept = default; + TestOsiSensor(const TestOsiSensor&) = default; + TestOsiSensor(TestOsiSensor&&) = delete; + TestOsiSensor& operator=(const TestOsiSensor&) = default; + TestOsiSensor& operator=(TestOsiSensor&&) = delete; + ~TestOsiSensor() noexcept override = default; - const std::shared_ptr& get() const override { return sensor_data_; }; + [[nodiscard]] const std::shared_ptr& get() const override { + return sensor_data_; + }; std::shared_ptr& get() override { return sensor_data_; } void reset() override { @@ -40,13 +46,13 @@ class TestOsiSensor : public ::cloe_osi::OsiSensor { sensor_data_.reset(); } - fable::Json active_state() const override { + [[nodiscard]] fable::Json active_state() const override { return fable::Json{ {"name", this->name()}, }; } - protected: + private: std::shared_ptr sensor_data_{nullptr}; }; diff --git a/optional/osi/src/osi/utility/osi_ground_truth.cpp b/osi/src/cloe/utility/osi_ground_truth.cpp similarity index 80% rename from optional/osi/src/osi/utility/osi_ground_truth.cpp rename to osi/src/cloe/utility/osi_ground_truth.cpp index 42c86a0c4..ec4f1b3b9 100644 --- a/optional/osi/src/osi/utility/osi_ground_truth.cpp +++ b/osi/src/cloe/utility/osi_ground_truth.cpp @@ -20,18 +20,17 @@ * \see osi_ground_truth.cpp */ -#include "osi/utility/osi_ground_truth.hpp" // for OsiGroundTruth +#include "cloe/utility/osi_ground_truth.hpp" // for OsiGroundTruth #include // for MovingObject #include // for ModelError -namespace cloeosi { +namespace cloe::utility { const osi3::MovingObject* OsiGroundTruth::get_moving_object(const uint64_t id) const { - for (auto osi_obj = gt_ptr_->moving_object().begin(); osi_obj != gt_ptr_->moving_object().end(); - ++osi_obj) { - if (osi_obj->id().value() == id) { - return &(*osi_obj); + for (const auto& osi_obj : gt_ptr_->moving_object()) { + if (osi_obj.id().value() == id) { + return &osi_obj; } } throw cloe::ModelError("OSI ground truth object not found"); @@ -40,9 +39,8 @@ const osi3::MovingObject* OsiGroundTruth::get_moving_object(const uint64_t id) c void OsiGroundTruth::set(const osi3::GroundTruth& osi_gt) { this->gt_ptr_ = &osi_gt; for (int i_mo = 0; i_mo < osi_gt.moving_object_size(); ++i_mo) { - osi3::MovingObject osi_mo = osi_gt.moving_object(i_mo); - int obj_id; - osi_identifier_to_int(osi_mo.id(), obj_id); + const osi3::MovingObject& osi_mo = osi_gt.moving_object(i_mo); + int obj_id = osi_identifier(osi_mo.id()); // Store geometric information of different object reference frames. if (osi_mo.has_vehicle_attributes()) { @@ -58,4 +56,4 @@ void OsiGroundTruth::set(const osi3::GroundTruth& osi_gt) { } } -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/src/osi/utility/osi_message_handler.cpp b/osi/src/cloe/utility/osi_message_handler.cpp similarity index 83% rename from optional/osi/src/osi/utility/osi_message_handler.cpp rename to osi/src/cloe/utility/osi_message_handler.cpp index a3d51c37b..384356e05 100644 --- a/optional/osi/src/osi/utility/osi_message_handler.cpp +++ b/osi/src/cloe/utility/osi_message_handler.cpp @@ -20,12 +20,12 @@ * \see osi_message_handler.hpp */ -#include "osi/utility/osi_message_handler.hpp" +#include "cloe/utility/osi_message_handler.hpp" -#include // for atan -#include // for assert -#include // for numeric_limits<> -#include // for map<> +#include // for assert +#include // for atan +#include // for numeric_limits<> +#include // for map<> #include // for Isometry3d, Vector3d @@ -42,10 +42,10 @@ #include // for SensorData, DetectedEntityHeader #include // for SensorView -#include "osi/utility/osi_ground_truth.hpp" // for OsiGroundTruth -#include "osi/utility/osi_utils.hpp" // for osi_require, .. +#include "cloe/utility/osi_ground_truth.hpp" // for OsiGroundTruth +#include "cloe/utility/osi_utils.hpp" // for osi_require, .. -namespace cloeosi { +namespace cloe::utility { Eigen::Isometry3d osi_position_orientation_to_pose_alt(const osi3::BaseMoving& base, const osi3::BaseMoving& base_gt) { @@ -56,111 +56,104 @@ Eigen::Isometry3d osi_position_orientation_to_pose_alt(const osi3::BaseMoving& b osi_require("GroundTruth-BaseMoving::orientation", base_gt.has_orientation()); base_p = &base_gt; } - Eigen::Quaterniond quaternion = cloe::utility::quaternion_from_rpy( + Eigen::Quaterniond quaternion = quaternion_from_rpy( base_p->orientation().roll(), base_p->orientation().pitch(), base_p->orientation().yaw()); osi_require("base::position", base.has_position()); Eigen::Vector3d translation = osi_vector3d_xyz_to_vector3d(base.position()); - return cloe::utility::pose_from_rotation_translation(quaternion, translation); + return pose_from_rotation_translation(quaternion, translation); } /** * Convert from OSI moving object type to Cloe object classification. Note that * vehicles are treated explicitly in osi_mov_veh_class_map. */ -const std::map osi_mov_obj_type_map = { - {osi3::MovingObject_Type_TYPE_UNKNOWN, cloe::Object::Class::Unknown}, - {osi3::MovingObject_Type_TYPE_OTHER, cloe::Object::Class::Unknown}, - {osi3::MovingObject_Type_TYPE_ANIMAL, cloe::Object::Class::Unknown}, - {osi3::MovingObject_Type_TYPE_PEDESTRIAN, cloe::Object::Class::Pedestrian}, +const std::map osi_mov_obj_type_map = { + {osi3::MovingObject_Type_TYPE_UNKNOWN, Object::Class::Unknown}, + {osi3::MovingObject_Type_TYPE_OTHER, Object::Class::Unknown}, + {osi3::MovingObject_Type_TYPE_ANIMAL, Object::Class::Unknown}, + {osi3::MovingObject_Type_TYPE_PEDESTRIAN, Object::Class::Pedestrian}, }; /** * Convert from OSI moving vehicle type to Cloe object classification. Note that * objects other than vehicles are treated explicitly in osi_mov_obj_type_map. */ -const std::map +const std::map osi_mov_veh_class_map = { - {osi3::MovingObject_VehicleClassification_Type_TYPE_UNKNOWN, cloe::Object::Class::Unknown}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_OTHER, cloe::Object::Class::Unknown}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_SMALL_CAR, cloe::Object::Class::Car}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_COMPACT_CAR, cloe::Object::Class::Car}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_MEDIUM_CAR, cloe::Object::Class::Car}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_LUXURY_CAR, cloe::Object::Class::Car}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_DELIVERY_VAN, - cloe::Object::Class::Truck}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_HEAVY_TRUCK, - cloe::Object::Class::Truck}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_SEMITRAILER, - cloe::Object::Class::Truck}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAILER, cloe::Object::Class::Unknown}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_MOTORBIKE, - cloe::Object::Class::Motorbike}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_BICYCLE, cloe::Object::Class::Bike}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_BUS, cloe::Object::Class::Truck}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAM, cloe::Object::Class::Unknown}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAIN, cloe::Object::Class::Unknown}, - {osi3::MovingObject_VehicleClassification_Type_TYPE_WHEELCHAIR, - cloe::Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_UNKNOWN, Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_OTHER, Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_SMALL_CAR, Object::Class::Car}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_COMPACT_CAR, Object::Class::Car}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_MEDIUM_CAR, Object::Class::Car}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_LUXURY_CAR, Object::Class::Car}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_DELIVERY_VAN, Object::Class::Truck}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_HEAVY_TRUCK, Object::Class::Truck}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_SEMITRAILER, Object::Class::Truck}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAILER, Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_MOTORBIKE, Object::Class::Motorbike}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_BICYCLE, Object::Class::Bike}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_BUS, Object::Class::Truck}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAM, Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_TRAIN, Object::Class::Unknown}, + {osi3::MovingObject_VehicleClassification_Type_TYPE_WHEELCHAIR, Object::Class::Unknown}, }; /** * Convert from OSI lane boundary types to Cloe types. */ -const std::map - osi_lane_bdry_type_map = { - // clang-format off - {osi3::LaneBoundary_Classification_Type_TYPE_UNKNOWN, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_OTHER, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_NO_LINE, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_SOLID_LINE, cloe::LaneBoundary::Type::Solid}, - {osi3::LaneBoundary_Classification_Type_TYPE_DASHED_LINE, cloe::LaneBoundary::Type::Dashed}, - {osi3::LaneBoundary_Classification_Type_TYPE_BOTTS_DOTS, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_ROAD_EDGE, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_SNOW_EDGE, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_GRASS_EDGE, cloe::LaneBoundary::Type::Grass}, - {osi3::LaneBoundary_Classification_Type_TYPE_GRAVEL_EDGE, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_SOIL_EDGE, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_GUARD_RAIL, cloe::LaneBoundary::Type::Unknown}, - {osi3::LaneBoundary_Classification_Type_TYPE_CURB, cloe::LaneBoundary::Type::Curb}, - {osi3::LaneBoundary_Classification_Type_TYPE_STRUCTURE, cloe::LaneBoundary::Type::Unknown}, - // clang-format on +const std::map osi_lane_bdry_type_map = + { + {osi3::LaneBoundary_Classification_Type_TYPE_UNKNOWN, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_OTHER, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_NO_LINE, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_SOLID_LINE, LaneBoundary::Type::Solid}, + {osi3::LaneBoundary_Classification_Type_TYPE_DASHED_LINE, LaneBoundary::Type::Dashed}, + {osi3::LaneBoundary_Classification_Type_TYPE_BOTTS_DOTS, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_ROAD_EDGE, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_SNOW_EDGE, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_GRASS_EDGE, LaneBoundary::Type::Grass}, + {osi3::LaneBoundary_Classification_Type_TYPE_GRAVEL_EDGE, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_SOIL_EDGE, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_GUARD_RAIL, LaneBoundary::Type::Unknown}, + {osi3::LaneBoundary_Classification_Type_TYPE_CURB, LaneBoundary::Type::Curb}, + {osi3::LaneBoundary_Classification_Type_TYPE_STRUCTURE, LaneBoundary::Type::Unknown}, }; /** * Convert from OSI lane boundary colors to Cloe colors. */ -const std::map osi_lane_bdry_color_map = { - {osi3::LaneBoundary_Classification_Color_COLOR_UNKNOWN, cloe::LaneBoundary::Color::Unknown}, - {osi3::LaneBoundary_Classification_Color_COLOR_OTHER, cloe::LaneBoundary::Color::Unknown}, - {osi3::LaneBoundary_Classification_Color_COLOR_NONE, cloe::LaneBoundary::Color::Unknown}, - {osi3::LaneBoundary_Classification_Color_COLOR_WHITE, cloe::LaneBoundary::Color::White}, - {osi3::LaneBoundary_Classification_Color_COLOR_YELLOW, cloe::LaneBoundary::Color::Yellow}, - {osi3::LaneBoundary_Classification_Color_COLOR_RED, cloe::LaneBoundary::Color::Red}, - {osi3::LaneBoundary_Classification_Color_COLOR_BLUE, cloe::LaneBoundary::Color::Blue}, - {osi3::LaneBoundary_Classification_Color_COLOR_GREEN, cloe::LaneBoundary::Color::Green}, - {osi3::LaneBoundary_Classification_Color_COLOR_VIOLET, cloe::LaneBoundary::Color::Unknown}, +const std::map osi_lane_bdry_color_map = { + {osi3::LaneBoundary_Classification_Color_COLOR_UNKNOWN, LaneBoundary::Color::Unknown}, + {osi3::LaneBoundary_Classification_Color_COLOR_OTHER, LaneBoundary::Color::Unknown}, + {osi3::LaneBoundary_Classification_Color_COLOR_NONE, LaneBoundary::Color::Unknown}, + {osi3::LaneBoundary_Classification_Color_COLOR_WHITE, LaneBoundary::Color::White}, + {osi3::LaneBoundary_Classification_Color_COLOR_YELLOW, LaneBoundary::Color::Yellow}, + {osi3::LaneBoundary_Classification_Color_COLOR_RED, LaneBoundary::Color::Red}, + {osi3::LaneBoundary_Classification_Color_COLOR_BLUE, LaneBoundary::Color::Blue}, + {osi3::LaneBoundary_Classification_Color_COLOR_GREEN, LaneBoundary::Color::Green}, + {osi3::LaneBoundary_Classification_Color_COLOR_VIOLET, LaneBoundary::Color::Unknown}, }; -cloe::Duration osi_timestamp_to_time(const osi3::Timestamp& timestamp) { - return std::chrono::duration_cast(std::chrono::seconds(timestamp.seconds()) + +Duration osi_timestamp_to_time(const osi3::Timestamp& timestamp) { + return std::chrono::duration_cast(std::chrono::seconds(timestamp.seconds()) + std::chrono::nanoseconds(timestamp.nanos())); } -cloe::Duration OsiMsgHandler::osi_timestamp_to_simtime(const osi3::Timestamp& timestamp) const { +Duration OsiMsgHandler::osi_timestamp_to_simtime(const osi3::Timestamp& timestamp) const { return osi_timestamp_to_time(timestamp) - this->init_time_; } -void from_osi_host_vehicle_data(const osi3::HostVehicleData& osi_hv, cloe::Object& obj) { +void from_osi_host_vehicle_data(const osi3::HostVehicleData& osi_hv, Object& obj) { from_osi_base_moving(osi_hv.location(), obj); } -void from_osi_detected_item_header(const osi3::DetectedItemHeader& osi_hdr, cloe::Object& obj) { +void from_osi_detected_item_header(const osi3::DetectedItemHeader& osi_hdr, Object& obj) { osi_require("ground_truth_id_size == 1", osi_hdr.ground_truth_id_size() == 1); // Multiple ground truth objects melt into one detected item are currently not // supported. - auto osi_obj_gt_id = osi_hdr.ground_truth_id(0); - osi_identifier_to_int(osi_obj_gt_id, obj.id); + const auto& osi_obj_gt_id = osi_hdr.ground_truth_id(0); + obj.id = osi_identifier(osi_obj_gt_id); // Existence probability if (osi_hdr.has_existence_probability()) { obj.exist_prob = osi_hdr.existence_probability(); @@ -169,7 +162,7 @@ void from_osi_detected_item_header(const osi3::DetectedItemHeader& osi_hdr, cloe } } -void from_osi_detected_moving_object(const osi3::DetectedMovingObject& osi_mo, cloe::Object& obj) { +void from_osi_detected_moving_object(const osi3::DetectedMovingObject& osi_mo, Object& obj) { // object id = ground truth id osi_require("DetectedMovingObject::header", osi_mo.has_header()); from_osi_detected_item_header(osi_mo.header(), obj); @@ -180,7 +173,7 @@ void from_osi_detected_moving_object(const osi3::DetectedMovingObject& osi_mo, c from_osi_mov_obj_type_classification(osi_mo.candidate(0), obj.classification); // TODO(tobias): Need to additionally handle classification probability. } else { - obj.classification = cloe::Object::Class::Unknown; + obj.classification = Object::Class::Unknown; } // DetectedMovingObject::base: "The bounding box does NOT include mirrors for @@ -191,7 +184,7 @@ void from_osi_detected_moving_object(const osi3::DetectedMovingObject& osi_mo, c void from_osi_detected_moving_object_alt(const osi3::DetectedMovingObject& osi_mo, const OsiGroundTruth& ground_truth, - cloe::Object& obj) { + Object& obj) { // Object id = ground truth id osi_require("DetectedMovingObject::header", osi_mo.has_header()); from_osi_detected_item_header(osi_mo.header(), obj); @@ -219,8 +212,8 @@ void from_osi_detected_moving_object_alt(const osi3::DetectedMovingObject& osi_m // TODO(tobias): handle sensor-specific data: if (osi_mo.has_radar_specifics()) } -void from_osi_base_moving(const osi3::BaseMoving& osi_bm, cloe::Object& obj) { - obj.type = cloe::Object::Type::Dynamic; +void from_osi_base_moving(const osi3::BaseMoving& osi_bm, Object& obj) { + obj.type = Object::Type::Dynamic; obj.pose = osi_position_orientation_to_pose(osi_bm); @@ -238,8 +231,8 @@ void from_osi_base_moving(const osi3::BaseMoving& osi_bm, cloe::Object& obj) { } void from_osi_base_moving_alt(const osi3::BaseMoving& osi_bm, const osi3::BaseMoving& osi_bm_gt, - cloe::Object& obj) { - obj.type = cloe::Object::Type::Dynamic; + Object& obj) { + obj.type = Object::Type::Dynamic; obj.pose = osi_position_orientation_to_pose_alt(osi_bm, osi_bm_gt); @@ -261,17 +254,17 @@ void from_osi_base_moving_alt(const osi3::BaseMoving& osi_bm, const osi3::BaseMo } template -void from_osi_mov_obj_type_classification(const T& osi_mo, cloe::Object::Class& oc) { +void from_osi_mov_obj_type_classification(const T& osi_mo, Object::Class& oc) { if (!osi_mo.has_type()) { - throw cloe::ModelError("OSI missing moving object type"); + throw ModelError("OSI missing moving object type"); } if (osi_mo.type() == osi3::MovingObject_Type_TYPE_VEHICLE) { if (!osi_mo.has_vehicle_classification()) { - throw cloe::ModelError("OSI missing moving vehicle classification"); + throw ModelError("OSI missing moving vehicle classification"); } if (!osi_mo.vehicle_classification().has_type()) { - throw cloe::ModelError("OSI missing moving vehicle classification type"); + throw ModelError("OSI missing moving vehicle classification type"); } } @@ -279,15 +272,15 @@ void from_osi_mov_obj_type_classification(const T& osi_mo, cloe::Object::Class& } template void from_osi_mov_obj_type_classification( - const osi3::MovingObject& osi_mo, cloe::Object::Class& oc); + const osi3::MovingObject& osi_mo, Object::Class& oc); template void from_osi_mov_obj_type_classification( - const osi3::DetectedMovingObject::CandidateMovingObject& osi_mo, cloe::Object::Class& oc); + const osi3::DetectedMovingObject::CandidateMovingObject& osi_mo, Object::Class& oc); void from_osi_mov_obj_type_classification( const osi3::MovingObject::Type& osi_ot, const osi3::MovingObject::VehicleClassification::Type& osi_vt, - cloe::Object::Class& oc) { + Object::Class& oc) { if (osi_ot == osi3::MovingObject_Type_TYPE_VEHICLE) { oc = osi_mov_veh_class_map.at(osi_vt); } else { @@ -295,8 +288,8 @@ void from_osi_mov_obj_type_classification( } } -void from_osi_base_stationary(const osi3::BaseStationary& osi_bs, cloe::Object& obj) { - obj.type = cloe::Object::Type::Static; +void from_osi_base_stationary(const osi3::BaseStationary& osi_bs, Object& obj) { + obj.type = Object::Type::Static; obj.pose = osi_position_orientation_to_pose(osi_bs); @@ -308,7 +301,7 @@ void from_osi_base_stationary(const osi3::BaseStationary& osi_bs, cloe::Object& obj.angular_velocity = Eigen::Vector3d::Zero(); } -void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, cloe::Object& obj) { +void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, Object& obj) { // obj->pose: Change object position from bbox-center to vehicle reference // point (rear axle/street level): // - Shift (x,y) to rear axis center using given osi bbcenter_to_rear vector. @@ -332,7 +325,7 @@ void transform_ego_coord_from_osi_data(const Eigen::Vector3d& dimensions_gt, clo } void transform_obj_coord_from_osi_data(const Eigen::Isometry3d& sensor_pose, - const Eigen::Vector3d& dimensions_gt, cloe::Object& obj) { + const Eigen::Vector3d& dimensions_gt, Object& obj) { // obj->pose/velocity/acceleration/angular_velocity: // Transform the location and orientation of the detected object from the ego // vehicle frame into the sensor reference frame. @@ -362,8 +355,8 @@ void transform_obj_coord_from_osi_data(const Eigen::Isometry3d& sensor_pose, } template -void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, const bool& restart, - cloe::Duration& osi_time) { +void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart, + Duration& osi_time) { this->clear_cache(); // Cycle until osi message has been received. int n_msg{0}; @@ -376,9 +369,9 @@ void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, const bool& restart, // 1st. timestep: Store the simulation reference (e.g. start) time. this->handle_first_message(osi_msgs[0]->timestamp()); } - osi_time = cloe::Duration::max(); + osi_time = Duration::max(); for (auto m : osi_msgs) { - cloe::Duration msg_time; + Duration msg_time; this->process_received_msg(m.get(), msg_time); osi_time = std::min(osi_time, msg_time); ++n_msg; @@ -389,17 +382,17 @@ void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, const bool& restart, s.step(), s.time().count()); } -template void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, +template void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart, - cloe::Duration& osi_time); + Duration& osi_time); -template void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, +template void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart, - cloe::Duration& osi_time); + Duration& osi_time); -template void OsiMsgHandler::process_osi_msgs(const cloe::Sync& s, +template void OsiMsgHandler::process_osi_msgs(const Sync& s, const bool& restart, - cloe::Duration& osi_time); + Duration& osi_time); void OsiMsgHandler::handle_first_message(const osi3::Timestamp& timestamp) { // TODO(tobias): probably needs to be changed for restarts @@ -409,7 +402,7 @@ void OsiMsgHandler::handle_first_message(const osi3::Timestamp& timestamp) { init_time_ = osi_timestamp_to_time(timestamp); } -void OsiMsgHandler::process_received_msg(osi3::SensorData* osi_sd, cloe::Duration& osi_time) { +void OsiMsgHandler::process_received_msg(osi3::SensorData* osi_sd, Duration& osi_time) { if (osi_sd == nullptr) { return; } @@ -428,12 +421,12 @@ void OsiMsgHandler::process_received_msg(osi3::SensorData* osi_sd, cloe::Duratio osi_time = osi_timestamp_to_simtime(osi_sd->timestamp()); osi_logger()->trace("OsiMsgHandler: message @ {} ns", osi_time.count()); } else { - throw cloe::ModelError("OsiMsgHandler: No timestamp in SensorData. FMU properly loaded?"); + throw ModelError("OsiMsgHandler: No timestamp in SensorData. FMU properly loaded?"); } // Read the time of the ground truth scene that was processed. if (osi_sd->has_last_measurement_time()) { - cloe::Duration meas_time = osi_timestamp_to_simtime(osi_sd->last_measurement_time()); + Duration meas_time = osi_timestamp_to_simtime(osi_sd->last_measurement_time()); osi_logger()->trace("OsiMsgHandler: measurement @ {} ns", meas_time.count()); } else { osi_logger()->info("OsiMsgHandler: last_measurement_time not available in SensorData."); @@ -464,14 +457,14 @@ void OsiMsgHandler::process_received_msg(osi3::SensorData* osi_sd, cloe::Duratio get_static_mounting_position(ground_truth_->get_veh_coord_sys_info(owner_id_), ground_truth_->get_mov_obj_dimensions(owner_id_)); } else { - throw cloe::ModelError("OSI sensor mounting position is not available"); + throw ModelError("OSI sensor mounting position is not available"); } } if (osi_sd->has_host_vehicle_location()) { // Sensor has its own estimate of the vehicle location, which we could use // to overwrite the ego pose that was taken from ground truth. - throw cloe::ModelError("OSI host_vehicle_location handling is not yet available"); + throw ModelError("OSI host_vehicle_location handling is not yet available"); } // Process detected moving objects. @@ -526,7 +519,7 @@ void OsiMsgHandler::process_received_msg(osi3::SensorData* osi_sd, cloe::Duratio ground_truth_->reset(); } -void OsiMsgHandler::process_received_msg(osi3::SensorView* osi_sv, cloe::Duration& osi_time) { +void OsiMsgHandler::process_received_msg(osi3::SensorView* osi_sv, Duration& osi_time) { if (osi_sv == nullptr) { return; } @@ -548,14 +541,14 @@ void OsiMsgHandler::process_received_msg(osi3::SensorView* osi_sv, cloe::Duratio osi_to_file(*osi_sv, "osi_sensor_view.json"); } } else { - throw cloe::ModelError("OsiMsgHandler: No timestamp in SensorView."); + throw ModelError("OsiMsgHandler: No timestamp in SensorView."); } if (osi_sv->has_global_ground_truth()) { // Store GroundTruth message for coordinate transformations w.r.t. ego vehicle. ground_truth_->set(osi_sv->global_ground_truth()); } else { - throw cloe::ModelError("OsiMsgHandler: No GroundTruth in SensorView."); + throw ModelError("OsiMsgHandler: No GroundTruth in SensorView."); } // Sensor mounting position is required for detected object and lane boundary @@ -587,7 +580,7 @@ void OsiMsgHandler::process_received_msg(osi3::SensorView* osi_sv, cloe::Duratio ground_truth_->reset(); } -void OsiMsgHandler::process_received_msg(osi3::GroundTruth* osi_gt, cloe::Duration& osi_time) { +void OsiMsgHandler::process_received_msg(osi3::GroundTruth* osi_gt, Duration& osi_time) { if (osi_gt == nullptr) { return; } @@ -609,7 +602,7 @@ void OsiMsgHandler::process_received_msg(osi3::GroundTruth* osi_gt, cloe::Durati osi_to_file(*osi_gt, "esmini_osi_ground_truth.json"); } } else { - throw cloe::ModelError("OsiMsgHandler: No timestamp in GroundTruth."); + throw ModelError("OsiMsgHandler: No timestamp in GroundTruth."); } // Store GroundTruth message for coordinate transformations w.r.t. ego vehicle. @@ -671,10 +664,10 @@ void OsiMsgHandler::convert_to_cloe_data(const osi3::SensorView& osi_sv) { void OsiMsgHandler::convert_to_cloe_data(const osi3::MovingObject& osi_ego, const osi3::HostVehicleData* osi_hv) { - auto obj = std::make_shared(); + auto obj = std::make_shared(); obj->exist_prob = 1.0; // Object id - osi_identifier_to_int(osi_ego.id(), obj->id); + obj->id = osi_identifier(osi_ego.id()); assert(obj->id == static_cast(owner_id_)); // Ego pose @@ -722,7 +715,7 @@ void OsiMsgHandler::convert_to_cloe_data(const osi3::MovingObject& osi_ego, void OsiMsgHandler::convert_to_cloe_data(const bool has_eh, const osi3::DetectedEntityHeader& osi_eh, const osi3::DetectedMovingObject& osi_mo) { - auto obj = std::make_shared(); + auto obj = std::make_shared(); // Get object information. The sensor (model) may not provide all required data. if (has_eh) { @@ -740,7 +733,7 @@ void OsiMsgHandler::convert_to_cloe_data(const bool has_eh, break; } case SensorMockLevel::OverwriteAll: { - throw cloe::ModelError( + throw ModelError( "OSI SensorMockLevel::OverwriteAll not available for DetectedMovingObject"); break; } @@ -778,10 +771,9 @@ void OsiMsgHandler::detected_moving_objects_from_ground_truth() { // Set moving object data. for (const auto& osi_obj : osi_gt.moving_object()) { osi_require("GroundTruth-MovingObject::id", osi_obj.has_id()); - int id; - osi_identifier_to_int(osi_obj.id(), id); + int id = osi_identifier(osi_obj.id()); if (id != static_cast(owner_id_)) { - auto obj = std::make_shared(); + auto obj = std::make_shared(); // Set existence probability. obj->exist_prob = 1.0; // Set id. @@ -790,7 +782,7 @@ void OsiMsgHandler::detected_moving_objects_from_ground_truth() { from_osi_mov_obj_type_classification(osi_obj, obj->classification); // Set type, pose, dimensions, rel. velocity, rel. acceleration, rel. angular_velocity. osi3::BaseMoving base_rel = osi_obj.base(); - auto osi_ego = ground_truth_->get_moving_object(owner_id_); + const auto* osi_ego = ground_truth_->get_moving_object(owner_id_); // Rel. velocity. double delta = base_rel.velocity().x() - osi_ego->base().velocity().x(); base_rel.mutable_velocity()->set_x(delta); @@ -838,7 +830,7 @@ void OsiMsgHandler::detected_moving_objects_from_ground_truth() { // Transform the location and orientation of the ground truth object from // the inertial into the ego vehicle frame. Eigen::Vector3d vec = obj->pose.translation(); - cloe::utility::transform_point_to_child_frame(osi_ego_pose_, &vec); + transform_point_to_child_frame(osi_ego_pose_, &vec); obj->pose.translation() = vec; obj->pose.rotate(osi_ego_pose_.rotation().inverse()); @@ -860,15 +852,14 @@ void OsiMsgHandler::detected_static_objects_from_ground_truth() { // Set static object data. for (const auto& osi_obj : osi_gt.stationary_object()) { osi_require("GroundTruth-StationaryObject::id", osi_obj.has_id()); - auto obj = std::make_shared(); + auto obj = std::make_shared(); // Set existence probability. obj->exist_prob = 1.0; // Set id. - int id; - osi_identifier_to_int(osi_obj.id(), id); + int id = osi_identifier(osi_obj.id()); obj->id = std::numeric_limits::max() - id; // Set classification. - obj->classification = cloe::Object::Class::Unknown; // FIXME(tobias): use OSI data + obj->classification = Object::Class::Unknown; // FIXME(tobias): use OSI data // Set type, pose and dimensions (velocity, acceleration, angular_velocity = 0). from_osi_base_stationary(osi_obj.base(), *obj); // Set cog_offset. @@ -881,12 +872,12 @@ void OsiMsgHandler::detected_static_objects_from_ground_truth() { // - from the inertial frame into the ego vehicle frame, // - from the ego vehicle frame into the sensor frame. Eigen::Vector3d vec = obj->pose.translation(); - cloe::utility::transform_point_to_child_frame(osi_ego_pose_, &vec); + transform_point_to_child_frame(osi_ego_pose_, &vec); obj->pose.translation() = vec; obj->pose.rotate(osi_ego_pose_.rotation().inverse()); vec = obj->pose.translation(); - cloe::utility::transform_point_to_child_frame(osi_sensor_pose_, &vec); + transform_point_to_child_frame(osi_sensor_pose_, &vec); obj->pose.translation() = vec; obj->pose.rotate(osi_sensor_pose_.rotation().inverse()); @@ -896,15 +887,15 @@ void OsiMsgHandler::detected_static_objects_from_ground_truth() { } void OsiMsgHandler::from_osi_boundary_points(const osi3::LaneBoundary& osi_lb, - cloe::LaneBoundary& lb, + LaneBoundary& lb, bool reverse_pt_order = false) { assert(osi_lb.boundary_line_size() > 0); for (int i = 0; i < osi_lb.boundary_line_size(); ++i) { const auto& osi_pt = osi_lb.boundary_line(i); Eigen::Vector3d position = osi_vector3d_xyz_to_vector3d(osi_pt.position()); // Transform points from the inertial into the sensor reference frame. - cloe::utility::transform_point_to_child_frame(osi_ego_pose_, &position); - cloe::utility::transform_point_to_child_frame(osi_sensor_pose_, &position); + transform_point_to_child_frame(osi_ego_pose_, &position); + transform_point_to_child_frame(osi_sensor_pose_, &position); lb.points.push_back(position); } // Provide points in ascending order. @@ -932,37 +923,36 @@ void OsiMsgHandler::detected_lane_boundaries_from_ground_truth() { if (osi_lane.classification().centerline_is_driving_direction()) { continue; } - int lane_id; - osi_identifier_to_int(osi_lane.id(), lane_id); - int lb_id; + int lane_id = osi_identifier(osi_lane.id()); for (const auto& osi_lb_id : osi_lane.classification().right_lane_boundary_id()) { - osi_identifier_to_int(osi_lb_id, lb_id); + int lb_id = osi_identifier(osi_lb_id); lbs_flip_pt_order[lb_id] = lane_id; } for (const auto& osi_lb_id : osi_lane.classification().left_lane_boundary_id()) { - osi_identifier_to_int(osi_lb_id, lb_id); + int lb_id = osi_identifier(osi_lb_id); lbs_flip_pt_order[lb_id] = lane_id; } for (const auto& osi_lb_id : osi_lane.classification().free_lane_boundary_id()) { - osi_identifier_to_int(osi_lb_id, lb_id); + int lb_id = osi_identifier(osi_lb_id); lbs_flip_pt_order[lb_id] = lane_id; } } + // If some of the OSI data does not have an id, avoid id clashes. int lb_id = 0; for (const auto& osi_lb : osi_gt.lane_boundary()) { if (osi_lb.has_classification() && osi_lb.has_id()) { - int id; - osi_identifier_to_int(osi_lb.id(), id); + int id = osi_identifier(osi_lb.id()); lb_id = std::max(lb_id, id + 1); } } + // Set lane boundary data. for (const auto& osi_lb : osi_gt.lane_boundary()) { if (osi_lb.has_classification()) { - cloe::LaneBoundary lb; + LaneBoundary lb; if (osi_lb.has_id()) { - osi_identifier_to_int(osi_lb.id(), lb.id); + lb.id = osi_identifier(osi_lb.id()); } else { lb.id = lb_id; } @@ -983,4 +973,4 @@ void OsiMsgHandler::detected_lane_boundaries_from_ground_truth() { } } -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/src/osi/utility/osi_test.cpp b/osi/src/cloe/utility/osi_test.cpp similarity index 92% rename from optional/osi/src/osi/utility/osi_test.cpp rename to osi/src/cloe/utility/osi_test.cpp index 89eaf4e34..f6edd6fff 100644 --- a/optional/osi/src/osi/utility/osi_test.cpp +++ b/osi/src/cloe/utility/osi_test.cpp @@ -34,8 +34,8 @@ #include // for Orientation3D, BaseMoving, .. #include // for MovingObject -#include "osi/utility/osi_message_handler.hpp" // for transform_ego_coord_from_osi_data, ... -#include "osi/utility/osi_utils.hpp" // for pose_to_osi_position_orientation, ... +#include "cloe/utility/osi_message_handler.hpp" // for transform_ego_coord_from_osi_data, ... +#include "cloe/utility/osi_utils.hpp" // for pose_to_osi_position_orientation, ... // Sensor mounting position in the vehicle reference frame constexpr double sens_pos_xyz[] = {3.0, 1.0, 0.0}; @@ -71,10 +71,10 @@ TEST(osi, eigen_pose) { init_osi_vec_3d(base.mutable_position(), sens_pos_xyz); constexpr double ori[3] = {0.1 * M_PI, 0.2 * M_PI, 0.3 * M_PI}; init_osi_ori_3d(base.mutable_orientation(), ori); - Eigen::Isometry3d pose = cloeosi::osi_position_orientation_to_pose(base); + Eigen::Isometry3d pose = cloe::utility::osi_position_orientation_to_pose(base); // Inverse conversion. osi3::BaseMoving base_out; - cloeosi::pose_to_osi_position_orientation(pose, base_out); + cloe::utility::pose_to_osi_position_orientation(pose, base_out); assert_eq_osi_vec_3d(base.position(), base_out.position()); assert_eq_osi_ori_3d(base.orientation(), base_out.orientation()); @@ -120,7 +120,7 @@ TEST(osi, transf_base_mov) { // Set the target object OSI data. osi3::BaseMoving obj_base = init_osi_base(obj_data); // Transform the object base into the ego reference frame. - cloeosi::osi_transform_base_moving(ego_base, obj_base); + cloe::utility::osi_transform_base_moving(ego_base, obj_base); ASSERT_DOUBLE_EQ(obj_base.position().x(), 10.0); ASSERT_DOUBLE_EQ(obj_base.position().y(), 10.0); @@ -158,7 +158,7 @@ TEST(osi, transform_ego_coord) { // OSI bbcenter_to_rear in local object reference frame. ego.cog_offset = obj_osi_cog; - cloeosi::transform_ego_coord_from_osi_data(obj_dims, ego); + cloe::utility::transform_ego_coord_from_osi_data(obj_dims, ego); // Result: Ego rear axle center on street level, in world frame. ASSERT_DOUBLE_EQ(ego.pose.translation()(0), 10.0); @@ -192,7 +192,7 @@ TEST(osi, transform_obj_coord) { Eigen::Vector3d transl{sens_pos_xyz[0], sens_pos_xyz[1], sens_pos_xyz[2]}; Eigen::Isometry3d sensor_pose = cloe::utility::pose_from_rotation_translation(quat, transl); - cloeosi::transform_obj_coord_from_osi_data(sensor_pose, obj_dims, obj); + cloe::utility::transform_obj_coord_from_osi_data(sensor_pose, obj_dims, obj); // Result: Object rear axle center on street level, in sensor frame. ASSERT_DOUBLE_EQ(obj.pose.translation()(0), 7.8); @@ -222,7 +222,7 @@ TEST(osi, vehicle_classification) { cloe::Object obj; - cloeosi::from_osi_mov_obj_type_classification(osi_obj, obj.classification); + cloe::utility::from_osi_mov_obj_type_classification(osi_obj, obj.classification); ASSERT_EQ(obj.classification, cloe::Object::Class::Car); } diff --git a/optional/osi/src/osi/utility/osi_transceiver_tcp.cpp b/osi/src/cloe/utility/osi_transceiver_tcp.cpp similarity index 87% rename from optional/osi/src/osi/utility/osi_transceiver_tcp.cpp rename to osi/src/cloe/utility/osi_transceiver_tcp.cpp index c50fc0aa7..651fd7938 100644 --- a/optional/osi/src/osi/utility/osi_transceiver_tcp.cpp +++ b/osi/src/cloe/utility/osi_transceiver_tcp.cpp @@ -19,7 +19,7 @@ * \file osi_transceiver_tcp.cpp */ -#include "osi/utility/osi_transceiver_tcp.hpp" +#include "cloe/utility/osi_transceiver_tcp.hpp" #include // for malloc, free #include // for shared_ptr<> @@ -32,7 +32,7 @@ #include // for SensorData -namespace cloeosi { +namespace cloe::utility { // This method reads a complete SensorData struct from the stream. // @@ -45,8 +45,8 @@ std::shared_ptr OsiTransceiverTcp::receive_sensor_data_wait() if (!tcp_stream_) { free(hdr_buf); this->num_errors_++; - throw cloe::utility::TcpReadError("OsiTransceiverTcp: error during header read: {}", - tcp_stream_.error().message()); + throw TcpReadError("OsiTransceiverTcp: error during header read: {}", + tcp_stream_.error().message()); } // Parse as protobuf for consistency with send(). @@ -60,7 +60,7 @@ std::shared_ptr OsiTransceiverTcp::receive_sensor_data_wait() // 2.a) Allocate enough memory for the message. auto data_buf = reinterpret_cast(malloc(data_size)); if (data_buf == nullptr) { - throw cloe::Error("OsiTransceiverTcp: malloc failed"); + throw Error("OsiTransceiverTcp: malloc failed"); } // 2.b) Read the message. @@ -68,8 +68,7 @@ std::shared_ptr OsiTransceiverTcp::receive_sensor_data_wait() if (!tcp_stream_) { free(data_buf); this->num_errors_++; - throw cloe::utility::TcpReadError("OsiTransceiverTcp: error during read: {}", - tcp_stream_.error().message()); + throw TcpReadError("OsiTransceiverTcp: error during read: {}", tcp_stream_.error().message()); } // 3. Parse the data message as protobuf input stream. @@ -102,4 +101,4 @@ std::shared_ptr OsiTransceiverTcp::receive_sensor_data_wait() return sensor_data_rcv; } -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/osi/src/osi/utility/osi_utils.cpp b/osi/src/cloe/utility/osi_utils.cpp similarity index 91% rename from optional/osi/src/osi/utility/osi_utils.cpp rename to osi/src/cloe/utility/osi_utils.cpp index 50b326f0d..fd674e673 100644 --- a/optional/osi/src/osi/utility/osi_utils.cpp +++ b/osi/src/cloe/utility/osi_utils.cpp @@ -19,7 +19,7 @@ * \file osi_utils.cpp */ -#include "osi/utility/osi_utils.hpp" +#include "cloe/utility/osi_utils.hpp" #include // for ofstream #include @@ -33,7 +33,8 @@ #include // for Timestamp, Identifier, BaseMoving, .. #include // for SensorData, DetectedEntityHeader -namespace cloeosi { +namespace cloe::utility { +using Eigen::Vector3d; template void osi_to_json(const OSI_T& msg, std::string* json_string) { @@ -55,12 +56,12 @@ template void osi_to_file(const osi3::SensorData& msg, const std::string& fname) template void osi_to_file(const osi3::SensorView& msg, const std::string& fname); template void osi_to_file(const osi3::GroundTruth& msg, const std::string& fname); -void osi_identifier_to_int(const osi3::Identifier& osi_id, int& id) { - id = static_cast(osi_id.value()); +int osi_identifier(const osi3::Identifier& osi_id) { + return static_cast(osi_id.value()); } -Eigen::Vector3d osi_vector3d_xyz_to_vector3d(const osi3::Vector3d osi_coord) { - return Eigen::Vector3d(osi_coord.x(), osi_coord.y(), osi_coord.z()); +Eigen::Vector3d osi_vector3d_xyz_to_vector3d(const osi3::Vector3d& osi_coord) { + return {osi_coord.x(), osi_coord.y(), osi_coord.z()}; } void vector3d_to_osi_vector3d_xyz(const Eigen::Vector3d& vec, osi3::Vector3d* osi_vec) { @@ -69,12 +70,12 @@ void vector3d_to_osi_vector3d_xyz(const Eigen::Vector3d& vec, osi3::Vector3d* os osi_vec->set_z(vec(2)); } -Eigen::Vector3d osi_dimension3d_lwh_to_vector3d(const osi3::Dimension3d osi_dim) { - return Eigen::Vector3d(osi_dim.length(), osi_dim.width(), osi_dim.height()); +Eigen::Vector3d osi_dimension3d_lwh_to_vector3d(const osi3::Dimension3d& osi_dim) { + return {osi_dim.length(), osi_dim.width(), osi_dim.height()}; } -Eigen::Vector3d osi_orientation3d_rpy_to_vector3d(const osi3::Orientation3d osi_ori) { - return Eigen::Vector3d(osi_ori.roll(), osi_ori.pitch(), osi_ori.yaw()); +Eigen::Vector3d osi_orientation3d_rpy_to_vector3d(const osi3::Orientation3d& osi_ori) { + return {osi_ori.roll(), osi_ori.pitch(), osi_ori.yaw()}; } void vector3d_to_osi_orientation_rpy(const Eigen::Vector3d& vec, osi3::Orientation3d* osi_ori) { @@ -108,12 +109,12 @@ template Eigen::Isometry3d osi_position_orientation_to_poseset_x(pos_in(0)); pos_out->set_y(pos_in(1)); pos_out->set_z(pos_in(2)); - auto ori_out = base.mutable_orientation(); + auto* ori_out = base.mutable_orientation(); Eigen::Vector3d ypr_out = pose_in.rotation().matrix().eulerAngles(2, 1, 0); ori_out->set_roll(ypr_out(2)); ori_out->set_pitch(ypr_out(1)); @@ -153,4 +154,4 @@ void osi_transform_base_moving(const osi3::BaseMoving& base_ref, osi3::BaseMovin vector3d_to_osi_orientation_rpy(vec, base.mutable_orientation_rate()); } -} // namespace cloeosi +} // namespace cloe::utility diff --git a/optional/esmini/CMakeLists.txt b/plugins/esmini/CMakeLists.txt similarity index 78% rename from optional/esmini/CMakeLists.txt rename to plugins/esmini/CMakeLists.txt index 2ffb7eb2c..53edeb3df 100644 --- a/optional/esmini/CMakeLists.txt +++ b/plugins/esmini/CMakeLists.txt @@ -2,12 +2,9 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) project(cloe_plugin_esmini LANGUAGES CXX) -set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") -if(CLOE_FIND_PACKAGES) - find_package(cloe-runtime REQUIRED) - find_package(cloe-models REQUIRED) - find_package(cloe-osi REQUIRED) -endif() +find_package(cloe-runtime REQUIRED) +find_package(cloe-models REQUIRED) +find_package(cloe-osi REQUIRED) find_package(esmini REQUIRED) include(CloePluginSetup) @@ -20,7 +17,7 @@ cloe_add_plugin( cloe::runtime cloe::models cloe::osi - esmini::esmini + esmini::esminiLib COMPILE_DEFINITIONS PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\" ) diff --git a/plugins/esmini/Makefile b/plugins/esmini/Makefile new file mode 100644 index 000000000..759272674 --- /dev/null +++ b/plugins/esmini/Makefile @@ -0,0 +1 @@ +include ../../Makefile.package diff --git a/optional/esmini/conanfile.py b/plugins/esmini/conanfile.py similarity index 87% rename from optional/esmini/conanfile.py rename to plugins/esmini/conanfile.py index 2678c7464..3fe18d492 100644 --- a/optional/esmini/conanfile.py +++ b/plugins/esmini/conanfile.py @@ -11,12 +11,6 @@ class CloeSimulatorESMini(ConanFile): description = "Cloe ESMini simulator plugin." license = "Apache-2.0" settings = "os", "compiler", "build_type", "arch" - options = { - "pedantic": [True, False], - } - default_options = { - "pedantic": True, - } generators = "CMakeDeps", "VirtualRunEnv" exports_sources = [ "src/*", @@ -34,11 +28,13 @@ def set_version(self): def requirements(self): self.requires("eigen/3.4.0") - self.requires(f"esmini/[~2.24.0]@cloe/stable") + self.requires(f"esmini/2.37.0@cloe/stable") self.requires(f"cloe-runtime/{self.version}@cloe/develop") self.requires(f"cloe-models/{self.version}@cloe/develop") self.requires(f"cloe-osi/{self.version}@cloe/develop") + self.requires("zlib/1.2.13", override=True) # conflict between boost & protobuf + def build_requirements(self): self.test_requires("gtest/1.13.0") @@ -49,7 +45,6 @@ def generate(self): tc = cmake.CMakeToolchain(self) tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version - tc.cache_variables["TargetLintingExtended"] = self.options.pedantic tc.generate() def build(self): @@ -66,9 +61,6 @@ def package(self): if self.should_install: cm.install() - def package_id(self): - del self.info.options.pedantic - def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) diff --git a/optional/esmini/src/esmini.cpp b/plugins/esmini/src/esmini.cpp similarity index 87% rename from optional/esmini/src/esmini.cpp rename to plugins/esmini/src/esmini.cpp index 31c45b518..920769bbc 100644 --- a/optional/esmini/src/esmini.cpp +++ b/plugins/esmini/src/esmini.cpp @@ -21,10 +21,10 @@ * This file defines the ESMini simulator plugin. */ -#include // for function<> -#include // for unique_ptr<> -#include // for string -#include // for vector<> +#include // for shared_ptr<> +#include // for string +#include +#include // for vector<> #include @@ -46,17 +46,21 @@ #include "esmini_logger.hpp" // for esmini_logger() #include "esmini_vehicle.hpp" -namespace esmini { +namespace cloe_esmini { /** * Implementation of a cloe::Simulator specifically for ESMini. */ class ESMiniSimulator : public cloe::Simulator { public: - ESMiniSimulator(const std::string& name, const ESMiniConfiguration& c) - : Simulator(name), config_(c) {} + ESMiniSimulator(const ESMiniSimulator&) = default; + ESMiniSimulator(ESMiniSimulator&&) = delete; + ESMiniSimulator& operator=(const ESMiniSimulator&) = default; + ESMiniSimulator& operator=(ESMiniSimulator&&) = delete; + ESMiniSimulator(const std::string& name, ESMiniConfiguration c) + : Simulator(name), config_(std::move(c)) {} - virtual ~ESMiniSimulator() noexcept = default; + ~ESMiniSimulator() noexcept override = default; void connect() final { SE_SetLogFilePath("/tmp/esmini.log"); @@ -93,8 +97,8 @@ class ESMiniSimulator : public cloe::Simulator { // Check the scenario for the requested ego vehicles and create the cloe vehicles. for (int i = 0; i < SE_GetNumberOfObjects(); ++i) { auto id = SE_GetId(i); - auto name = SE_GetObjectName(id); - if (name) { + const auto* name = SE_GetObjectName(id); + if (name != nullptr) { auto it = std::find(ego_v.begin(), ego_v.end(), name); if (it != ego_v.end()) { vehicles_.push_back(std::make_shared(id, name, config_.vehicles.at(name))); @@ -102,7 +106,7 @@ class ESMiniSimulator : public cloe::Simulator { } } } - if (ego_v.size() > 0) { + if (!ego_v.empty()) { for (auto const& ego : ego_v) { esmini_logger()->error("Ego vehicle not found in scenario: {}", ego); } @@ -111,8 +115,6 @@ class ESMiniSimulator : public cloe::Simulator { } void disconnect() final { - assert(!is_operational()); - SE_Close(); Simulator::disconnect(); @@ -158,12 +160,12 @@ class ESMiniSimulator : public cloe::Simulator { // Receive new data from all sensors. cloe::Duration sensor_time{0}; { - for (auto v : vehicles_) { + for (const auto& v : vehicles_) { sensor_time = v->esmini_get_environment_data(sync); } } // Set actuation signals. - for (auto v : vehicles_) { + for (const auto& v : vehicles_) { v->esmini_step_ego_position(sync); } @@ -173,7 +175,7 @@ class ESMiniSimulator : public cloe::Simulator { } // Trigger the next step. - double step_size_sec = std::chrono::duration(sync.step_width()).count(); + auto step_size_sec = std::chrono::duration(sync.step_width()).count(); esmini_logger()->trace("Trigger timestep dt = {}s", step_size_sec); if (SE_StepDT(step_size_sec) != 0) { throw cloe::ModelError("ESMini step failed!"); @@ -209,6 +211,6 @@ DEFINE_SIMULATOR_FACTORY(ESMiniFactory, ESMiniConfiguration, "esmini", "basic Op DEFINE_SIMULATOR_FACTORY_MAKE(ESMiniFactory, ESMiniSimulator) -} // namespace esmini +} // namespace cloe_esmini -EXPORT_CLOE_PLUGIN(esmini::ESMiniFactory) +EXPORT_CLOE_PLUGIN(cloe_esmini::ESMiniFactory) diff --git a/optional/esmini/src/esmini_conf.hpp b/plugins/esmini/src/esmini_conf.hpp similarity index 65% rename from optional/esmini/src/esmini_conf.hpp rename to plugins/esmini/src/esmini_conf.hpp index d411453d8..5ec92478a 100644 --- a/optional/esmini/src/esmini_conf.hpp +++ b/plugins/esmini/src/esmini_conf.hpp @@ -21,21 +21,20 @@ #pragma once -#include // for duration<> #include // for map<> -#include // for shared_ptr<> #include // for string -#include // for Conf, Schema +#include // for Confable +#include // for Schema -namespace esmini { +namespace cloe_esmini { /** * ESMiniVehicleConfig contains the esmini specific vehicle configuration. * * That is, sensor definitions and a mapping to cloe components. */ -struct ESMiniVehicleConfig : public cloe::Confable { +struct ESMiniVehicleConfig : public fable::Confable { /// Externally controlled esmini vehicle. bool is_closed_loop{true}; @@ -45,9 +44,9 @@ struct ESMiniVehicleConfig : public cloe::Confable { public: CONFABLE_SCHEMA(ESMiniVehicleConfig) { // clang-format off - return cloe::Schema{ - {"closed_loop", cloe::Schema(&is_closed_loop, "control the esmini vehicle")}, - {"filter_distance", cloe::Schema(&filter_dist, "filter distance for ground truth data")}, + return fable::Schema{ + {"closed_loop", fable::Schema(&is_closed_loop, "control the esmini vehicle")}, + {"filter_distance", fable::Schema(&filter_dist, "filter distance for ground truth data")}, }; // clang-format on } @@ -57,8 +56,8 @@ struct ESMiniVehicleConfig : public cloe::Confable { * The ESMiniConfiguration class contains all configuration values for ESMini. * It can be merged from an input JSON object, as well as serialized to a JSON object. */ -struct ESMiniConfiguration : public cloe::Confable { - std::string scenario = ""; +struct ESMiniConfiguration : public fable::Confable { + std::string scenario{}; bool is_headless{true}; @@ -71,14 +70,14 @@ struct ESMiniConfiguration : public cloe::Confable { CONFABLE_SCHEMA(ESMiniConfiguration) { // clang-format off - return cloe::Schema{ - {"headless", cloe::Schema(&is_headless, "run esmini without viewer")}, - {"write_images", cloe::Schema(&write_images, "save an image for each step")}, - {"scenario", cloe::Schema(&scenario, "absolute path to open scenario file")}, - {"vehicles", cloe::Schema(&vehicles, "vehicle configuration like sensors and component mapping")}, + return fable::Schema{ + {"headless", fable::Schema(&is_headless, "run esmini without viewer")}, + {"write_images", fable::Schema(&write_images, "save an image for each step")}, + {"scenario", fable::Schema(&scenario, "absolute path to open scenario file")}, + {"vehicles", fable::Schema(&vehicles, "vehicle configuration like sensors and component mapping")}, }; // clang-format on } }; -} // namespace esmini +} // namespace cloe_esmini diff --git a/optional/esmini/src/esmini_ego_control.hpp b/plugins/esmini/src/esmini_ego_control.hpp similarity index 95% rename from optional/esmini/src/esmini_ego_control.hpp rename to plugins/esmini/src/esmini_ego_control.hpp index 97ad45f91..7cd05dc35 100644 --- a/optional/esmini/src/esmini_ego_control.hpp +++ b/plugins/esmini/src/esmini_ego_control.hpp @@ -37,7 +37,7 @@ // Refer to comment on Controller::Type in esminiLib.hpp. #define ESMINI_CONTROLLER_TYPE_EXTERNAL 1 -namespace esmini { +namespace cloe_esmini { /** * ESMiniSimpleEgoModel updates the ego state based on a kinematic bicycle model. @@ -60,7 +60,7 @@ class ESMiniSimpleEgoModel { return ego_state_; } - double get_throttle_from_acceleration(double trg_accel) const { + [[nodiscard]] double get_throttle_from_acceleration(double trg_accel) const { return std::max(-1.0, std::min(1.0, trg_accel / max_acceleration_abs_)); } @@ -142,7 +142,7 @@ class ESMiniDriverModel { SE_GetObjectGhostState(ego_id_, &ghost_state); double ghost_dir_angle = atan2(ghost_state.y - ego_state.y, ghost_state.x - ego_state.x); double delta_ego_dir = remainder(ghost_dir_angle - ego_state.h, 2 * M_PI); - if (abs(delta_ego_dir) > M_PI_2) { + if (std::abs(delta_ego_dir) > M_PI_2) { throw cloe::ModelError( "ESMiniDriverModel: Ego vehicle has passed driver model ghost object. Fix scenario."); } @@ -161,7 +161,7 @@ class ESMiniDriverModel { // Use simple model (refer to the ESMini test-driver.cpp example). // Look ahead along lane center. Scenario actions are ignored. uint16_t lookahead_strategy = 0; - SE_GetRoadInfoAtDistance(ego_id_, 5 + 0.75f * ego_vel, &road_info, lookahead_strategy, true); + SE_GetRoadInfoAtDistance(ego_id_, 5 + 0.75F * ego_vel, &road_info, lookahead_strategy, true); if (road_info.speed_limit <= 0.0) { throw cloe::ModelError("ESMiniDriverModel::Simple: OpenDrive speed limit missing."); } @@ -181,8 +181,6 @@ class ESMiniDriverModel { DriverModelType model_type_{DriverModelType::GhostLookAheadDist}; /// Tuning parameter to reach the target velocity. const double throttle_weight_{0.1}; - /// Handle to the model instance. - void* model_{nullptr}; }; /** @@ -197,7 +195,7 @@ class ESMiniEgoControl : public cloe::LatLongActuator { driver_model_ = std::make_shared(ego_id_, DriverModelType::GhostLookAheadDist); } - virtual ~ESMiniEgoControl() = default; + ~ESMiniEgoControl() override = default; /** * Returns true when the controller actuation state changes from its previous @@ -215,8 +213,8 @@ class ESMiniEgoControl : public cloe::LatLongActuator { * Update the ego vehicle position in the scene. */ void step(const cloe::Sync& s) { - double trg_throttle; - double trg_steering_angle; + double trg_throttle = 0; + double trg_steering_angle = 0; get_target_actuation(trg_throttle, trg_steering_angle); // Step the vehicle model forward in time. vehicle_model_->step(std::chrono::duration(s.step_width()).count(), trg_throttle, @@ -224,7 +222,8 @@ class ESMiniEgoControl : public cloe::LatLongActuator { // Get the updated vehicle state. auto ego_state = vehicle_model_->get_ego_state(); // Update new ego position, heading and velocity in the scenario (z, pitch, roll will be aligned to the road). - SE_ReportObjectPosXYH(0, 0, ego_state.x, ego_state.y, ego_state.h, ego_state.speed); + SE_ReportObjectPosXYH(0, 0.0F, ego_state.x, ego_state.y, ego_state.h); + SE_ReportObjectSpeed(0, ego_state.speed); // Detect driver or controller takeover for lateral and/or longitudinal control. if (this->has_level_change()) { esmini_logger()->info("ESMiniEgoControl: vehicle {} new controller state: {}", id(), diff --git a/optional/esmini/src/esmini_logger.hpp b/plugins/esmini/src/esmini_logger.hpp similarity index 97% rename from optional/esmini/src/esmini_logger.hpp rename to plugins/esmini/src/esmini_logger.hpp index 6ef9d7a9c..d0933ee7c 100644 --- a/optional/esmini/src/esmini_logger.hpp +++ b/plugins/esmini/src/esmini_logger.hpp @@ -25,7 +25,7 @@ #include // for Logger, get -namespace esmini { +namespace cloe_esmini { inline cloe::Logger esmini_logger() { return cloe::logger::get("esmini"); } diff --git a/optional/esmini/src/esmini_osi_sensor.hpp b/plugins/esmini/src/esmini_osi_sensor.hpp similarity index 88% rename from optional/esmini/src/esmini_osi_sensor.hpp rename to plugins/esmini/src/esmini_osi_sensor.hpp index 1fdf6aca8..10da92bbc 100644 --- a/optional/esmini/src/esmini_osi_sensor.hpp +++ b/plugins/esmini/src/esmini_osi_sensor.hpp @@ -29,13 +29,14 @@ #include // for SE_UpdateOSIGroundTruth, .. -#include // for Object -#include // for OsiMsgHandler -#include // for OsiTransceiver +#include // for Object +#include // for OsiMsgHandler +#include // for OsiTransceiver +#include "esmini_logger.hpp" #include "esmini_world_data.hpp" // for ESMiniEnvData -namespace esmini { +namespace cloe_esmini { // TODO(tobias): This should eventually be fixed in ESMini. void fix_esmini_osi_ground_truth(osi3::GroundTruth& gt) { @@ -57,9 +58,9 @@ void fix_esmini_osi_ground_truth(osi3::GroundTruth& gt) { } } -class ESMiniOsiReceiver : public cloeosi::OsiTransceiver { +class ESMiniOsiReceiver : public cloe::utility::OsiTransceiver { public: - virtual ~ESMiniOsiReceiver() = default; + ~ESMiniOsiReceiver() override = default; /** * Update the ESMini osi::GroundTruth object and check return code. @@ -98,12 +99,12 @@ class ESMiniOsiReceiver : public cloeosi::OsiTransceiver { * Fetch sensor model output from ESMini, if applicable. */ void receive_osi_msgs(std::vector>& msgs) override { - if (msgs.size() > 0) { + if (!msgs.empty()) { esmini_logger()->warn( "ESMiniOsiReceiver: Non-zero length of message vector before retrieval: {}", msgs.size()); } if (this->has_sensor_data()) { - osi3::SensorData* sd = (osi3::SensorData*)SE_GetOSISensorDataRaw(); + const auto* sd = reinterpret_cast(SE_GetOSISensorDataRaw()); if (!sd->has_timestamp()) { throw cloe::ModelError("ESMiniOsiSensor: No timestamp in SensorData."); } @@ -115,17 +116,18 @@ class ESMiniOsiReceiver : public cloeosi::OsiTransceiver { * Fetch ground truth from ESMini, if applicable. */ void receive_osi_msgs(std::vector>& msgs) override { - if (msgs.size() > 0) { + if (!msgs.empty()) { esmini_logger()->warn( "ESMiniOsiReceiver: Non-zero length of message vector before retrieval: {}", msgs.size()); } if (this->has_ground_truth()) { - osi3::GroundTruth gt = *(osi3::GroundTruth*)SE_GetOSIGroundTruthRaw(); + // NOTE: Make a copy because we are going to change it. + auto gt = *reinterpret_cast(SE_GetOSIGroundTruthRaw()); if (!gt.has_timestamp()) { throw cloe::ModelError("ESMiniOsiSensor: No timestamp in GroundTruth."); } fix_esmini_osi_ground_truth(gt); - msgs.push_back(std::make_shared(gt)); + msgs.push_back(std::make_shared(std::move(gt))); } } @@ -154,9 +156,9 @@ class ESMiniOsiReceiver : public cloeosi::OsiTransceiver { * Note: Object and lane boundary data is converted to a fictive sensor position located in the vehicle reference point. * */ -class ESMiniOsiSensor : public cloeosi::OsiMsgHandler, public ESMiniEnvData { +class ESMiniOsiSensor : public cloe::utility::OsiMsgHandler, public ESMiniEnvData { public: - virtual ~ESMiniOsiSensor() = default; + ~ESMiniOsiSensor() override = default; ESMiniOsiSensor(uint64_t owner_id, double filter_dist) : OsiMsgHandler(new ESMiniOsiReceiver(), owner_id), ESMiniEnvData("osi_sensor", filter_dist) { @@ -205,7 +207,7 @@ class ESMiniOsiSensor : public cloeosi::OsiMsgHandler, public ESMiniEnvData { /** * Set the mock level for different data types according to user request. */ - void set_mock_conf(std::shared_ptr mock) override { + void set_mock_conf(std::shared_ptr mock) override { this->mock_ = mock; } @@ -223,4 +225,4 @@ class ESMiniOsiSensor : public cloeosi::OsiMsgHandler, public ESMiniEnvData { } }; -} // namespace esmini +} // namespace cloe_esmini diff --git a/optional/esmini/src/esmini_sensor_components.hpp b/plugins/esmini/src/esmini_sensor_components.hpp similarity index 99% rename from optional/esmini/src/esmini_sensor_components.hpp rename to plugins/esmini/src/esmini_sensor_components.hpp index c7f8da423..b4e3c9cf9 100644 --- a/optional/esmini/src/esmini_sensor_components.hpp +++ b/plugins/esmini/src/esmini_sensor_components.hpp @@ -25,7 +25,7 @@ #include "esmini_world_data.hpp" // for ESMiniEnvData -namespace esmini { +namespace cloe_esmini { class ESMiniEgoSensor : public cloe::EgoSensor { public: diff --git a/optional/esmini/src/esmini_test.cpp b/plugins/esmini/src/esmini_test.cpp similarity index 94% rename from optional/esmini/src/esmini_test.cpp rename to plugins/esmini/src/esmini_test.cpp index 7d13b8e24..65be83f81 100644 --- a/optional/esmini/src/esmini_test.cpp +++ b/plugins/esmini/src/esmini_test.cpp @@ -28,8 +28,8 @@ using namespace cloe; // NOLINT(build/namespaces) -TEST(esmini, deserialization) { - esmini::ESMiniConfiguration conf; +TEST(cloe_esmini, deserialization) { + cloe_esmini::ESMiniConfiguration conf; fable::assert_validate(conf, R"({ "headless" : true, diff --git a/optional/esmini/src/esmini_vehicle.hpp b/plugins/esmini/src/esmini_vehicle.hpp similarity index 99% rename from optional/esmini/src/esmini_vehicle.hpp rename to plugins/esmini/src/esmini_vehicle.hpp index 708a212e4..2865db6c0 100644 --- a/optional/esmini/src/esmini_vehicle.hpp +++ b/plugins/esmini/src/esmini_vehicle.hpp @@ -35,7 +35,7 @@ #include "esmini_sensor_components.hpp" // for ESMiniEgoSensor, ESMiniObjectSensor, .. #include "esmini_world_data.hpp" // for ESMiniEnvData -namespace esmini { +namespace cloe_esmini { class ESMiniVehicle : public cloe::Vehicle { public: diff --git a/optional/esmini/src/esmini_world_data.hpp b/plugins/esmini/src/esmini_world_data.hpp similarity index 98% rename from optional/esmini/src/esmini_world_data.hpp rename to plugins/esmini/src/esmini_world_data.hpp index 9d6d7c811..7c90d135c 100644 --- a/optional/esmini/src/esmini_world_data.hpp +++ b/plugins/esmini/src/esmini_world_data.hpp @@ -31,7 +31,7 @@ #include // for Object #include // for Sync -namespace esmini { +namespace cloe_esmini { class ESMiniEnvData { public: @@ -139,8 +139,6 @@ class ESMiniEnvData { /// Lane id-to-boundary-map. cloe::LaneBoundaries lanes_; - - /// Traffic signs id-to-signs-map. }; } // namespace esmini diff --git a/optional/esmini/tests/conanfile_esmini.py b/plugins/esmini/tests/conanfile_esmini.py similarity index 69% rename from optional/esmini/tests/conanfile_esmini.py rename to plugins/esmini/tests/conanfile_esmini.py index 7a92bfb1b..97a84070a 100644 --- a/optional/esmini/tests/conanfile_esmini.py +++ b/plugins/esmini/tests/conanfile_esmini.py @@ -2,7 +2,7 @@ # pylint: skip-file from pathlib import Path -from conans import ConanFile, tools +from conan import ConanFile class CloeTest(ConanFile): @@ -11,7 +11,6 @@ class CloeTest(ConanFile): default_options = { "cloe-engine:server": True, - "cloe-engine:lrdb": False, } @property @@ -20,17 +19,11 @@ def cloe_launch_env(self): "CLOE_LOG_LEVEL": "debug", "CLOE_STRICT_MODE": "1", "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "../../.." + "CLOE_ROOT": Path(self.recipe_folder) / "../../..", } def set_version(self): - for version_path in ["../VERSION", "../../../VERSION"]: - version_file = Path(self.recipe_folder) / version_path - if version_file.exists(): - self.version = self.project_version(version_path) - return - git = tools.Git(self, self.recipe_folder) - self.version = git.run("describe --dirty=-dirty")[1:] + self.version = self.project_version("../../../VERSION") def requirements(self): self.requires(f"cloe-engine/{self.version}@cloe/develop") @@ -40,6 +33,7 @@ def requirements(self): self.requires(f"cloe-plugin-gndtruth-extractor/{self.version}@cloe/develop") self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop") self.requires(f"cloe-plugin-esmini/{self.version}@cloe/develop") + self.requires("esmini-data/2.37.0@cloe/stable") # Overrides: self.requires("zlib/1.2.13", override=True) diff --git a/optional/esmini/tests/config_esmini_aeb.json b/plugins/esmini/tests/config_esmini_aeb.json similarity index 100% rename from optional/esmini/tests/config_esmini_aeb.json rename to plugins/esmini/tests/config_esmini_aeb.json diff --git a/optional/esmini/tests/config_esmini_closed_loop.json b/plugins/esmini/tests/config_esmini_closed_loop.json similarity index 100% rename from optional/esmini/tests/config_esmini_closed_loop.json rename to plugins/esmini/tests/config_esmini_closed_loop.json diff --git a/optional/esmini/tests/config_esmini_cut_in.json b/plugins/esmini/tests/config_esmini_cut_in.json similarity index 100% rename from optional/esmini/tests/config_esmini_cut_in.json rename to plugins/esmini/tests/config_esmini_cut_in.json diff --git a/optional/esmini/tests/config_esmini_open_loop.json b/plugins/esmini/tests/config_esmini_open_loop.json similarity index 100% rename from optional/esmini/tests/config_esmini_open_loop.json rename to plugins/esmini/tests/config_esmini_open_loop.json diff --git a/optional/esmini/tests/controller_basic_aeb.json b/plugins/esmini/tests/controller_basic_aeb.json similarity index 100% rename from optional/esmini/tests/controller_basic_aeb.json rename to plugins/esmini/tests/controller_basic_aeb.json diff --git a/optional/esmini/tests/controller_virtue.json b/plugins/esmini/tests/controller_virtue.json similarity index 100% rename from optional/esmini/tests/controller_virtue.json rename to plugins/esmini/tests/controller_virtue.json diff --git a/optional/esmini/tests/test_esmini.bats b/plugins/esmini/tests/test_esmini.bats similarity index 100% rename from optional/esmini/tests/test_esmini.bats rename to plugins/esmini/tests/test_esmini.bats diff --git a/optional/esmini/tests/test_esmini_closed_loop.json b/plugins/esmini/tests/test_esmini_closed_loop.json similarity index 100% rename from optional/esmini/tests/test_esmini_closed_loop.json rename to plugins/esmini/tests/test_esmini_closed_loop.json diff --git a/optional/esmini/tests/test_esmini_open_loop.json b/plugins/esmini/tests/test_esmini_open_loop.json similarity index 100% rename from optional/esmini/tests/test_esmini_open_loop.json rename to plugins/esmini/tests/test_esmini_open_loop.json diff --git a/plugins/gndtruth_extractor/tests/conanfile_default.py b/plugins/gndtruth_extractor/tests/conanfile_default.py index b567adb56..456b73752 100644 --- a/plugins/gndtruth_extractor/tests/conanfile_default.py +++ b/plugins/gndtruth_extractor/tests/conanfile_default.py @@ -1,3 +1,6 @@ +# mypy: ignore-errors +# pylint: skip-file + from pathlib import Path from conan import ConanFile @@ -27,6 +30,3 @@ def requirements(self): self.requires(f"cloe-plugin-basic/{self.version}@cloe/develop") self.requires(f"cloe-plugin-minimator/{self.version}@cloe/develop") self.requires(f"cloe-plugin-gndtruth-extractor/{self.version}@cloe/develop") - - if self.options["cloe-engine"].server: - self.requires("boost/[<1.70]", override=True) diff --git a/optional/osi/vendor/open-simulation-interface-3.3.1/Makefile b/vendor/esmini-data/Makefile similarity index 87% rename from optional/osi/vendor/open-simulation-interface-3.3.1/Makefile rename to vendor/esmini-data/Makefile index 4b7465566..10c25c6e0 100644 --- a/optional/osi/vendor/open-simulation-interface-3.3.1/Makefile +++ b/vendor/esmini-data/Makefile @@ -3,5 +3,5 @@ override SOURCE_DIR := src override PACKAGE_CHANNEL := cloe/stable override CLEAN_SOURCE_DIR := true -PROJECT_ROOT := ../../../.. +PROJECT_ROOT := ../.. include ${PROJECT_ROOT}/Makefile.package diff --git a/vendor/esmini-data/conandata.yml b/vendor/esmini-data/conandata.yml new file mode 100644 index 000000000..687856024 --- /dev/null +++ b/vendor/esmini-data/conandata.yml @@ -0,0 +1,12 @@ +--- +sources: + 2.37.0: + url: + - /~https://github.com/esmini/esmini/archive/refs/tags/v2.37.0.tar.gz + sha256: "a1f216411caa7d8782dd9c82683f8bac3f00d7da2f6370535726b6446c339e59" +patches: + 2.37.0: + - patch_file: patches/2.37.0-test-driver-path.patch + patch_type: git + patch_description: > + Patch paths to reflect new position of test-driver.xosc. diff --git a/vendor/esmini-data/conanfile.py b/vendor/esmini-data/conanfile.py new file mode 100644 index 000000000..1b27d6f0b --- /dev/null +++ b/vendor/esmini-data/conanfile.py @@ -0,0 +1,46 @@ +import os + +from conan import ConanFile +from conan.tools import files, env + +required_conan_version = ">=1.52.0" + + +class ESMiniData(ConanFile): + name = "esmini-data" + version = "2.37.0" + license = "MPL-2.0" + url = "/~https://github.com/esmini/esmini" + description = "Basic OpenScenario player example data" + topics = ("Environment Simulator", "OpenScenario", "OpenDrive") + + def export_sources(self): + files.export_conandata_patches(self) + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def build(self): + files.apply_conandata_patches(self) + + def package(self): + files.copy( + self, + "*", + src=os.path.join(self.source_folder, "resources"), + dst=os.path.join(self.package_folder), + ) + files.copy( + self, + "*.xosc", + src=os.path.join(self.source_folder, "EnvironmentSimulator", "code-examples", "test-driver"), + dst=os.path.join(self.package_folder, "xosc"), + ) + + def package_info(self): + self.runenv_info.define_path( + "ESMINI_XOSC_PATH", os.path.join(self.package_folder, "xosc") + ) + self.runenv_info.define_path( + "ESMINI_XODR_PATH", os.path.join(self.package_folder, "xodr") + ) diff --git a/vendor/esmini-data/patches/2.37.0-test-driver-path.patch b/vendor/esmini-data/patches/2.37.0-test-driver-path.patch new file mode 100644 index 000000000..62f9ca81a --- /dev/null +++ b/vendor/esmini-data/patches/2.37.0-test-driver-path.patch @@ -0,0 +1,27 @@ +diff --git a/EnvironmentSimulator/code-examples/test-driver/test-driver.xosc b/EnvironmentSimulator/code-examples/test-driver/test-driver.xosc +index e4ee105..81e5c12 100644 +--- a/EnvironmentSimulator/code-examples/test-driver/test-driver.xosc ++++ b/EnvironmentSimulator/code-examples/test-driver/test-driver.xosc +@@ -12,11 +12,11 @@ + + + +- ++ + + + +- ++ + + + +@@ -26,7 +26,7 @@ + + + +- ++ + + + diff --git a/optional/osi/vendor/protoc/Makefile b/vendor/esmini/Makefile similarity index 71% rename from optional/osi/vendor/protoc/Makefile rename to vendor/esmini/Makefile index 83740b9b3..10c25c6e0 100644 --- a/optional/osi/vendor/protoc/Makefile +++ b/vendor/esmini/Makefile @@ -1,7 +1,7 @@ # Overrides will be preserved in Makefile.package. override SOURCE_DIR := src -override PACKAGE_CHANNEL := _/_ +override PACKAGE_CHANNEL := cloe/stable override CLEAN_SOURCE_DIR := true -PROJECT_ROOT := ../../../.. +PROJECT_ROOT := ../.. include ${PROJECT_ROOT}/Makefile.package diff --git a/vendor/esmini/conandata.yml b/vendor/esmini/conandata.yml new file mode 100644 index 000000000..8d2106506 --- /dev/null +++ b/vendor/esmini/conandata.yml @@ -0,0 +1,21 @@ +--- +sources: + 2.37.0: + url: + - /~https://github.com/esmini/esmini/archive/refs/tags/v2.37.0.tar.gz + sha256: "a1f216411caa7d8782dd9c82683f8bac3f00d7da2f6370535726b6446c339e59" +patches: + 2.37.0: + - patch_file: patches/2.37.0_add_ctest.patch + patch_type: git + patch_description: > + Use CTest for running all unit tests. + - patch_file: patches/2.37.0_remove_operating_system_test.patch + patch_type: git + patch_description: > + Remove unnecessary operating system test. This intentionally fails and requires + a gtest filter to be used, but it's easier to just remove it. + - patch_file: patches/2.37.0_use_conan_osi_package.patch + patch_type: git + patch_description: > + Use open_simulation_interface package from Conan instead of downloaded version. diff --git a/vendor/esmini/conanfile.py b/vendor/esmini/conanfile.py new file mode 100644 index 000000000..46ff6ada0 --- /dev/null +++ b/vendor/esmini/conanfile.py @@ -0,0 +1,179 @@ +import os + +from conan import ConanFile +from conan.tools import cmake, files, env +from conan.tools.system import package_manager + +required_conan_version = ">=1.52.0" + + +class ESMini(ConanFile): + name = "esmini" + version = "2.37.0" + license = "MPL-2.0" + url = "/~https://github.com/esmini/esmini" + description = "Basic OpenScenario player" + topics = ("Environment Simulator", "OpenScenario", "OpenDrive") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_osg": [True, False], + "with_osi": [True, False], + "with_sumo": [True, False], + } + default_options = { + "shared": True, + "fPIC": True, + "with_osg": True, + "with_osi": True, + "with_sumo": True, + } + generators = "CMakeDeps" + + def export_sources(self): + files.export_conandata_patches(self) + + def configure(self): + if self.options.with_osg: + self.options.with_osi = True + if self.options.with_osi: + self.options["open-simulation-interface"].shared = self.options.shared + self.options["protobuf"].shared = True + self.options["open-simulation-interface"].shared = self.options.shared + self.options["protobuf"].shared = self.options.shared + + def layout(self): + # We can't use cmake_layout because ESmini *really* doesn't like stuff to + # not be directly in "build/": unit-tests provide wrong results and segfault. + # Conan likes putting stuff in "build/Debug" and "build/Release". + self.folders.src = "." + self.folders.build = "build" + self.folders.generators = "build/generators" + # TODO: I am not sure whether these are necessary... + self.cpp.source.includedirs = ["include"] + self.cpp.build.libdirs = ["."] + self.cpp.build.bindirs = ["."] + + def system_requirements(self): + packages = None + if self.options.with_osg: + # TODO: add all system requirements + packages = [ + "libfontconfig1-dev", + "libgl-dev", + "libxrandr-dev", + "libxinerama-dev", + ] + if packages: + apt = package_manager.Apt(self) + apt.install(packages, update=True, check=True) + + def requirements(self): + # Currently, esmini needs all dependencies whether you use them or not + self.requires("open-simulation-interface/3.5.0@cloe/stable") + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + # This is the same environment that is used by scripts/run_tests.sh: + base_folder = os.path.join(self.build_folder, "..") + test_env = env.Environment() + test_env.define( + "LSAN_OPTIONS", + f"print_suppressions=false:suppressions={base_folder}/scripts/LSAN.supp", + ) + test_env.define( + "ASAN_OPTIONS", + f"detect_invalid_pointer_pairs=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:fast_unwind_on_malloc=0:suppressions={base_folder}/scripts/ASAN.supp", + ) + test_vars = test_env.vars(self) + test_vars.save_script("esminitest") + + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_PROJECT_VERSION"] = self.version + tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.cache_variables["USE_OSG"] = self.options.with_osg + tc.cache_variables["USE_OSI"] = self.options.with_osi + tc.cache_variables["USE_SUMO"] = self.options.with_sumo + tc.cache_variables["USE_GTEST"] = True + tc.cache_variables["DYN_PROTOBUF"] = self.options.shared + tc.generate() + + def build(self): + files.apply_conandata_patches(self) + + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + cm.install() + if self.should_test: + cm.test(env=["conanrun", "conanbuild", "esminitest"]) + + def package(self): + files.copy( + self, + "*", + src=os.path.join(self.source_folder, "bin"), + dst=os.path.join(self.package_folder, "bin"), + excludes=["*.a", "*.so"], + ) + files.copy( + self, + "*.hpp", + src=os.path.join(self.source_folder, "EnvironmentSimulator", "Libraries"), + dst=os.path.join(self.package_folder, "include"), + keep_path=False, + ) + files.copy( + self, + "*.a", + src=os.path.join(self.source_folder, "bin"), + dst=os.path.join(self.package_folder, "lib"), + keep_path=False, + ) + files.copy( + self, + "*.so", + src=os.path.join(self.source_folder, "bin"), + dst=os.path.join(self.package_folder, "lib"), + keep_path=False, + ) + files.copy( + self, + "LICENSE", + src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses"), + ) + files.copy( + self, + "*", + src=os.path.join(self.source_folder, "3rd_party_terms_and_licenses"), + dst=os.path.join(self.package_folder, "licenses"), + ) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "esmini") + self.cpp_info.set_property("cmake_target_name", "esmini::esmini") + if self.options.shared: + self.cpp_info.components["esmini"].libs = ["esminiLib", "esminiRMLib"] + self.cpp_info.components["esminiLib"].libs = ["esminiLib"] + else: + self.cpp_info.components["esmini"].libs = [ + "esminiLib_static", + "esminiRMLib", + ] + self.cpp_info.components["esminiLib"].libs = ["esminiLib_static"] + self.cpp_info.components["esminiRMLib"].libs = ["esminiRMLib"] + if self.options.with_osi: + self.cpp_info.components["esmini"].requires = [ + "open-simulation-interface::open-simulation-interface" + ] + self.cpp_info.components["esminiLib"].requires = [ + "open-simulation-interface::open-simulation-interface" + ] + + self.runenv_info.prepend_path("PATH", os.path.join(self.package_folder, "bin")) diff --git a/vendor/esmini/patches/2.37.0_add_ctest.patch b/vendor/esmini/patches/2.37.0_add_ctest.patch new file mode 100644 index 000000000..812ab2393 --- /dev/null +++ b/vendor/esmini/patches/2.37.0_add_ctest.patch @@ -0,0 +1,55 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c820a47..dc5a621 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,3 +1,5 @@ ++cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) ++ + message( + STATUS "CMake version: " + ${CMAKE_VERSION}) +@@ -82,22 +84,12 @@ set(ESMINI_BUILD_VERSION + + # ############################### Setting project rules ############################################################ + +-if(WIN32) +- cmake_minimum_required( +- VERSION 3.7.1 # for cmake generator VisualStudio 2017 support +- # VERSION 3.14 # for cmake generator VisualStudio 2019 support VERSION 3.19 # for cmake presets support +- FATAL_ERROR) +-else() +- cmake_minimum_required( +- VERSION 2.8.12 +- FATAL_ERROR) +-endif() +- + set_property( + GLOBAL + PROPERTY USE_FOLDERS + ON) + ++include(CTest) + include(support/cmake/rule/project_options.cmake) + + if(${CMAKE_SYSTEM_NAME} +diff --git a/support/cmake/common/unittest.cmake b/support/cmake/common/unittest.cmake +index 2df5b8a..edb9efe 100644 +--- a/support/cmake/common/unittest.cmake ++++ b/support/cmake/common/unittest.cmake +@@ -2,6 +2,9 @@ include_guard() + + # ############################### Building given unittest target ################################################### + ++include(CTest) ++include(GoogleTest) ++ + macro( + unittest + TARGET +@@ -55,5 +58,6 @@ macro( + add_test( + NAME ${TARGET} + COMMAND ${TARGET}) ++ gtest_add_tests(TARGET ${TARGET}) + + endmacro() diff --git a/vendor/esmini/patches/2.37.0_cloud_urls.patch b/vendor/esmini/patches/2.37.0_cloud_urls.patch new file mode 100644 index 000000000..12caa1159 --- /dev/null +++ b/vendor/esmini/patches/2.37.0_cloud_urls.patch @@ -0,0 +1,122 @@ +diff --git a/support/cmake/cloud/download.cmake b/support/cmake/cloud/download.cmake +index 757905a..9b565ff 100644 +--- a/support/cmake/cloud/download.cmake ++++ b/support/cmake/cloud/download.cmake +@@ -16,6 +16,7 @@ function( + ${target_folder}/${target_filename} + STATUS DOWNLOAD_STATUS + LOG DOWNLOAD_LOG ++ NETRC OPTIONAL + INACTIVITY_TIMEOUT 60) + + set(log_file +diff --git a/support/cmake/cloud/set_cloud_links.cmake b/support/cmake/cloud/set_cloud_links.cmake +index 1e3202b..333e364 100644 +--- a/support/cmake/cloud/set_cloud_links.cmake ++++ b/support/cmake/cloud/set_cloud_links.cmake +@@ -3,87 +3,105 @@ include_guard() + macro(set_cloud_links) + + set(MODELS_PACKAGE_URL ++ http://localhost:8080/models.7z; + https://esmini.asuscomm.com/AICLOUD779364751/models/models.7z; + https://drive.google.com/u/1/uc?id=1c3cqRzwY41gWXbg0rmugQkL5I_5L6DH_&export=download; + https://dl.dropboxusercontent.com/s/5gk8bvgzqiaaoco/models.7z?dl=1) + + if(APPLE) + set(OSG_PACKAGE_URL ++ http://localhost:8080/OpenSceneGraph_mac.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/OpenSceneGraph_mac.7z; + https://drive.google.com/u/1/uc?id=1mfn_vrcXBoFBekR_t8RXTWB4sD59JD7p&export=download; + https://www.dropbox.com/s/d0czj6b89p9jyvv/OpenSceneGraph_mac.7z?dl=1) + if(OSI_VERSION_3_3_1) + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_mac.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_mac.7z; + https://drive.google.com/u/1/uc?id=1UVzO8cPQaDU9KVn9v2v8Suj0uUw1dzYI&export=download; + https://www.dropbox.com/s/m62v19gp0m73dte/osi_mac.7z?dl=1) + else() + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_3_5_0_mac_clang_1200.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_3_5_0_mac_clang_1200.7z; + https://drive.google.com/u/1/uc?id=1Owvoy9N_PGXe-s9GUgDxg-4h2AhlQ_Pi&export=download; + https://www.dropbox.com/s/3pp3ijt9evvawep/osi_3_5_0_mac_clang_1200.7z?dl=1) + endif() + set(SUMO_PACKAGE_URL ++ http://localhost:8080/sumo_mac.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/sumo_mac.7z; + https://drive.google.com/u/1/uc?id=1FAve0-MlJPv6lUZy0HvriZI7xstLAzvX&export=download; + https://www.dropbox.com/s/0x8kwztk7nmacs1/sumo_mac.7z?dl=1) + set(IMPLOT_PACKAGE_URL ++ http://localhost:8080/implot_mac.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/implot_mac.7z; + https://drive.google.com/u/1/uc?id=1Cjda4pzyOGpOBiKAJ0_nBAeK8wcWzPuT&export=download; + https://www.dropbox.com/scl/fi/kg6km3plk755vnz8gv1me/implot_mac.7z?rlkey=zzbpujrhoprlwnjeudv9pcb1o&dl=1) + elseif(LINUX) + set(OSG_PACKAGE_URL ++ http://localhost:8080/osg_linux_glibc_2_31_gcc_7_5_0.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osg_linux_glibc_2_31_gcc_7_5_0.7z; + https://drive.google.com/u/1/uc?id=1Ya1bLp_0-qqlhs67WAwbGW7l37wqP3o2&export=download; + https://www.dropbox.com/s/4ug0gmkgdavzyb4/osg_linux_glibc_2_31_gcc_7_5_0.7z?dl=1) + if(OSI_VERSION_3_3_1) + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_linux.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_linux.7z; + https://drive.google.com/u/1/uc?id=1Q8O9YciIC0BPEszIKtQ2UW9KcVRZS4iB&export=download; + https://dl.dropboxusercontent.com/s/kwtdg0c1c8pawa1/osi_linux.7z?dl=1) + else() + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_3_5_0_linux_glibc_2_31_gcc_7_5_0.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_3_5_0_linux_glibc_2_31_gcc_7_5_0.7z; + https://drive.google.com/u/1/uc?id=1Xq_zQ5xaszYuN6G_dgSFHchXdnDxN6hS&export=download; + https://www.dropbox.com/s/c7r04x85h92gw5z/osi_3_5_0_linux_glibc_2_31_gcc_7_5_0.7z?dl=1) + endif() + set(SUMO_PACKAGE_URL ++ http://localhost:8080/sumo_linux.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/sumo_linux.7z; + https://drive.google.com/u/1/uc?id=1m4znxNIXapP0D-l21oIm2l7L5ti-JbZH&export=download; + https://dl.dropboxusercontent.com/s/gfwtqd3gf76f86a/sumo_linux.7z?dl=1) + set(GTEST_PACKAGE_URL ++ http://localhost:8080/googletest_linux.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/googletest_linux.7z; + https://drive.google.com/u/1/uc?id=1Hyr9eJX2GmgpYwZhx14xOoXlZ2j-FY_p&export=download; + https://dl.dropboxusercontent.com/s/si7jsjjsy5bpoym/googletest_linux.7z?dl=1) + set(IMPLOT_PACKAGE_URL ++ http://localhost:8080/implot_linux_glibc_2_31_gcc_7_5_0.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/implot_linux_glibc_2_31_gcc_7_5_0.7z; + https://drive.google.com/u/1/uc?id=1YVetAhT7IBLTvkbDeyCDgZ3mjbExcxFY&export=download; + https://www.dropbox.com/scl/fi/d5h6vdqqf6q890d53541b/implot_linux_glibc_2_31_gcc_7_5_0.7z?rlkey=galhhylarlx70lhzfdmih4jim&dl=1) + elseif(MSVC) + set(OSG_PACKAGE_URL ++ http://localhost:8080/OpenSceneGraph_v10.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/OpenSceneGraph_v10.7z; + https://drive.google.com/u/1/uc?id=1RTag0aUn_pJPK697j0-E72ABW10wZvOm&export=download; + https://dl.dropboxusercontent.com/s/e95hnoo782p40uc/OpenSceneGraph_v10.7z?dl=1) + if(OSI_VERSION_3_3_1) + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_v10.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_v10.7z; + https://drive.google.com/u/1/uc?id=1pcQcVHUESOk2Wmi-zUA7uzdxxE6iwRJx&export=download; + https://dl.dropboxusercontent.com/s/an58ckp2qfx5069/osi_v10.7z?dl=1) + else() + set(OSI_PACKAGE_URL ++ http://localhost:8080/osi_3_5_0_win_vs_sdk_141.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/osi_3_5_0_win_vs_sdk_141.7z; + https://drive.google.com/u/1/uc?id=1v490rg7s4kpuT28O5DI-fXc9BxyHqhVA&export=download; + https://www.dropbox.com/s/1xjb16ilsm4ir7x/osi_3_5_0_win_vs_sdk_141.7z?dl=1) + endif() + set(SUMO_PACKAGE_URL ++ http://localhost:8080/sumo_v10.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/sumo_v10.7z; + https://drive.google.com/u/1/uc?id=18PhbSLyvs0IGWTAY3YBoYzpVnMFPbOuR&export=download; + https://dl.dropboxusercontent.com/s/5jtpnnd61wonxuh/sumo_v10.7z?dl=1) + set(GTEST_PACKAGE_URL ++ http://localhost:8080/googletest_v10.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/googletest_v10.7z; + https://drive.google.com/u/1/uc?id=1So-3gtrmEdW9RhEvVQisj1QFksHM_otU&export=download; + https://dl.dropboxusercontent.com/s/aaiehwzc6woqbc6/googletest_v10.7z?dl=1) + set(IMPLOT_PACKAGE_URL ++ http://localhost:8080/implot_v10.7z; + https://esmini.asuscomm.com/AICLOUD766065121/libs/implot_v10.7z; + https://drive.google.com/u/1/uc?id=1k7dEITeu3vy6RTqKUw2o4FiTYljVuHkk&export=download; + https://www.dropbox.com/scl/fi/txl0jqi49ysreoegcoqk9/implot_v10.7z?rlkey=jh0cd5bkpzrxxt8sn0q4frjpr&dl=1) diff --git a/vendor/esmini/patches/2.37.0_remove_operating_system_test.patch b/vendor/esmini/patches/2.37.0_remove_operating_system_test.patch new file mode 100644 index 000000000..b0a658337 --- /dev/null +++ b/vendor/esmini/patches/2.37.0_remove_operating_system_test.patch @@ -0,0 +1,23 @@ +diff --git a/EnvironmentSimulator/Unittest/CMakeLists.txt b/EnvironmentSimulator/Unittest/CMakeLists.txt +index 58cdea2..f9764c9 100644 +--- a/EnvironmentSimulator/Unittest/CMakeLists.txt ++++ b/EnvironmentSimulator/Unittest/CMakeLists.txt +@@ -7,18 +7,11 @@ include(${CMAKE_SOURCE_DIR}/support/cmake/rule/disable_iwyu.cmake) + + include(${CMAKE_SOURCE_DIR}/support/cmake/common/unittest.cmake) + +-# ############################### Creating executable (OperatingSystem_test) ######################################### +- + if(USE_OSG) + set(VIEWER_LIBS_FOR_TEST + ViewerBase) + endif() + +-unittest( +- OperatingSystem_test +- OperatingSystem_test.cpp +- PlayerBase) +- + # ############################### Creating executable (RoadManager_test) ############################################# + + unittest( diff --git a/vendor/esmini/patches/2.37.0_use_conan_osi_package.patch b/vendor/esmini/patches/2.37.0_use_conan_osi_package.patch new file mode 100644 index 000000000..8528fea8a --- /dev/null +++ b/vendor/esmini/patches/2.37.0_use_conan_osi_package.patch @@ -0,0 +1,523 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dc5a621..4c4c6c8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,6 +51,7 @@ set(USE_OSG + ON + CACHE BOOL + "If projects that depend on osg should be compiled.") ++# TODO: Use openscenegraph from CCI + + set(USE_OSI + ON +@@ -66,16 +67,25 @@ set(USE_GTEST + ON + CACHE BOOL + "If unit test suites based on googletest should be compiled.") ++# TODO: Use gtest from CCI + + set(DYN_PROTOBUF + OFF + CACHE BOOL + "Set for dynamic linking of protobuf library (.so/.dll)") ++# TODO: Use protobuf from CCI + + set(USE_IMPLOT + ON + CACHE BOOL + "If implot for real-time plotting should be compiled.") ++# TODO: Use implot from CCI ++ ++# TODO: Use pugixml from CCI ++ ++# TODO: Use fmi2 from CCI ++ ++# TODO: Use dirent from CCI + + set(ESMINI_BUILD_VERSION + "N/A - client build" +@@ -110,6 +120,11 @@ if(NOT + message(FATAL_ERROR "Unrecognized platform therefore there isn't an installation directory. Stopping the cmake process.") + endif() + ++# ############################### Finding required packages ########################################################## ++ ++find_package(open_simulation_interface REQUIRED) ++find_package(protobuf REQUIRED) ++ + # ############################### Loading common packages ############################################################ + + include(${CMAKE_CURRENT_SOURCE_DIR}/support/cmake/common/color.cmake) +@@ -145,11 +160,11 @@ download( + ${EXTERNALS_OSG_OS_SPECIFIC_PATH} + "${OSG_PACKAGE_URL}") + +-download( +- osi +- ${EXTERNALS_OSI_PATH} +- ${EXTERNALS_OSI_OS_SPECIFIC_PATH} +- "${OSI_PACKAGE_URL}") ++# download( ++# osi ++# ${EXTERNALS_OSI_PATH} ++# ${EXTERNALS_OSI_OS_SPECIFIC_PATH} ++# "${OSI_PACKAGE_URL}") + + download( + sumo +@@ -157,6 +172,7 @@ download( + ${EXTERNALS_SUMO_OS_SPECIFIC_PATH} + "${SUMO_PACKAGE_URL}") + ++# TODO: Replace with CCI + download( + implot + ${EXTERNALS_IMPLOT_PATH} +diff --git a/EnvironmentSimulator/Applications/esmini-dyn/main.cpp b/EnvironmentSimulator/Applications/esmini-dyn/main.cpp +index 6b8d3b5..747ae54 100644 +--- a/EnvironmentSimulator/Applications/esmini-dyn/main.cpp ++++ b/EnvironmentSimulator/Applications/esmini-dyn/main.cpp +@@ -16,11 +16,11 @@ + */ + + #ifdef _USE_OSI +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_groundtruth.pb.h" +-#include "osi_sensordata.pb.h" +-#include "osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_groundtruth.pb.h" ++#include "osi3/osi_sensordata.pb.h" ++#include "osi3/osi_version.pb.h" + #endif + + #include "stdio.h" +diff --git a/EnvironmentSimulator/Applications/replayer/osi_receiver.cpp b/EnvironmentSimulator/Applications/replayer/osi_receiver.cpp +index bb94aa4..b354ded 100644 +--- a/EnvironmentSimulator/Applications/replayer/osi_receiver.cpp ++++ b/EnvironmentSimulator/Applications/replayer/osi_receiver.cpp +@@ -14,10 +14,10 @@ + #include + #include + +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_sensorview.pb.h" +-#include "osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_sensorview.pb.h" ++#include "osi3/osi_version.pb.h" + #include + + #ifndef _WINDOWS +diff --git a/EnvironmentSimulator/Libraries/esminiLib/esminiLib.cpp b/EnvironmentSimulator/Libraries/esminiLib/esminiLib.cpp +index aced2a3..a254873 100644 +--- a/EnvironmentSimulator/Libraries/esminiLib/esminiLib.cpp ++++ b/EnvironmentSimulator/Libraries/esminiLib/esminiLib.cpp +@@ -18,7 +18,7 @@ + #include "esminiLib.hpp" + #include "IdealSensor.hpp" + #ifdef USE_OSI +-#include "osi_sensordata.pb.h" ++#include "osi3/osi_sensordata.pb.h" + #endif + #include "vehicle.hpp" + #include "pugixml.hpp" +diff --git a/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.hpp b/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.hpp +index 8ab1396..0ba6af0 100644 +--- a/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.hpp ++++ b/EnvironmentSimulator/Modules/ScenarioEngine/SourceFiles/OSIReporter.hpp +@@ -16,14 +16,14 @@ + #include "IdealSensor.hpp" + #include "ScenarioGateway.hpp" + #include "ScenarioEngine.hpp" +-#include "osi_sensordata.pb.h" +-#include "osi_object.pb.h" +-#include "osi_groundtruth.pb.h" +-#include "osi_sensorview.pb.h" +-#include "osi_version.pb.h" +-#include "osi_common.pb.h" +-#include "osi_trafficcommand.pb.h" +-#include "osi_trafficupdate.pb.h" ++#include "osi3/osi_sensordata.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_groundtruth.pb.h" ++#include "osi3/osi_sensorview.pb.h" ++#include "osi3/osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_trafficcommand.pb.h" ++#include "osi3/osi_trafficupdate.pb.h" + #include + #include + #include +diff --git a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp +index 4c2ecd2..0b9e0f8 100644 +--- a/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp ++++ b/EnvironmentSimulator/Unittest/ScenarioEngineDll_test.cpp +@@ -1,10 +1,10 @@ + #include + #include + #include +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_sensorview.pb.h" +-#include "osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_sensorview.pb.h" ++#include "osi3/osi_version.pb.h" + #include "Replay.hpp" + #include "CommonMini.hpp" + #include "esminiLib.hpp" +@@ -16,6 +16,13 @@ + #define _USE_MATH_DEFINES + #include + ++#define USING_BUNDLED_OSI 0 ++#if USING_BUNDLED_OSI ++#define OSI_MAX_MSG_SIZE 10000 ++#else ++#define OSI_MAX_MSG_SIZE 12000 ++#endif ++ + class GetNumberOfObjectsTest : public ::testing::TestWithParam> + { + }; +@@ -331,7 +338,9 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) + SE_UpdateOSIGroundTruth(); + SE_FlushOSIFile(); + ASSERT_EQ(stat("gt.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 83802); // initial OSI size, including static content ++#endif + + int road_lane_size; + +@@ -344,13 +353,17 @@ TEST(GetOSIRoadLaneTest, lane_no_obj) + SE_UpdateOSIGroundTruth(); + SE_FlushOSIFile(); + ASSERT_EQ(stat("gt.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 84691); // slight growth due to only dynamic updates ++#endif + + SE_StepDT(0.001f); // Step for write another frame to osi file + SE_UpdateOSIGroundTruth(); + SE_FlushOSIFile(); + ASSERT_EQ(stat("gt.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 85581); // slight growth due to only dynamic updates ++#endif + + SE_DisableOSIFile(); + SE_Close(); +@@ -860,13 +873,15 @@ TEST(GroundTruthTests, check_GroundTruth_including_init_state) + SE_DisableOSIFile(); + + ASSERT_EQ(stat("gt.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 8126); ++#endif + + // Read OSI file + FILE* file = FileOpen("gt.osi", "rb"); + ASSERT_NE(file, nullptr); + +- const int max_msg_size = 10000; ++ const int max_msg_size = OSI_MAX_MSG_SIZE; + int msg_size; + char msg_buf[max_msg_size]; + +@@ -935,13 +950,15 @@ TEST(GroundTruthTests, check_frequency_implicit) + SE_Close(); + + ASSERT_EQ(stat("gt_implicit.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 8126); ++#endif + + // Read OSI file + FILE* file = FileOpen("gt_implicit.osi", "rb"); + ASSERT_NE(file, nullptr); + +- const int max_msg_size = 10000; ++ const int max_msg_size = OSI_MAX_MSG_SIZE; + int msg_size; + char msg_buf[max_msg_size]; + +@@ -1005,13 +1022,15 @@ TEST(GroundTruthTests, check_frequency_explicit) + SE_Close(); + + ASSERT_EQ(stat("gt_explicit.osi", &fileStatus), 0); ++#if USING_BUNDLED_OSI + EXPECT_EQ(fileStatus.st_size, 8126); ++#endif + + // Read OSI file + FILE* file = FileOpen("gt_explicit.osi", "rb"); + ASSERT_NE(file, nullptr); + +- const int max_msg_size = 10000; ++ const int max_msg_size = OSI_MAX_MSG_SIZE; + int msg_size; + char msg_buf[max_msg_size]; + +diff --git a/EnvironmentSimulator/code-examples/osi-groundtruth/osi-groundtruth.cpp b/EnvironmentSimulator/code-examples/osi-groundtruth/osi-groundtruth.cpp +index 466e9ba..cfae2bb 100644 +--- a/EnvironmentSimulator/code-examples/osi-groundtruth/osi-groundtruth.cpp ++++ b/EnvironmentSimulator/code-examples/osi-groundtruth/osi-groundtruth.cpp +@@ -1,9 +1,9 @@ + #include "esminiLib.hpp" + +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_groundtruth.pb.h" +-#include "osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_groundtruth.pb.h" ++#include "osi3/osi_version.pb.h" + + int main(int argc, char* argv[]) + { +diff --git a/EnvironmentSimulator/code-examples/osi-traffic_command/osi-traffic_command.cpp b/EnvironmentSimulator/code-examples/osi-traffic_command/osi-traffic_command.cpp +index 9b1aedd..5548bce 100644 +--- a/EnvironmentSimulator/code-examples/osi-traffic_command/osi-traffic_command.cpp ++++ b/EnvironmentSimulator/code-examples/osi-traffic_command/osi-traffic_command.cpp +@@ -1,10 +1,10 @@ + #include "esminiLib.hpp" + +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_groundtruth.pb.h" +-#include "osi_trafficcommand.pb.h" +-#include "osi_version.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_groundtruth.pb.h" ++#include "osi3/osi_trafficcommand.pb.h" ++#include "osi3/osi_version.pb.h" + + int main(int argc, char* argv[]) + { +diff --git a/OSMP_FMU/CMakeLists.txt b/OSMP_FMU/CMakeLists.txt +index 57413a4..d31622e 100644 +--- a/OSMP_FMU/CMakeLists.txt ++++ b/OSMP_FMU/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.5) ++cmake_minimum_required(VERSION 3.15) + + set(TARGET EsminiOsiSource) + project(${TARGET}) +@@ -13,7 +13,12 @@ execute_process( + string(SUBSTRING "${VERSION}" 1 -1 VERSION ) + string(STRIP "${VERSION}" VERSION) + +-set(OSIVERSION "3.5.0") ++find_package(open_simulation_interface REQUIRED) ++link_libraries(open_simulation_interface::libopen_simulation_interface) ++set(OSIVERSION ${open_simulation_interface_VERSION}) ++get_filename_component(EXTERNALS_OSI_PATH ++ "${open_simulation_interface_INCLUDE_DIR}" DIRECTORY) ++ + set(OSMPVERSION "1.4.0") + + set(STATIC_LINKING TRUE) +@@ -98,12 +103,11 @@ string(MD5 FMUGUID modelDescription.in.xml) + configure_file(modelDescription.in.xml modelDescription.xml @ONLY) + + include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../EnvironmentSimulator/Libraries/esminiLib +- ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osi/${EXT_INCL_DIR}/include) ++ ) + + link_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../bin +- ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osi/${EXT_INCL_DIR}/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../externals/sumo/${EXT_INCL_DIR}/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osg/${EXT_INCL_DIR}/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osg/${EXT_INCL_DIR}/lib/osgPlugins-3.6.5 +@@ -123,7 +127,7 @@ target_compile_definitions(${TARGET} PRIVATE "FMU_SHARED_OBJECT") + + if(STATIC_LINKING) + message("Link esmini statically") +- set(EXTERNALS_OSI_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osi/${EXT_INCL_DIR}/lib) ++ set(EXTERNALS_OSI_LIBRARY_PATH "${EXTERNALS_OSI_PATH}/lib") + set(EXTERNALS_OSG_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osg/${EXT_INCL_DIR}/lib) + set(EXTERNALS_OSG_PLUGINS_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../externals/osg/${EXT_INCL_DIR}/lib/osgPlugins-3.6.5) + set(EXTERNALS_SUMO_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../externals/sumo/${EXT_INCL_DIR}/lib) +diff --git a/OSMP_FMU/EsminiOsiSource.cpp b/OSMP_FMU/EsminiOsiSource.cpp +index c8e0496..6a1f3ee 100644 +--- a/OSMP_FMU/EsminiOsiSource.cpp ++++ b/OSMP_FMU/EsminiOsiSource.cpp +@@ -6,10 +6,10 @@ + + #include "esminiLib.hpp" + +-#include "osi_common.pb.h" +-#include "osi_object.pb.h" +-#include "osi_groundtruth.pb.h" +-#include "osi_trafficupdate.pb.h" ++#include "osi3/osi_common.pb.h" ++#include "osi3/osi_object.pb.h" ++#include "osi3/osi_groundtruth.pb.h" ++#include "osi3/osi_trafficupdate.pb.h" + + #include "EsminiOsiSource.h" + +diff --git a/OSMP_FMU/EsminiOsiSource.h b/OSMP_FMU/EsminiOsiSource.h +index 9027ff2..5f90ac2 100644 +--- a/OSMP_FMU/EsminiOsiSource.h ++++ b/OSMP_FMU/EsminiOsiSource.h +@@ -81,8 +81,8 @@ using namespace std; + + #undef min + #undef max +-#include "osi_sensorview.pb.h" +-#include "osi_trafficcommand.pb.h" ++#include "osi3/osi_sensorview.pb.h" ++#include "osi3/osi_trafficcommand.pb.h" + + /* FMU Class */ + class EsminiOsiSource { +diff --git a/support/cmake/common/locations.cmake b/support/cmake/common/locations.cmake +index d4ee92e..193870f 100644 +--- a/support/cmake/common/locations.cmake ++++ b/support/cmake/common/locations.cmake +@@ -63,8 +63,8 @@ macro(set_project_external_paths) + ${EXTERNALS_PATH}/googletest) + set(EXTERNALS_OSG_PATH + ${EXTERNALS_PATH}/osg) +- set(EXTERNALS_OSI_PATH +- ${EXTERNALS_PATH}/osi) ++ get_filename_component(EXTERNALS_OSI_PATH ++ "${open_simulation_interface_INCLUDE_DIR}" DIRECTORY) + set(EXTERNALS_PUGIXML_PATH + ${EXTERNALS_PATH}/pugixml) + set(EXTERNALS_SUMO_PATH +@@ -84,7 +84,7 @@ macro(set_project_os_specific_paths) + set(EXTERNALS_OSG_OS_SPECIFIC_PATH + ${EXTERNALS_OSG_PATH}/mac) + set(EXTERNALS_OSI_OS_SPECIFIC_PATH +- ${EXTERNALS_OSI_PATH}/mac) ++ ${EXTERNALS_OSI_PATH}) + set(EXTERNALS_SUMO_OS_SPECIFIC_PATH + ${EXTERNALS_SUMO_PATH}/mac) + set(EXTERNALS_GOOGLETEST_OS_SPECIFIC_PATH +@@ -97,7 +97,7 @@ macro(set_project_os_specific_paths) + set(EXTERNALS_OSG_OS_SPECIFIC_PATH + ${EXTERNALS_OSG_PATH}/linux) + set(EXTERNALS_OSI_OS_SPECIFIC_PATH +- ${EXTERNALS_OSI_PATH}/linux) ++ ${EXTERNALS_OSI_PATH}) + set(EXTERNALS_SUMO_OS_SPECIFIC_PATH + ${EXTERNALS_SUMO_PATH}/linux) + set(EXTERNALS_GOOGLETEST_OS_SPECIFIC_PATH +@@ -120,7 +120,7 @@ macro(set_project_os_specific_paths) + set(EXTERNALS_OSG_OS_SPECIFIC_PATH + ${EXTERNALS_OSG_PATH}/v10) + set(EXTERNALS_OSI_OS_SPECIFIC_PATH +- ${EXTERNALS_OSI_PATH}/v10) ++ ${EXTERNALS_OSI_PATH}) + set(EXTERNALS_SUMO_OS_SPECIFIC_PATH + ${EXTERNALS_SUMO_PATH}/v10) + set(EXTERNALS_GOOGLETEST_OS_SPECIFIC_PATH +@@ -152,7 +152,8 @@ macro(set_project_includes) + ${EXTERNALS_OSG_OS_SPECIFIC_PATH}/build/include + ${EXTERNALS_OSG_OS_SPECIFIC_PATH}/include) + set(EXTERNALS_OSI_INCLUDES +- ${EXTERNALS_OSI_OS_SPECIFIC_PATH}/include) ++ "${open_simulation_interface_INCLUDE_DIRS}" ++ "${protobuf_INCLUDE_DIRS}") + set(EXTERNALS_SUMO_INCLUDES + ${EXTERNALS_SUMO_OS_SPECIFIC_PATH}/include) + set(EXTERNALS_GOOGLETEST_INCLUDES +@@ -175,13 +176,8 @@ macro(set_project_library_paths) + set(EXTERNALS_OSG_PLUGINS_LIBRARY_PATH + ${EXTERNALS_OSG_LIBRARY_PATH}/osgPlugins-3.6.5) + +- if(DYN_PROTOBUF) +- set(EXTERNALS_OSI_LIBRARY_PATH +- ${EXTERNALS_OSI_OS_SPECIFIC_PATH}/lib-dyn) +- else() +- set(EXTERNALS_OSI_LIBRARY_PATH +- ${EXTERNALS_OSI_OS_SPECIFIC_PATH}/lib) +- endif(DYN_PROTOBUF) ++ set(EXTERNALS_OSI_LIBRARY_PATH ++ ${EXTERNALS_OSI_OS_SPECIFIC_PATH}/lib) + + set(EXTERNALS_SUMO_LIBRARY_PATH + ${EXTERNALS_SUMO_OS_SPECIFIC_PATH}/lib) +diff --git a/support/cmake/external/osi.cmake b/support/cmake/external/osi.cmake +index 780fdb2..b49b44d 100644 +--- a/support/cmake/external/osi.cmake ++++ b/support/cmake/external/osi.cmake +@@ -3,61 +3,8 @@ include_guard() + # ############################### Setting osi libraries ############################################################## + + macro(set_osi_libs) ++ find_package(open_simulation_interface REQUIRED) ++ find_package(Protobuf REQUIRED) + +- if(APPLE) +- if(DYN_PROTOBUF) +- set(OSI_LIBRARIES +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interface.dylib +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.dylib) +- else() +- set(OSI_LIBRARIES +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interface_pic.a +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.a) +- endif() +- +- elseif(LINUX) +- if(DYN_PROTOBUF) +- set(OSI_LIBRARIES +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interface.so +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.so +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interfaced.so +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobufd.so) +- else() +- set(OSI_LIBRARIES +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interface_pic.a +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.a +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libopen_simulation_interface_picd.a +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobufd.a) +- endif() +- elseif(MSVC) +- if(DYN_PROTOBUF) +- set(OSI_LIBRARIES +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/open_simulation_interface.dll +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.lib +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/open_simulation_interfaced.dll +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobufd.lib) +- else() +- set(OSI_LIBRARIES +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/open_simulation_interface_pic.lib +- optimized +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobuf.lib +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/open_simulation_interface_picd.lib +- debug +- ${EXTERNALS_OSI_LIBRARY_PATH}/libprotobufd.lib) +- endif() +- endif() ++ set(OSI_LIBRARIES ${open_simulation_interface_LIBRARIES} ${Protobuf_LIBRARIES}) + endmacro() diff --git a/vendor/esmini/test_package/CMakeLists.txt b/vendor/esmini/test_package/CMakeLists.txt new file mode 100644 index 000000000..57e834a31 --- /dev/null +++ b/vendor/esmini/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(esmini REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} + PUBLIC + esmini::esmini +) diff --git a/vendor/esmini/test_package/conanfile.py b/vendor/esmini/test_package/conanfile.py new file mode 100644 index 000000000..2eeae4258 --- /dev/null +++ b/vendor/esmini/test_package/conanfile.py @@ -0,0 +1,30 @@ +import os + +from conan import ConanFile +from conan.tools import build, cmake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake.cmake_layout(self) + + def generate(self): + tc = cmake.CMakeToolchain(self) + tc.generate() + + def build(self): + cm = cmake.CMake(self) + cm.configure() + cm.build() + + def test(self): + if build.can_run(self): + bin_path = os.path.join(self.build_folder, self.cpp.build.bindirs[0], "test_package") + self.run(f"{bin_path} test-driver.xosc", env="conanrun", cwd=self.source_folder) diff --git a/vendor/esmini/test_package/resources/VehicleCatalog.xosc b/vendor/esmini/test_package/resources/VehicleCatalog.xosc new file mode 100644 index 000000000..516e71015 --- /dev/null +++ b/vendor/esmini/test_package/resources/VehicleCatalog.xosc @@ -0,0 +1,614 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/esmini/test_package/resources/curves_elevation.xodr b/vendor/esmini/test_package/resources/curves_elevation.xodr new file mode 100644 index 000000000..a24dedef0 --- /dev/null +++ b/vendor/esmini/test_package/resources/curves_elevation.xodr @@ -0,0 +1,163 @@ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +