diff --git a/conanfile.py b/conanfile.py index c918846e0..5d3cb67a8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -34,6 +34,8 @@ class Cloe(ConanFile): "cloe-plugin-noisy-sensor", "cloe-plugin-speedometer", "cloe-plugin-virtue", + "cloe-databroker-bindings", + "cloe-python-api" ) options = { "shared": [True, False], @@ -99,7 +101,7 @@ def requirements(self): if self.options.engine_server: self.requires("oatpp/1.3.0") if self.options.python_api: - self.requires("pybind11/2.10.1") + self.requires("pybind11/2.11.1") def build_requirements(self): self.test_requires("gtest/1.13.0") @@ -196,13 +198,17 @@ def package_info(self): 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") - pydir = os.path.join(self.source_folder, "python/python_api") + pypath_build = os.path.join(self.build_folder, "lib/cloe/python") + pypath_source = os.path.join(self.source_folder, "python/python_api") libdir = os.path.join(self.build_folder, "lib") + cloe_bindings_path = libdir 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") - pydir = os.path.join(self.package_folder, "lib/cloe/python") + pypath_build = os.path.join(self.package_folder, "lib/cloe/python") + pypath_source = pypath_build + cloe_bindings_path = os.path.join(self.package_folder, "lib/cloe/python/cloe") libdir = None self.output.info(f"Appending PATH environment variable: {bindir}") @@ -213,6 +219,7 @@ def package_info(self): self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}") self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) if self.options.python_api: - self.output.info(f"Appending PYHTONPATH and CLOE_PYTHON_BINDINGS environment variables: {pydir}") - self.runenv_info.prepend_path("PYTHONPATH", str(pydir)) - self.runenv_info.prepend_path("CLOE_PYTHON_BINDINGS", str(pydir)) + self.output.info(f"Appending PYHTONPATH and CLOE_PYTHON_BINDINGS environment variables") + self.runenv_info.prepend_path("PYTHONPATH", str(pypath_source)) + self.runenv_info.prepend_path("PYTHONPATH", str(cloe_bindings_path)) + self.runenv_info.prepend_path("CLOE_PYTHON_BINDINGS", str(pypath_build)) diff --git a/plugins/basic/CMakeLists.txt b/plugins/basic/CMakeLists.txt index 74c8baf0f..f0aa8bfcb 100644 --- a/plugins/basic/CMakeLists.txt +++ b/plugins/basic/CMakeLists.txt @@ -32,6 +32,14 @@ set_target_properties(_basic_bindings PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) + +set_target_properties(_basic_bindings + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloe/python" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cloe/python" + ) + + install(TARGETS _basic_bindings LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cloe/python) include(CTest) diff --git a/python/python_api/cloe/__init__.py b/python/python_api/cloe/__init__.py index 9a971bd64..13c313524 100644 --- a/python/python_api/cloe/__init__.py +++ b/python/python_api/cloe/__init__.py @@ -1,2 +1,2 @@ from ._runner import TestRunner, Simulation -from ._cloe_bindings import CallbackResult +from _cloe_bindings import CallbackResult diff --git a/python/python_api/cloe/_runner.py b/python/python_api/cloe/_runner.py index d858af9ee..af2d56b6d 100644 --- a/python/python_api/cloe/_runner.py +++ b/python/python_api/cloe/_runner.py @@ -2,12 +2,13 @@ from datetime import timedelta from pathlib import Path import os +import sys from time import sleep from typing import Optional, Dict, Any from queue import Queue, Empty -from ._cloe_bindings import SimulationDriver, CallbackResult, DataBrokerAdapter, SimulationDriver, Stack -from ._cloe_bindings import Simulation as _Simulation +from _cloe_bindings import SimulationDriver, CallbackResult, DataBrokerAdapter, SimulationDriver, Stack +from _cloe_bindings import Simulation as _Simulation @dataclass @@ -176,8 +177,7 @@ def log_level(self, value): self._sim.log_level = value def bind_plugin_types(self, lib: Path): - import importlib - import sys + import importlib.util components = str(lib.name).split('.') module_name = components[0] print(f"Attempting to load module {module_name} from {lib}") @@ -194,11 +194,7 @@ def bind_plugin_types(self, lib: Path): def __init__(self, stack: Optional[Dict[str, Any]] = None): self.databroker_adapter = DataBrokerAdapter() self.driver = SimulationDriver(self.databroker_adapter) - if "CLOE_PLUGIN_PATH" not in os.environ: - # todo this is just here for debugging - plugin_paths = ["/home/ohf4fe/dev/sil/cloe/build/linux-x86_64-gcc-8/Debug/lib/cloe"] - else: - plugin_paths = os.environ["CLOE_PLUGIN_PATH"].split(":") + plugin_paths = os.environ["CLOE_PLUGIN_PATH"].split(":") full_config_stack = Stack(plugin_paths) if not stack: # todo this is just here for debugging diff --git a/python/python_api/cloe/src/CMakeLists.txt b/python/python_api/cloe/src/CMakeLists.txt index ed2bf2ddf..929759d3d 100644 --- a/python/python_api/cloe/src/CMakeLists.txt +++ b/python/python_api/cloe/src/CMakeLists.txt @@ -1,5 +1,3 @@ -set(PYTHON_BINDINGS_LOCAL_DEV OFF CACHE BOOL "This sets the compiler output to the local source tree so - the cloe python project can be simply imported.") set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION}) if(CLOE_FIND_PACKAGES) @@ -24,13 +22,6 @@ set_target_properties(_cloe_bindings PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -if(PYTHON_BINDINGS_LOCAL_DEV) - set_target_properties(_cloe_bindings - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.." - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.." - ) -endif() target_link_libraries(_cloe_bindings PUBLIC cloe::stacklib cloe::databroker-bindings cloe::simulation) target_include_directories(_cloe_bindings PRIVATE ${PROJECT_SOURCE_DIR}/engine/src) diff --git a/python/python_api/cloe/test/config_minimator_infinite.json b/python/python_api/cloe/test/config_minimator_infinite.json index 29fdc85b3..a3fc0b66a 100644 --- a/python/python_api/cloe/test/config_minimator_infinite.json +++ b/python/python_api/cloe/test/config_minimator_infinite.json @@ -15,8 +15,35 @@ }, "simulators": [ { - "binding": "minimator" - // name is automatically "minimator" + "binding": "minimator", + "args": { + "vehicles": { + "ego1": { + "ego_sensor_mockup": { + "ego_object": { + "velocity": 20.0, + "position": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + } + } + }, + "object_sensor_mockup": { + "objects": [ + { + "velocity": 0.0, + "position": { + "x": 10.0, + "y": 0.0, + "z": 0.0 + } + } + ] + } + } + } + } } ], "vehicles": [ diff --git a/python/python_api/cloe/test/config_minimator_smoketest.json b/python/python_api/cloe/test/config_minimator_smoketest.json index 767d78985..1696455c2 100644 --- a/python/python_api/cloe/test/config_minimator_smoketest.json +++ b/python/python_api/cloe/test/config_minimator_smoketest.json @@ -3,18 +3,37 @@ "include": [ "config_minimator_infinite.json" ], + "logging": [ + { + "name": "*", + "level": "error" + } + ], "server": { "listen": false, "listen_port": 23456 }, "triggers": [ - {"event": "virtue/failure", "action": "fail"}, { - "label": "Vehicle default should never move with the minimator binding.", - "event": "default_speed/kmph=>0.0", "action": "fail" + "event": "virtue/failure", + "action": "fail" }, - {"event": "start", "action": "log=info: Running minimator/basic smoketest."}, - {"event": "start", "action": "realtime_factor=-1"}, - {"event": "time=60", "action": "succeed"} + { + "label": "Vehicle default should never move at a velocity greater that 72 kmph with the minimator binding.", + "event": "default_speed/kmph=>80.0", + "action": "fail" + }, + { + "event": "start", + "action": "log=info: Running minimator/basic smoketest." + }, + { + "event": "start", + "action": "realtime_factor=-1" + }, + { + "event": "time=60", + "action": "succeed" + } ] } diff --git a/runtime/include/cloe/databroker/data_broker_meta_information.hpp b/runtime/include/cloe/databroker/data_broker_meta_information.hpp index b0efdb607..53b286fce 100644 --- a/runtime/include/cloe/databroker/data_broker_meta_information.hpp +++ b/runtime/include/cloe/databroker/data_broker_meta_information.hpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace cloe { /**