diff --git a/.clang-format b/.clang-format index 9cf6330c11cd21bf7dc5c49cd4992dfa8a050a06..b580ec9ff78e8322008ec834c3ecfd72d8bbc62a 100644 --- a/.clang-format +++ b/.clang-format @@ -6,3 +6,4 @@ BinPackArguments: false BinPackParameters: false BreakBeforeBraces: Allman ColumnLimit: 0 +InsertNewlineAtEOF: true diff --git a/.cmake-format b/.cmake-format index 1fbbb020b01441bdb068a1865696cab156703875..8227f04a9b626d235889dfb597735a39d1cbc57f 100644 --- a/.cmake-format +++ b/.cmake-format @@ -14,12 +14,14 @@ command_case: canonical keyword_case: upper additional_commands: CPMAddPackage: + pargs: "*" kwargs: NAME: "*" GITHUB_REPOSITORY: "*" GIT_TAG: "*" VERSION: "*" OPTIONS: "*" + PATCH_COMMAND: "*" configure_package_config_file: flags: - NO_SET_AND_CHECK_MACRO diff --git a/CMakeLists.txt b/CMakeLists.txt index 67832395372f48cd4ed963b3db54cfc73536fdd4..ad3fb24318d1b2dfe774ebb7de4b01b9a619801c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ endif() project( MantleAPI VERSION 0.1.0 - DESCRIPTION "MantleAPI, an abstraction layer for environmental simulators" + DESCRIPTION "An abstraction layer for environmental simulators" LANGUAGES CXX ) diff --git a/README.md b/README.md index a27500d38d9cccc0bd272e6e20019136b167ff71..d15a6cdf6440114710cab70719ca9d4025c2cbac 100644 --- a/README.md +++ b/README.md @@ -3,69 +3,55 @@ A collection of interfaces for abstraction between a scenario engine and an environment simulator. It is intended to be usable with a wide variety of scenario description languages by implementing according scenario engines. -Remark: This is currently work in progress and no stable state is reached yet. +â—ï¸ This is currently work in progress and no stable state is reached yet. -## Used libraries -### Units -License: MIT License -URL: https://github.com/nholthaus/units -Version: v2.3.3 +## Build -### GoogleTest -License: BSD-3-Clause License -URL: https://github.com/google/googletest -Version: v1.12.1 +In order to build this project please consider the following sections. -### CPM -License: MIT License -URL: https://github.com/cpm-cmake/CPM.cmake -Version: v0.36.0 +The used configuration for all setups is `Debug`. For release builds change the configuration to `Release`. +### Ubuntu native or wsl2 (preferred) -## Build +1. âš™ï¸ Install requirements -In order to build this project please consider the following sections. + sudo apt-get -y update && sudo apt-get -y install \ + build-essential \ + cmake \ + doxygen \ + graphviz \ + ninja-build \ + plantuml -The used configuration for all setups is `Debug`. For release builds change the configuration to `Release`. +2. ðŸ› ï¸ Configure, build, and install -### Windows wsl2 Ubuntu and on Linux/Ubuntu native (prefered) + cd <path/to/mantle_api> + cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install + cmake --build build + cmake --install build -Install Requirements: -``` -sudo apt install graphviz doxygen cmake g++ -``` +3. 📄 Build docs -1. Build via cmake: - ``` - cd <path_to_mantle_api> - cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install - cmake --build build -j - cmake --install build - ``` + cd <path/to/mantle_api> + cmake --build build --target MantleAPI_doc + cat <path/to/mantle_api>/build/doc/html/index.html -2. Build doc: - ``` - cd <path_to_mantle_api> - cmake --build build --target MantleAPI_doc - cat <path_to_mantle_api>/build/doc/html/index.html - ``` +4. 🧪 Run tests -3. Test via ctest: - ``` - cd <path_to_mantle_api>/build - ctest --stop-on-failure - ``` - ctest runs the tests from both build targets: `CommonTests` and `MentleAPITests`. + cd <path/to/mantle_api>/build + ctest --stop-on-failure + + CTest runs the tests from both build targets: `CommonTest` and `MantleAPITest`. ### Windows mingw with cmake This section introduces a step by step guide to install the requirements to build this API with mingw tooling. Requirements: -- Follow the following guide to set up the mingw64 shell and the required dependencies (cmake, gcc, ninja, doxygen, graphviz): https://www.eclipse.org/openpass/content/html/installation_guide/20_install_prerequisites.html#installing-the-binary-packages +- Follow the following guide to set up the mingw64 shell and the required dependencies (cmake, gcc, ninja, doxygen, graphviz): https://www.eclipse.org/openpass/content/html/installation_guide/20_install_prerequisites.html#installing-the-binary-packages -Build via cmake (on a mingw console): +Build via cmake (on a mingw console): 1. Go to the project dir: `cd <project_dir>` 2. Build via cmake: ``` @@ -74,12 +60,12 @@ Build via cmake (on a mingw console): cmake -G "Ninja" .. ninja ``` -3. Test the API +3. Test the API ``` cd <path_to_mantle_api>/build/test ./MantleAPITest.exe ``` -4. Build Doc: +4. Build Doc: ``` cd <path_to_mantle_api>/build cmake --build . --target MantleAPI_doc @@ -90,10 +76,10 @@ Build via cmake (on a mingw console): This section introduces a step by step guide to install the requirements to build this API with native tooling. Requirements: -- install cmake: https://cmake.org/install/ +- install CMake: https://cmake.org/install/ - install Visual Studio build tools 2022: https://visualstudio.microsoft.com/downloads/#remote-tools-for-visual-studio-2022 -- install doxygen: https://www.doxygen.nl/download.html -- install graphviz: https://graphviz.org/download/ +- install Doxygen: https://www.doxygen.nl/download.html +- install Graphviz: https://graphviz.org/download/ Add doxygen, graphiz, and cmake to at least the current users PATH variable. @@ -107,9 +93,9 @@ Add doxygen, graphiz, and cmake to at least the current users PATH variable. cmake.exe --build <path_to_mantle_api>/build --config Debug --target all -- ``` -3. Run Tests: +3. Run Tests: - Common Test: + Common Test: ``` $> ."<path_to_mantle_api>/build/CommonTest.exe" Running main() from gmock_main.cc @@ -157,7 +143,7 @@ Add doxygen, graphiz, and cmake to at least the current users PATH variable. ### Versioning -Versioning should follow the semantic versioning pattern `MAJOR.MINOR.PATCH`. +Versioning follows the [semantic versioning pattern](https://semver.org/) `MAJOR.MINOR.PATCH`. Currently this is a manual task that needs to be approved as a part of a code review. In the following a course guideline is given, when to increment the according fields: @@ -169,14 +155,22 @@ In the following a course guideline is given, when to increment the according fi **Minor:** -- Increments, if changes are ABI compatible, i.e. independent of the rest of other mantle definitions. +- Increments, if changes are ABI compatible, i.e. independent of the rest of other mantle definitions. It is expected that this does not happen very often at the current state of development. -- Features related to testing, such as enhancing mocks, adding tests, etc. +- Features related to testing, such as enhancing mocks, adding tests etc. - Features related to chore tasks, such as CI scripts, CMake enhancements, formatters, etc. **Patch:** -- Fixing typos in the documentation (as long as they don't change the semantic of a function call!) +- Fixing typos in the documentation (as long as they don't change the semantics of a function call!) - Fixing bugs related to testing - Fixing bugs related to chore tasks +## Third party + +| Name | License | Version | +|--------------------------------------------------------------------|--------------|---------| +| [CPM](https://github.com/cpm-cmake/CPM.cmake) | MIT | 0.36.0 | +| [Doxygen Awesome](https://github.com/jothepro/doxygen-awesome-css) | MIT | 2.3.1 | +| [GoogleTest](https://github.com/google/googletest) | BSD-3-Clause | 1.12.1 | +| [Units](https://github.com/nholthaus/units) | MIT | 2.3.3 | diff --git a/cmake/FindPlantUML.cmake b/cmake/FindPlantUML.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9f056d1940a2d2f2d959b48be423fe83d8ee831d --- /dev/null +++ b/cmake/FindPlantUML.cmake @@ -0,0 +1,23 @@ +################################################################################ +# Copyright (c) 2024 Mercedes-Benz Tech Innovation GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +find_file(PLANTUML_JAR plantuml.jar PATHS ${PLANTUML_JAR_PATH} ENV{PLANTUML_JAR_PATH} /usr/share/plantuml) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PlantUML DEFAULT_MSG PLANTUML_JAR) + +if(PlantUML_FOUND) + if(NOT TARGET PlantUML::PlantUML) + add_executable(PlantUML::PlantUML IMPORTED) + if(EXISTS "${PLANTUML_JAR}") + set_target_properties(PlantUML::PlantUML PROPERTIES IMPORTED_LOCATION "${PLANTUML_JAR}") + endif() + endif() +endif() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3f2dc76506e3744b194de97fbed3a7db085984cd..b3b8e2eca1a0160e4c53c143b161b175cc1fd872 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -9,11 +9,30 @@ # SPDX-License-Identifier: EPL-2.0 ################################################################################ +CPMAddPackage("gh:jothepro/doxygen-awesome-css@2.3.3") + find_package(Doxygen QUIET REQUIRED dot OPTIONAL_COMPONENTS mscgen dia) set(DOXYGEN_BUILTIN_STL_SUPPORT YES) +set(DOXYGEN_DISABLE_INDEX NO) set(DOXYGEN_DOT_IMAGE_FORMAT svg) +set(DOXYGEN_DOT_TRANSPARENT YES) +set(DOXYGEN_FULL_SIDEBAR NO) set(DOXYGEN_GENERATE_LATEX NO) +set(DOXYGEN_GENERATE_TREEVIEW YES) +set(DOXYGEN_HTML_EXTRA_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/header.html + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-darkmode-toggle.js + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-fragment-copy-button.js + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-interactive-toc.js + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-paragraph-link.js +) +set(DOXYGEN_HTML_EXTRA_STYLESHEET + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome.css + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-sidebar-only.css + ${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome-sidebar-only-darkmode-toggle.css +) +set(DOXYGEN_HTML_HEADER header.html) set(DOXYGEN_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) set(DOXYGEN_INTERACTIVE_SVG YES) set(DOXYGEN_JAVADOC_AUTOBRIEF YES) @@ -25,6 +44,12 @@ set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${PROJECT_SOURCE_DIR}/README.md) set(DOXYGEN_WARN_LOGFILE ${CMAKE_CURRENT_BINARY_DIR}/DoxygenWarningLog.txt) set(DOXYGEN_WARN_NO_PARAMDOC YES) +find_package(PlantUML) +if(PlantUML_FOUND) + set(DOXYGEN_PLANTUML_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/diagrams) + set(DOXYGEN_PLANTUML_JAR_PATH ${PLANTUML_JAR}) +endif() + doxygen_add_docs( ${PROJECT_NAME}_doc ${PROJECT_SOURCE_DIR}/README.md ${PROJECT_SOURCE_DIR}/include COMMENT "Generate html docs" ) diff --git a/doc/diagrams/logging.puml b/doc/diagrams/logging.puml new file mode 100644 index 0000000000000000000000000000000000000000..c4bd2573e565b2961e95c252fc4b3175f3851445 --- /dev/null +++ b/doc/diagrams/logging.puml @@ -0,0 +1,59 @@ +@startuml Logging +set namespaceSeparator :: + +enum mantle_api::LogLevel { + kTrace + kDebug + kInfo + kWarning + kError + kCritical +} + +interface mantle_api::ILogger { + + {abstract} LogLevel GetCurrentLogLevel() const + + {abstract} void Log(LogLevel level, std::string_view message) + .. + + void Trace(std::string_view message) + + void Debug(std::string_view message) + + void Info(std::string_view message) + + void Warning(std::string_view message) + + void Error(std::string_view message) + + void Critical(std::string_view message) +} + +package Environment <<Frame>> #LightCyan { + +class EnvironmentImpl { + - mantle_api::ILogger logger_ +} + +} + +package Scenario <<Frame>> #LightGreen { + +class ScenarioEngineImpl { + - mantle_api::ILogger logger_ +} + +} + +package Simulator <<Frame>> #LightCoral { + +class LoggerImpl implements mantle_api::ILogger { + + mantle_api::LogLevel GetCurrentLogLevel() const + + void Log(mantle_api::LogLevel level, std::string_view message) +} + +class SimulatorImpl { + - mantle_api::ILogger logger_ +} + +} + +mantle_api::ILogger .right. mantle_api::LogLevel +EnvironmentImpl o-- mantle_api::ILogger +ScenarioEngineImpl o-- mantle_api::ILogger +SimulatorImpl *-- mantle_api::ILogger + +@enduml diff --git a/doc/header.html b/doc/header.html new file mode 100644 index 0000000000000000000000000000000000000000..81f90941ed30759ee8f4cf53acdbca8820acce00 --- /dev/null +++ b/doc/header.html @@ -0,0 +1,73 @@ +<!-- HTML header for doxygen 1.9.1--> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> + <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=9" /> + <meta name="generator" content="Doxygen $doxygenversion" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <!--BEGIN PROJECT_NAME--> + <title>$projectname: $title</title><!--END PROJECT_NAME--> + <!--BEGIN !PROJECT_NAME--> + <title>$title</title><!--END !PROJECT_NAME--> + <link href="$relpath^tabs.css" rel="stylesheet" type="text/css" /> + <script type="text/javascript" src="$relpath^jquery.js"></script> + <script type="text/javascript" src="$relpath^dynsections.js"></script> + $treeview + $search + $mathjax + <link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" /> + $extrastylesheet + + <script type="text/javascript" src="$relpath^doxygen-awesome-darkmode-toggle.js"></script> + <script type="text/javascript" src="$relpath^doxygen-awesome-fragment-copy-button.js"></script> + <script type="text/javascript" src="$relpath^doxygen-awesome-paragraph-link.js"></script> + <script type="text/javascript" src="$relpath^doxygen-awesome-interactive-toc.js"></script> + <script type="text/javascript"> + DoxygenAwesomeDarkModeToggle.init() + DoxygenAwesomeFragmentCopyButton.init() + DoxygenAwesomeParagraphLink.init() + DoxygenAwesomeInteractiveToc.init() + </script> +</head> + +<body> + <div id="top"><!-- do not remove this div, it is closed by doxygen! --> + + <!--BEGIN TITLEAREA--> + <div id="titlearea"> + <table cellspacing="0" cellpadding="0"> + <tbody> + <tr style="height: 56px;"> + <!--BEGIN PROJECT_LOGO--> + <td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo" /></td> + <!--END PROJECT_LOGO--> + <!--BEGIN PROJECT_NAME--> + <td id="projectalign" style="padding-left: 0.5em;"> + <div id="projectname">$projectname + <!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER--> + </div> + <!--BEGIN PROJECT_BRIEF--> + <div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF--> + </td> + <!--END PROJECT_NAME--> + <!--BEGIN !PROJECT_NAME--> + <!--BEGIN PROJECT_BRIEF--> + <td style="padding-left: 0.5em;"> + <div id="projectbrief">$projectbrief</div> + </td> + <!--END PROJECT_BRIEF--> + <!--END !PROJECT_NAME--> + <!--BEGIN DISABLE_INDEX--> + <!--BEGIN SEARCHENGINE--> + <td>$searchbox</td> + <!--END SEARCHENGINE--> + <!--END DISABLE_INDEX--> + </tr> + </tbody> + </table> + </div> + <!--END TITLEAREA--> + <!-- end header part --> diff --git a/include/MantleAPI/Common/bounding_box.h b/include/MantleAPI/Common/bounding_box.h index 5e378f12df7e8155671638773fd727b9fb18cf7a..0160dab467e5021a428f6f38986e56ef3fcf3857 100644 --- a/include/MantleAPI/Common/bounding_box.h +++ b/include/MantleAPI/Common/bounding_box.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file bounding_box.h */ +/// @file bounding_box.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_BOUNDING_BOX_H @@ -27,8 +27,8 @@ namespace mantle_api /// For vehicles the origin shall be the center of the rear axis. struct BoundingBox { - Vec3<units::length::meter_t> geometric_center{}; ///< Coordinates of bounding box center in local coordinate system - Dimension3 dimension{}; ///< Dimension of the bounding box (i.e. length = x dimension, width = y dimension, height = z dimension) + Vec3<units::length::meter_t> geometric_center{}; ///< Coordinates of bounding box center in local coordinate system + Dimension3 dimension{}; ///< Dimension of the bounding box (i.e. length = x dimension, width = y dimension, height = z dimension) }; /// @brief equality diff --git a/include/MantleAPI/Common/dimension.h b/include/MantleAPI/Common/dimension.h index 0c455ac5ba7eb35baab6599e539bb7376d5f75a2..16e13c81d15b481bd40fd4e8c504cb20a8d401cf 100644 --- a/include/MantleAPI/Common/dimension.h +++ b/include/MantleAPI/Common/dimension.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file dimension.h */ +/// @file dimension.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_DIMENSION_H diff --git a/include/MantleAPI/Common/floating_point_helper.h b/include/MantleAPI/Common/floating_point_helper.h index f11ef0ca726fda03b7a4018ad0c8e8f61eb51d1f..4824fa058e0c24288d2a44caef1a3e9a8b63946c 100644 --- a/include/MantleAPI/Common/floating_point_helper.h +++ b/include/MantleAPI/Common/floating_point_helper.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file floating_point_helper.h */ +/// @file floating_point_helper.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H @@ -19,7 +19,6 @@ #include <units.h> #include <cmath> -#include <limits> #include <type_traits> #if !defined(MANTLE_API_DEFAULT_EPS) @@ -98,7 +97,7 @@ constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = static_ca // Handle bigger values. // Values are considered almost equal, if their difference is less than epsilon multiplied by the bigger absolute value. - if(!absolute_comparison_only) + if (!absolute_comparison_only) { return std::abs(lhs - rhs) <= epsilon * std::max(std::abs(lhs), std::abs(rhs)); } diff --git a/include/MantleAPI/Common/i_geometry_helper.h b/include/MantleAPI/Common/i_geometry_helper.h index 44f895c4d6c4c2163bec48f25d5b3582db203394..3f8c98deaa24e2a268902244611298f2d0d06d41 100644 --- a/include/MantleAPI/Common/i_geometry_helper.h +++ b/include/MantleAPI/Common/i_geometry_helper.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_geometry_helper.h */ +/// @file i_geometry_helper.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_I_GEOMETRY_HELPER_H @@ -21,6 +21,7 @@ namespace mantle_api { + /// Interface that provides functionality to perform geometrical calculations class IGeometryHelper { diff --git a/include/MantleAPI/Common/i_identifiable.h b/include/MantleAPI/Common/i_identifiable.h index 52ab357099585e8b3d463b29abea7c798f56b7c9..19b9e821376f05325d7af2ba693106b0d9b13fd8 100644 --- a/include/MantleAPI/Common/i_identifiable.h +++ b/include/MantleAPI/Common/i_identifiable.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_identifiable.h */ +/// @file i_identifiable.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_I_IDENTIFIABLE_H @@ -21,6 +21,7 @@ namespace mantle_api { + using UniqueId = std::uint64_t; ///< Container for unique id constexpr UniqueId InvalidId{std::numeric_limits<UniqueId>::max()}; ///< 'invalid' id diff --git a/include/MantleAPI/Common/i_logger.h b/include/MantleAPI/Common/i_logger.h index 88e0c40e45ddfc779fe2150e858891a5ff737fbe..b5c72f39657054d986aa63c233c7f431d2223270 100644 --- a/include/MantleAPI/Common/i_logger.h +++ b/include/MantleAPI/Common/i_logger.h @@ -9,15 +9,27 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ +//----------------------------------------------------------------------------- +/// @file MantleAPI/Common/i_logger.h +//----------------------------------------------------------------------------- + #ifndef MANTLEAPI_COMMON_I_LOGGER_H #define MANTLEAPI_COMMON_I_LOGGER_H #include <string_view> +/// MantleAPI namespace namespace mantle_api { -/// Log levels for the logging interface +/// @defgroup logging Logging +/// Logging related classes and utilities +/// @startuml +/// !include logging.puml!0 +/// @enduml + +/// Log level definition for ILogger +/// @ingroup logging enum class LogLevel : int { kTrace = 0, ///< Step by step execution messages for intensive debugging @@ -29,6 +41,7 @@ enum class LogLevel : int }; /// Interface for logging messages +/// @ingroup logging class ILogger { public: diff --git a/include/MantleAPI/Common/log_utils.h b/include/MantleAPI/Common/log_utils.h index 4be6cd39fe91527061e416a16712294b86dc86d4..6e23967b191c07b1569ff69c50931eb90566fbf9 100644 --- a/include/MantleAPI/Common/log_utils.h +++ b/include/MantleAPI/Common/log_utils.h @@ -9,6 +9,10 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ +//----------------------------------------------------------------------------- +/// @file MantleAPI/Common/log_utils.h +//----------------------------------------------------------------------------- + #ifndef MANTLEAPI_COMMON_LOG_UTILS_H #define MANTLEAPI_COMMON_LOG_UTILS_H @@ -19,14 +23,22 @@ #include <ostream> #include <string_view> +/// MantleAPI namespace namespace mantle_api { +/// Log utilities namespace namespace log_utils { +/// Array of log level names +/// @ingroup logging static inline constexpr auto kLogLevelNames = std::array<std::string_view, 6U>{"Trace", "Debug", "Info", "Warning", "Error", "Critical"}; +/// Convert a log level to its name +/// @param[in] level The log level +/// @return The name of the log level +/// @ingroup logging [[nodiscard]] constexpr std::string_view ToStringView(LogLevel level) noexcept { return (level >= LogLevel::kTrace && level <= LogLevel::kCritical) ? kLogLevelNames.at(static_cast<std::size_t>(level)) : "Log level out of range"; @@ -34,6 +46,8 @@ static inline constexpr auto kLogLevelNames = std::array<std::string_view, 6U>{" } // namespace log_utils +/// Stream operator for log level +/// @ingroup logging inline std::ostream& operator<<(std::ostream& os, mantle_api::LogLevel level) noexcept { os << log_utils::ToStringView(level); diff --git a/include/MantleAPI/Common/orientation.h b/include/MantleAPI/Common/orientation.h index 06a515d5936310afff3a582d532a99149e7fbdbc..432bdc11114e158553fbdda08da5d5437efbbcdb 100644 --- a/include/MantleAPI/Common/orientation.h +++ b/include/MantleAPI/Common/orientation.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file orientation.h */ +/// @file orientation.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_ORIENTATION_H @@ -21,6 +21,7 @@ namespace mantle_api { + template <typename T, class = typename std::enable_if_t<units::traits::is_angle_unit<T>::value || units::traits::is_angular_velocity_unit<T>::value || diff --git a/include/MantleAPI/Common/poly_line.h b/include/MantleAPI/Common/poly_line.h index 6e301b033d5de1906ad78ac64e639f92e0780f6d..c28c40a1c432d14820f372704490ed60773f9cb1 100644 --- a/include/MantleAPI/Common/poly_line.h +++ b/include/MantleAPI/Common/poly_line.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file poly_line.h */ +/// @file poly_line.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_POLY_LINE_H @@ -23,11 +23,12 @@ namespace mantle_api { + /// This struct represents the point of a polygonal chain (polyline) trajectory specification struct PolyLinePoint { - Pose pose{}; ///< Pose of the PolyLinePoint - std::optional<Time> time{}; ///< Time specification of the PolyLinePoint + Pose pose{}; ///< Pose of the PolyLinePoint + std::optional<Time> time{}; ///< Time specification of the PolyLinePoint /// @brief Equality comparison for PolyLinePoint. /// @@ -66,4 +67,4 @@ using PolyLine = std::vector<PolyLinePoint>; } // namespace mantle_api -#endif // MANTLEAPI_COMMON_POLY_LINE_H \ No newline at end of file +#endif // MANTLEAPI_COMMON_POLY_LINE_H diff --git a/include/MantleAPI/Common/pose.h b/include/MantleAPI/Common/pose.h index 35fef7c693dbb525b964f22437c11c4ea374aee2..5bbaf6a5f6c68152384474a96c3514d767f81ea9 100644 --- a/include/MantleAPI/Common/pose.h +++ b/include/MantleAPI/Common/pose.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file pose.h */ +/// @file pose.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_POSE_H @@ -23,6 +23,7 @@ namespace mantle_api { + /// Pose in the Cartesian coordinate system struct Pose { diff --git a/include/MantleAPI/Common/position.h b/include/MantleAPI/Common/position.h index 0befbc214ecb9961a394b09cddb7a248c27462ae..6e9dc2c1bbc4573eed4dec2e3b8d18880355a968 100644 --- a/include/MantleAPI/Common/position.h +++ b/include/MantleAPI/Common/position.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file position.h */ +/// @file position.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_POSITION_H @@ -17,10 +17,10 @@ #include <MantleAPI/Common/floating_point_helper.h> #include <MantleAPI/Common/vector.h> -#include <cmath> +#include <units.h> + #include <cstdint> #include <string> -#include <units.h> #include <variant> namespace mantle_api diff --git a/include/MantleAPI/Common/route_definition.h b/include/MantleAPI/Common/route_definition.h index f1ab172c0fd41f4a1eca00ce8d19da3ccc80cc09..6dfc890b46465cfb1a19509d344d945977bfbe2e 100644 --- a/include/MantleAPI/Common/route_definition.h +++ b/include/MantleAPI/Common/route_definition.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file route_definition.h */ +/// @file route_definition.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_ROUTE_DEFINITION_H @@ -25,7 +25,7 @@ namespace mantle_api { -/// Defines how a route should be calculated +/// Define how the route from a waypoint forward should be calculated. enum class RouteStrategy { kUndefined = 0, @@ -34,7 +34,7 @@ enum class RouteStrategy kShortest }; -/// Groups a Waypoint with a RouteStrategy +/// Group a Waypoint with a RouteStrategy. struct RouteWaypoint { /// Reference position used to form a route @@ -43,7 +43,7 @@ struct RouteWaypoint RouteStrategy route_strategy{}; }; -/// @brief Equality comparison for RouteWaypoint +/// Equality comparison for RouteWaypoint. /// /// @param[in] lhs The left-hand side value for the comparison /// @param[in] rhs The right-hand side value for the comparison @@ -53,7 +53,7 @@ inline bool operator==(const RouteWaypoint& lhs, const RouteWaypoint& rhs) noexc return std::tie(lhs.waypoint, lhs.route_strategy) == std::tie(rhs.waypoint, rhs.route_strategy); } -/// @brief Inequality comparison for RouteWaypoint +/// Inequality comparison for RouteWaypoint. /// /// @param[in] lhs The left-hand side value for the comparison /// @param[in] rhs The right-hand side value for the comparison @@ -63,15 +63,15 @@ inline bool operator!=(const RouteWaypoint& lhs, const RouteWaypoint& rhs) noexc return !(lhs == rhs); } -/// Serves as a raw set of global coordinates and information for -/// linking them, from which the actual route can be calculated +/// A raw set of global coordinates and information for +/// linking them, from which the actual route can be calculated. struct RouteDefinition { /// The list of waypoints with associated RouteStrategies - std::vector<mantle_api::RouteWaypoint> waypoints{}; + std::vector<mantle_api::RouteWaypoint> waypoints; }; -/// @brief Equality comparison for RouteDefinition. +/// Equality comparison for RouteDefinition. /// /// @param[in] lhs The left-hand side value for the comparison /// @param[in] rhs The right-hand side value for the comparison @@ -81,7 +81,7 @@ inline bool operator==(const RouteDefinition& lhs, const RouteDefinition& rhs) n return lhs.waypoints == rhs.waypoints; } -/// @brief Inequality comparison for RouteDefinition. +/// Inequality comparison for RouteDefinition. /// /// @param[in] lhs The left-hand side value for the comparison /// @param[in] rhs The right-hand side value for the comparison diff --git a/include/MantleAPI/Common/spline.h b/include/MantleAPI/Common/spline.h index 36f8f186e119f19a50e069e2a9a01969c004efca..250e7d6f335fdbab68190aec7015699e97a8ca72 100644 --- a/include/MantleAPI/Common/spline.h +++ b/include/MantleAPI/Common/spline.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file spline.h */ +/// @file spline.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_SPLINE_H diff --git a/include/MantleAPI/Common/time_utils.h b/include/MantleAPI/Common/time_utils.h index 6c12effdf806aa5aa0b49f697fb38508b93d0520..fbdb5f86509d7e1f815f680f78239f2eeae77562 100644 --- a/include/MantleAPI/Common/time_utils.h +++ b/include/MantleAPI/Common/time_utils.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file time_utils.h */ +/// @file time_utils.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_TIME_UTILS_H @@ -21,7 +21,8 @@ namespace mantle_api { -using Time = units::time::millisecond_t; ///< Time in ms + +using Time = units::time::millisecond_t; ///< Time in ms /// @brief Converts input in [s] to @cond \ref Time @endcond. /// @tparam T Input type, e.g. `double`. diff --git a/include/MantleAPI/Common/trajectory.h b/include/MantleAPI/Common/trajectory.h index cd001a6fe6efc99b473766a5a11f0425a8b08522..0dbb0c880e7815cbf0fb27d6eda10fb13e657401 100644 --- a/include/MantleAPI/Common/trajectory.h +++ b/include/MantleAPI/Common/trajectory.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file trajectory.h */ +/// @file trajectory.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_TRAJECTORY_H @@ -22,6 +22,7 @@ namespace mantle_api { + /// Definition of a trajectory type in terms of shape struct Trajectory { @@ -59,4 +60,4 @@ inline std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory) } // namespace mantle_api -#endif // MANTLEAPI_COMMON_TRAJECTORY_H \ No newline at end of file +#endif // MANTLEAPI_COMMON_TRAJECTORY_H diff --git a/include/MantleAPI/Common/unit_definitions.h b/include/MantleAPI/Common/unit_definitions.h index a8bc2cbd04f14470c25ca9c498678188572f232f..c3b6693197b7f01e7b88d635e0ccad31bf1f4668 100644 --- a/include/MantleAPI/Common/unit_definitions.h +++ b/include/MantleAPI/Common/unit_definitions.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file unit_definitions.h */ +/// @file unit_definitions.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_UNIT_DEFINITIONS_H diff --git a/include/MantleAPI/Common/vector.h b/include/MantleAPI/Common/vector.h index fddef77fa445715503cd91ae24fb9b640c269cfd..8b878f51cd1f3668dd5152c9fac62b664100fcc6 100644 --- a/include/MantleAPI/Common/vector.h +++ b/include/MantleAPI/Common/vector.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file vector.h */ +/// @file vector.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_VECTOR_H @@ -17,8 +17,6 @@ #include <MantleAPI/Common/floating_point_helper.h> -#include <cstdint> - namespace mantle_api { @@ -39,9 +37,9 @@ struct Vec3 { } - T x{0}; ///< x-component - T y{0}; ///< y-component - T z{0}; ///< z-component + T x{0}; ///< x-component + T y{0}; ///< y-component + T z{0}; ///< z-component /// @brief Returns length of the vector /// diff --git a/include/MantleAPI/EnvironmentalConditions/road_condition.h b/include/MantleAPI/EnvironmentalConditions/road_condition.h index 41c66cd3aac41e8b9aa540fd12393c41fa5e62d1..1140aaeeb57831cd9e90a4d8ce5b1b4edda6f4ca 100644 --- a/include/MantleAPI/EnvironmentalConditions/road_condition.h +++ b/include/MantleAPI/EnvironmentalConditions/road_condition.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file road_condition.h */ +/// @file road_condition.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_ROAD_CONDITION_H @@ -20,6 +20,7 @@ namespace mantle_api { + /// Definition of the position of the rectangle struct Rectangle { @@ -37,5 +38,7 @@ struct FrictionPatch /// Percentage of road friction units::concentration::percent_t friction{100.0}; }; + } // namespace mantle_api + #endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_ROAD_CONDITION_H diff --git a/include/MantleAPI/EnvironmentalConditions/weather.h b/include/MantleAPI/EnvironmentalConditions/weather.h index 4817d77cef9d0543012ca3090961c08e9f990f4d..af3200b090c44b76664c4d134d45b1bf876c639c 100644 --- a/include/MantleAPI/EnvironmentalConditions/weather.h +++ b/include/MantleAPI/EnvironmentalConditions/weather.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file weather.h */ +/// @file weather.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_WEATHER_H @@ -19,6 +19,7 @@ namespace mantle_api { + /// Specify the amount of the precipitation. enum class Precipitation { diff --git a/include/MantleAPI/Execution/i_environment.h b/include/MantleAPI/Execution/i_environment.h index 2ab006863a4344823884899a762c69be03bc0922..235b6312ef3cc3e5a140c511def54c7f341d6433 100644 --- a/include/MantleAPI/Execution/i_environment.h +++ b/include/MantleAPI/Execution/i_environment.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_environment.h */ +/// @file i_environment.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_EXECUTION_I_ENVIRONMENT_H diff --git a/include/MantleAPI/Execution/i_environment_engine.h b/include/MantleAPI/Execution/i_environment_engine.h index f2958d8962b2e9a0e281f05bd373ae5d6111238d..f99d65ad7f54787fee332bb7406cb49a97763547 100644 --- a/include/MantleAPI/Execution/i_environment_engine.h +++ b/include/MantleAPI/Execution/i_environment_engine.h @@ -8,12 +8,17 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ +//----------------------------------------------------------------------------- +/// @file i_environment_engine.h +//----------------------------------------------------------------------------- + #ifndef MANTLEAPI_EXECUTION_I_ENVIRONMENT_ENGINE_H #define MANTLEAPI_EXECUTION_I_ENVIRONMENT_ENGINE_H #include <MantleAPI/Execution/i_environment.h> #include <MantleAPI/Execution/i_steppable.h> +/// MantleAPI namespace namespace mantle_api { diff --git a/include/MantleAPI/Execution/i_scenario_engine.h b/include/MantleAPI/Execution/i_scenario_engine.h index 4560f4f0b90650cfd8458348d12dc5405e7310ee..8ad78922ab2ceb3237a0b242df9007181596d53e 100644 --- a/include/MantleAPI/Execution/i_scenario_engine.h +++ b/include/MantleAPI/Execution/i_scenario_engine.h @@ -11,7 +11,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_scenario_engine.h */ +/// @file i_scenario_engine.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_EXECUTION_I_SCENARIO_ENGINE_H diff --git a/include/MantleAPI/Execution/i_steppable.h b/include/MantleAPI/Execution/i_steppable.h index 84406c039acb01ae532b87b1174d55914e6413ca..703c3fa46bde88cebdf95b22be0df66ba647bb0b 100644 --- a/include/MantleAPI/Execution/i_steppable.h +++ b/include/MantleAPI/Execution/i_steppable.h @@ -8,6 +8,10 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ +//----------------------------------------------------------------------------- +/// @file i_steppable.h +//----------------------------------------------------------------------------- + #ifndef MANTLEAPI_EXECUTION_I_STEPPABLE_H #define MANTLEAPI_EXECUTION_I_STEPPABLE_H @@ -15,6 +19,7 @@ #include <optional> +/// MantleAPI namespace namespace mantle_api { diff --git a/include/MantleAPI/Execution/scenario_info.h b/include/MantleAPI/Execution/scenario_info.h index 7279b7eb784c892ebc166ffaf2b0e7b55f048cf4..b6bc56774125e5b20efff0e154a7f4d2842d9471 100644 --- a/include/MantleAPI/Execution/scenario_info.h +++ b/include/MantleAPI/Execution/scenario_info.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file scenario_info.h */ +/// @file scenario_info.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_EXECUTION_SCENARIO_INFO_H @@ -24,6 +24,7 @@ namespace mantle_api { + /// Information about the scenario struct ScenarioInfo { @@ -71,7 +72,7 @@ struct ScenarioInfo ~ScenarioInfo() = default; /// Duration of the scenario timeout - Time scenario_timeout_duration; + Time scenario_timeout_duration{}; /// Specific description of the scenario std::string description; /// Absolute path to the map diff --git a/include/MantleAPI/Map/i_coord_converter.h b/include/MantleAPI/Map/i_coord_converter.h index 53952583dd63170aff83bc114d1f9fd100e3f7d1..b261986e06f4b6d92114a592c6f72b58a5ecf042 100644 --- a/include/MantleAPI/Map/i_coord_converter.h +++ b/include/MantleAPI/Map/i_coord_converter.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_coord_converter.h */ +/// @file i_coord_converter.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_MAP_I_COORD_CONVERTER_H @@ -21,6 +21,7 @@ namespace mantle_api { + /// Interface that provides functionality to query the underlying map with regard to transformation of different /// position types, curvature, elevation etc. class ICoordConverter diff --git a/include/MantleAPI/Map/i_lane_location_query_service.h b/include/MantleAPI/Map/i_lane_location_query_service.h index 7e34088205672b58eff2f433f539b1573d9e8f1c..fad37f9181e60837193526b520f4f470662bd765 100644 --- a/include/MantleAPI/Map/i_lane_location_query_service.h +++ b/include/MantleAPI/Map/i_lane_location_query_service.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_lane_location_query_service.h */ +/// @file i_lane_location_query_service.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_MAP_I_LANE_LOCATION_QUERY_SERVICE_H diff --git a/include/MantleAPI/Map/i_route.h b/include/MantleAPI/Map/i_route.h index f52bb147dfb7fef0b15e0aa051171da8611a742d..80357e6910983a0b5d21b74feeaa756fe5963983 100644 --- a/include/MantleAPI/Map/i_route.h +++ b/include/MantleAPI/Map/i_route.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_route.h */ +/// @file i_route.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_MAP_I_ROUTE_H @@ -50,14 +50,14 @@ public: LaneId lane_id, units::length::meter_t lane_offset = units::length::meter_t{ 0.0}) const = 0; - + /// Returns interpolated value for the width of the lane at the given position /// /// @param lane_id ID of lane to search in /// @param route_pos s coordinate of search start /// @return width at position [[nodiscard]] virtual units::length::meter_t GetLaneWidth(units::length::meter_t route_pos, LaneId lane_id) const = 0; - + /// Returns ID of the lane that encloses the passed in position within its shape /// /// @param inert_pos Position to search for the Lane ID diff --git a/include/MantleAPI/Map/lane_definition.h b/include/MantleAPI/Map/lane_definition.h index e651178c83062cca7f37434f66908fa6ef0dd386..13d278a5b2c2060ceee2c77616839a9a94e70474 100644 --- a/include/MantleAPI/Map/lane_definition.h +++ b/include/MantleAPI/Map/lane_definition.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file route_definition.h */ +/// @file lane_definition.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_MAP_LANE_DEFINITION_H @@ -17,6 +17,7 @@ #include <cstdint> +/// MantleAPI namespace namespace mantle_api { diff --git a/include/MantleAPI/Map/map_details.h b/include/MantleAPI/Map/map_details.h index 0d7ad9696b6583292b60978b534f1c4f07e375b8..ad53ed487d5fce53066e8b28b9fd5efa8deb9e2e 100644 --- a/include/MantleAPI/Map/map_details.h +++ b/include/MantleAPI/Map/map_details.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file map_details.h */ +/// @file map_details.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_MAP_MAP_DETAILS_H @@ -22,6 +22,7 @@ namespace mantle_api { + /// Definition of the map area struct MapDetails { @@ -29,7 +30,7 @@ struct MapDetails /// Cloning MapDetails for usage as unique ptr in ScenarioInfo. Can be overwritten in derived classes. /// @return Copy of MapDetails - virtual std::unique_ptr<MapDetails> Clone() const + [[nodiscard]] virtual std::unique_ptr<MapDetails> Clone() const { return std::make_unique<MapDetails>(*this); } @@ -39,4 +40,5 @@ struct MapDetails }; } // namespace mantle_api + #endif // MANTLEAPI_MAP_MAP_DETAILS_H diff --git a/include/MantleAPI/Traffic/control_strategy.h b/include/MantleAPI/Traffic/control_strategy.h index c76a152b578c6f8986a74a7f0076f0c1a99f0fdc..a79f04317aedf94ddd22b9ae2e37aaa4d9de1be7 100644 --- a/include/MantleAPI/Traffic/control_strategy.h +++ b/include/MantleAPI/Traffic/control_strategy.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file control_strategy.h */ +/// @file control_strategy.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_CONTROL_STRATEGY_H @@ -249,8 +249,8 @@ struct FollowTrajectoryControlStrategy : public ControlStrategy { /// Specification of the time domain (absolute or relative) ReferenceContext domainAbsoluteRelative{ReferenceContext::kAbsolute}; - /// Scaling factor for time values. - /// While values smaller than 1.0 represent negative scaling, values larger than 1.0 will result in positive scaling. + /// Scaling factor for time values. + /// While values smaller than 1.0 represent negative scaling, values larger than 1.0 will result in positive scaling. /// A value of 1.0 means no scaling. double scale{1.0}; /// Global offset for all time values diff --git a/include/MantleAPI/Traffic/default_routing_behavior.h b/include/MantleAPI/Traffic/default_routing_behavior.h index 137783928c67a1edbc466a016c06c51e86da5ade..215a845491c9de4f9e2123a283b685ee1a93b1fb 100644 --- a/include/MantleAPI/Traffic/default_routing_behavior.h +++ b/include/MantleAPI/Traffic/default_routing_behavior.h @@ -8,18 +8,24 @@ * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ +//----------------------------------------------------------------------------- +/// @file default_routing_behavior.h +//----------------------------------------------------------------------------- + #ifndef MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H #define MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H -namespace mantle_api { +/// MantleAPI namespace +namespace mantle_api +{ /// Specify behavior to end of route enum class DefaultRoutingBehavior { - kStop, ///< Do nothing - kRandomRoute ///< Randomly select where to go next + kStop, ///< Do nothing + kRandomRoute ///< Randomly select where to go next }; } // namespace mantle_api -#endif // MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H \ No newline at end of file +#endif // MANTLEAPI_TRAFFIC_DEFAULT_ROUTING_BEHAVIOR_H diff --git a/include/MantleAPI/Traffic/entity_helper.h b/include/MantleAPI/Traffic/entity_helper.h index 85ffe60c35bdf04e8572e67b7104d5f36c75920a..65bd5a81367070cd14f50573a94bb0d525c7e309 100644 --- a/include/MantleAPI/Traffic/entity_helper.h +++ b/include/MantleAPI/Traffic/entity_helper.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file entity_helper.h */ +/// @file entity_helper.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_ENTITY_HELPER_H @@ -18,8 +18,6 @@ #include <MantleAPI/Common/floating_point_helper.h> #include <MantleAPI/Traffic/i_entity.h> -#include <cmath> - namespace mantle_api { diff --git a/include/MantleAPI/Traffic/entity_properties.h b/include/MantleAPI/Traffic/entity_properties.h index 17e5b1d147803378d9170ac0989d35a00d1d1293..780e9b1d2fac4075e3afe6761e2f81c4b60cf705 100644 --- a/include/MantleAPI/Traffic/entity_properties.h +++ b/include/MantleAPI/Traffic/entity_properties.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file entity_properties.h */ +/// @file entity_properties.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_ENTITY_PROPERTIES_H diff --git a/include/MantleAPI/Traffic/i_controller.h b/include/MantleAPI/Traffic/i_controller.h index e8ed0ef6b15e30bf1d17aa3a8a4608fe83f38ad6..4afd7b91f1e00c6a27a145bc99bd6229718d2a35 100644 --- a/include/MantleAPI/Traffic/i_controller.h +++ b/include/MantleAPI/Traffic/i_controller.h @@ -1,6 +1,3 @@ -#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_H -#define MANTLEAPI_TRAFFIC_I_CONTROLLER_H - /******************************************************************************** * Copyright (c) 2021 in-tech GmbH * 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) @@ -13,17 +10,18 @@ ********************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_controller.h */ +/// @file i_controller.h //----------------------------------------------------------------------------- +#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_H +#define MANTLEAPI_TRAFFIC_I_CONTROLLER_H #pragma once -#include <optional> - #include "MantleAPI/Common/i_identifiable.h" namespace mantle_api { + /// Base interface for all controllers. class IController : public virtual IIdentifiable { @@ -51,4 +49,5 @@ public: }; } // namespace mantle_api -#endif + +#endif // MANTLEAPI_TRAFFIC_I_CONTROLLER_H diff --git a/include/MantleAPI/Traffic/i_controller_config.h b/include/MantleAPI/Traffic/i_controller_config.h index 1e29b041f16c80adfe463c429063118673a5c622..8ba999f08dddff1a81def7a978d3521bcabf7267 100644 --- a/include/MantleAPI/Traffic/i_controller_config.h +++ b/include/MantleAPI/Traffic/i_controller_config.h @@ -10,7 +10,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_controller_config.h */ +/// @file i_controller_config.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_CONFIG_H @@ -22,7 +22,6 @@ #include <MantleAPI/Map/i_lane_location_query_service.h> #include <MantleAPI/Traffic/control_strategy.h> -#include <algorithm> #include <map> #include <memory> #include <vector> diff --git a/include/MantleAPI/Traffic/i_controller_repository.h b/include/MantleAPI/Traffic/i_controller_repository.h index fe0deb10c8378b10b560c86bb1746c9f6b92cc28..13c0d672330d6ea7b448e017aa59fc94c6a7759d 100644 --- a/include/MantleAPI/Traffic/i_controller_repository.h +++ b/include/MantleAPI/Traffic/i_controller_repository.h @@ -1,6 +1,3 @@ -#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H -#define MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H - /******************************************************************************** * Copyright (c) 2021 in-tech GmbH * 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) @@ -13,23 +10,27 @@ ********************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_controller_repository.h */ +/// @file i_controller_repository.h //----------------------------------------------------------------------------- +#ifndef MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H +#define MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H #pragma once -#include "MantleAPI/Traffic/i_controller_config.h" #include "MantleAPI/Traffic/i_controller.h" +#include "MantleAPI/Traffic/i_controller_config.h" namespace mantle_api { /// This interface provides CRUD functionality for controllers. -/// Controller, which is assigned to exactly one entity, controls that one entity by enforcing the behavior prescribed by +/// Controller, which is assigned to exactly one entity, controls that one entity by enforcing the behavior prescribed by /// the control strategies assigned to that entity. /// Multiple controllers can be assigned to an entity, but only one controller can be activated for an entity at a time. class IControllerRepository { public: + virtual ~IControllerRepository() = default; + /// Creates a new controller for the entity /// /// @param config Controller config @@ -41,7 +42,7 @@ public: /// @param id Unique ID of the controller /// @param config Controller config /// @return newly created controller for the entity - [[deprecated]] virtual IController& Create(UniqueId id, std::unique_ptr<IControllerConfig> config) = 0; // deprecated + [[deprecated]] virtual IController& Create(UniqueId id, std::unique_ptr<IControllerConfig> config) = 0; // deprecated /// Gets the controller by the given unique ID /// @@ -68,4 +69,5 @@ public: }; } // namespace mantle_api -#endif + +#endif // MANTLEAPI_TRAFFIC_I_CONTROLLER_REPOSITORY_H diff --git a/include/MantleAPI/Traffic/i_entity.h b/include/MantleAPI/Traffic/i_entity.h index 4ae35654394a0abbf9b85988a66f36c784129553..f3ce582c58813d9ec93a51f538df5f9396230899 100644 --- a/include/MantleAPI/Traffic/i_entity.h +++ b/include/MantleAPI/Traffic/i_entity.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_entity.h */ +/// @file i_entity.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_I_ENTITY_H diff --git a/include/MantleAPI/Traffic/i_entity_repository.h b/include/MantleAPI/Traffic/i_entity_repository.h index 8c07355da15457306e205507adba6331de99b2fb..cfaeafb9b6fc982599d1615c174cf1372ffd583f 100644 --- a/include/MantleAPI/Traffic/i_entity_repository.h +++ b/include/MantleAPI/Traffic/i_entity_repository.h @@ -9,7 +9,7 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_entity_repository.h */ +/// @file i_entity_repository.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_I_ENTITY_REPOSITORY_H @@ -25,10 +25,13 @@ namespace mantle_api { + /// This interface provides CRUD functionality for scenario entities. class IEntityRepository { public: + virtual ~IEntityRepository() = default; + /// Creates a new dynamic scenario entity of vehicle type /// /// @param name The name of the entity to be created diff --git a/include/MantleAPI/Traffic/i_traffic_swarm_service.h b/include/MantleAPI/Traffic/i_traffic_swarm_service.h index 5325514d69d84ec35b7a0ac0dee407f0da84c0e4..59fdb07eb87facb64702f0cc798df79faa629589 100644 --- a/include/MantleAPI/Traffic/i_traffic_swarm_service.h +++ b/include/MantleAPI/Traffic/i_traffic_swarm_service.h @@ -9,84 +9,90 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file i_traffic_swarm_service.h */ +/// @file i_traffic_swarm_service.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_I_TRAFFIC_SWARM_CONTROLLER_H #define MANTLEAPI_TRAFFIC_I_TRAFFIC_SWARM_CONTROLLER_H -#include <vector> -#include <MantleAPI/Common/vector.h> #include <MantleAPI/Common/pose.h> +#include <MantleAPI/Common/vector.h> #include <units.h> +#include <memory> +#include <vector> + +#include "MantleAPI/Traffic/entity_properties.h" +#include "MantleAPI/Traffic/i_controller_config.h" + namespace mantle_api { /// This struct represents the parameters of the swarm traffic struct TrafficSwarmParameters { - /// The range for the lower and upper limit of the entity's starting speeds - struct SpeedRange - { - units::velocity::meters_per_second_t minimum; ///< The lower limit of a speed range - units::velocity::meters_per_second_t maximum; ///< The upper limit of a speed range - }; - - /// Name of the central entity the swarm traffic is created around - std::string central_entity_name; - /// The maximum number of vehicles surrounding the central entity - size_t maximum_number_of_vehicles; - /// The starting speeds of the spawned entities - SpeedRange speed_range; - /// Radius of the inner circular area around the central entity - units::length::meter_t exclusion_radius; - /// Shape of the swarm traffic distribution area is given as an ellipsis around a central entity. - /// semi_minor_spawning_radius defines the half length of the minor axis of this ellipsis. - units::length::meter_t semi_minor_spawning_radius; - // Shape of the swarm traffic distribution area is given as an ellipsis around a central entity. - /// semi_major_spawning_radius defines the half length of the major axis of this ellipsis. - units::length::meter_t semi_major_spawning_radius; - /// Offset in longitudinal direction related to the x-axis of the central entity - units::length::meter_t spawning_area_longitudinal_offset; + /// The range for the lower and upper limit of the entity's starting speeds + struct SpeedRange + { + units::velocity::meters_per_second_t minimum; ///< The lower limit of a speed range + units::velocity::meters_per_second_t maximum; ///< The upper limit of a speed range + }; + + /// Name of the central entity the swarm traffic is created around + std::string central_entity_name; + /// The maximum number of vehicles surrounding the central entity + size_t maximum_number_of_vehicles; + /// The starting speeds of the spawned entities + SpeedRange speed_range; + /// Radius of the inner circular area around the central entity + units::length::meter_t exclusion_radius; + /// Shape of the swarm traffic distribution area is given as an ellipsis around a central entity. + /// semi_minor_spawning_radius defines the half length of the minor axis of this ellipsis. + units::length::meter_t semi_minor_spawning_radius; + // Shape of the swarm traffic distribution area is given as an ellipsis around a central entity. + /// semi_major_spawning_radius defines the half length of the major axis of this ellipsis. + units::length::meter_t semi_major_spawning_radius; + /// Offset in longitudinal direction related to the x-axis of the central entity + units::length::meter_t spawning_area_longitudinal_offset; }; /// Base interface for the swarm traffic class ITrafficSwarmService { public: - - /// Specify the relative position of the spawned vehicle to the central entity - enum class RelativePosition - { - kInFront = 0, - kBehind - }; - - /// Specify the position of the spawned vehicle - using SpawningPosition = std::pair<mantle_api::Pose, RelativePosition>; - - /// Returns available spawning poses - /// - /// @return list of poses - virtual std::vector<SpawningPosition> GetAvailableSpawningPoses() const = 0; - - /// Returns additional properties for entity objects of type vehicle - /// - /// @param vehicle_class Category of the vehicle (car, bicycle, train,...) - /// @return vehicle properties - virtual mantle_api::VehicleProperties GetVehicleProperties(mantle_api::VehicleClass vehicle_class) const = 0; - - /// Updates parameters for the controller - /// - /// @param config External controller configuration file - /// @param speed The speed of the environment controller - virtual void UpdateControllerConfig(std::unique_ptr<mantle_api::ExternalControllerConfig>& config, - units::velocity::meters_per_second_t speed) = 0; - /// Sets the number of swarm entities - /// - /// @param count number of swarm entities - virtual void SetSwarmEntitiesCount(size_t count) = 0; + virtual ~ITrafficSwarmService() = default; + + /// Specify the relative position of the spawned vehicle to the central entity + enum class RelativePosition + { + kInFront = 0, + kBehind + }; + + /// Specify the position of the spawned vehicle + using SpawningPosition = std::pair<mantle_api::Pose, RelativePosition>; + + /// Returns available spawning poses + /// + /// @return list of poses + [[nodiscard]] virtual std::vector<SpawningPosition> GetAvailableSpawningPoses() const = 0; + + /// Returns additional properties for entity objects of type vehicle + /// + /// @param vehicle_class Category of the vehicle (car, bicycle, train,...) + /// @return vehicle properties + [[nodiscard]] virtual mantle_api::VehicleProperties GetVehicleProperties(mantle_api::VehicleClass vehicle_class) const = 0; + + /// Updates parameters for the controller + /// + /// @param config External controller configuration file + /// @param speed The speed of the environment controller + virtual void UpdateControllerConfig(std::unique_ptr<mantle_api::ExternalControllerConfig>& config, + units::velocity::meters_per_second_t speed) = 0; + /// Sets the number of swarm entities + /// + /// @param count number of swarm entities + virtual void SetSwarmEntitiesCount(size_t count) = 0; }; } // namespace mantle_api diff --git a/include/MantleAPI/Traffic/traffic_light_properties.h b/include/MantleAPI/Traffic/traffic_light_properties.h index 03cff3a238da5231389c059c7bb6ff8acd216ef5..cb13783542537794dca77657338a937fb9438b02 100644 --- a/include/MantleAPI/Traffic/traffic_light_properties.h +++ b/include/MantleAPI/Traffic/traffic_light_properties.h @@ -9,13 +9,14 @@ *******************************************************************************/ //----------------------------------------------------------------------------- -/** @file traffic_light_properties.h */ +/// @file traffic_light_properties.h //----------------------------------------------------------------------------- #ifndef MANTLEAPI_TRAFFIC_TRAFFIC_LIGHT_PROPERTIES_H #define MANTLEAPI_TRAFFIC_TRAFFIC_LIGHT_PROPERTIES_H #include <MantleAPI/Common/time_utils.h> + #include <vector> namespace mantle_api @@ -24,45 +25,45 @@ namespace mantle_api /// Specify the color of a traffic light bulb. enum class TrafficLightBulbColor { - kUnknown = 0, - kOther = 1, - kRed = 2, - kYellow = 3, - kGreen = 4, - kBlue = 5, - kWhite = 6 + kUnknown = 0, + kOther = 1, + kRed = 2, + kYellow = 3, + kGreen = 4, + kBlue = 5, + kWhite = 6 }; /// Specify the mode of a traffic light bulb. enum class TrafficLightBulbMode { - kUnknown = 0, - kOther = 1, - kOff = 2, - kConstant = 3, - kFlashing = 4, - kCounting = 5 + kUnknown = 0, + kOther = 1, + kOff = 2, + kConstant = 3, + kFlashing = 4, + kCounting = 5 }; /// Definition of the traffic light state struct TrafficLightBulbState { - /// Color of the traffic light bulb - TrafficLightBulbColor color; - /// Indication if a traffic light should be switched on, off or flashing - TrafficLightBulbMode mode; + /// Color of the traffic light bulb + TrafficLightBulbColor color; + /// Indication if a traffic light should be switched on, off or flashing + TrafficLightBulbMode mode; }; /// Definition of the specific phase of a traffic light struct TrafficLightPhase { - /// State of a traffic signal for this phase - /// e.g. the visual information "off;off;on" for a vehicle traffic signal - std::vector<TrafficLightBulbState> bulb_states; - /// Time specification at the start of the phase - mantle_api::Time start_time{0}; - /// Time specification at the end of the phase - mantle_api::Time end_time{0}; + /// State of a traffic signal for this phase + /// e.g. the visual information "off;off;on" for a vehicle traffic signal + std::vector<TrafficLightBulbState> bulb_states; + /// Time specification at the start of the phase + mantle_api::Time start_time{0}; + /// Time specification at the end of the phase + mantle_api::Time end_time{0}; }; } // namespace mantle_api