Skip to content
Snippets Groups Projects
Verified Commit 2c04a98c authored by Martin Stump's avatar Martin Stump
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://gitlab.eclipse.org/eclipse/simopenpass/scenario_api into add-clang-tidy-config
parents b49fbdb5 0e80917f
No related branches found
No related tags found
No related merge requests found
Showing
with 238 additions and 111 deletions
......@@ -13,6 +13,13 @@ line_ending: unix
command_case: canonical
keyword_case: upper
additional_commands:
CPMAddPackage:
kwargs:
NAME: "*"
GITHUB_REPOSITORY: "*"
GIT_TAG: "*"
VERSION: "*"
OPTIONS: "*"
configure_package_config_file:
flags:
- NO_SET_AND_CHECK_MACRO
......@@ -47,7 +54,7 @@ additional_commands:
EXECUTABLE: "*"
EXECUTABLE_ARGS: "*"
DEPENDENCIES: "*"
always_wrap: ["add_library", "find_package", "find_dependency", "target_include_directories"]
always_wrap: []
enable_sort: true
autosort: false
hashruler_min_length: 10
......
.cache/
.vscode/
build/
compile_commands.json
File moved
################################################################################
# Copyright (c) 2021 Daimler TSS GmbH
# Copyright (c) 2022 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
......@@ -13,29 +14,131 @@ cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Add the custom CMake modules to CMake's module path
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Determine if MantleAPI is built as a subproject (using add_subdirectory) or if it is the main project.
if(NOT DEFINED MantleAPI_MAIN_PROJECT)
set(MantleAPI_MAIN_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(MantleAPI_MAIN_PROJECT ON)
endif()
endif()
project(
ScenarioAPI
MantleAPI
VERSION 0.1.0
DESCRIPTION "Scenario API, an abstraction layer for environmental simulators"
DESCRIPTION "MantleAPI, an abstraction layer for environmental simulators"
LANGUAGES CXX
)
# Project setup only if this is the main project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(CTest)
option(BUILD_DOCUMENTATION "Build the documentation tree." OFF)
# Options that control generation of various targets.
option(MantleAPI_DOC "Generate the doc target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_INSTALL "Generate the install target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_TEST "Generate the test target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_PACKAGE "Generate the package target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_ENABLE_WARNINGS "Enable compiler warnings." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_ENABLE_WERROR "Fail and stop if a warning is triggered." ${MantleAPI_MAIN_PROJECT})
if(MSVC)
if(MantleAPI_ENABLE_WARNINGS)
add_compile_options(/W4)
endif()
if(MantleAPI_ENABLE_WERROR)
add_compile_options(/WX /wd4996)
endif()
else()
if(MantleAPI_ENABLE_WARNINGS)
add_compile_options(-Wall -Wextra)
endif()
if(MantleAPI_ENABLE_WERROR)
add_compile_options(-Werror -Wno-error=deprecated-declarations)
endif()
endif()
# Go into the actual project
add_subdirectory(MantleAPI)
# Fetch dependencies
include(CPM)
CPMAddPackage(
NAME units
GITHUB_REPOSITORY nholthaus/units
GIT_TAG v2.3.3
VERSION 2.3.3
OPTIONS "DISABLE_PREDEFINED_UNITS ON"
"ENABLE_PREDEFINED_ACCELERATION_UNITS ON"
"ENABLE_PREDEFINED_ANGLE_UNITS ON"
"ENABLE_PREDEFINED_ANGULAR_VELOCITY_UNITS ON"
"ENABLE_PREDEFINED_CONCENTRATION_UNITS ON"
"ENABLE_PREDEFINED_FORCE_UNITS ON"
"ENABLE_PREDEFINED_LENGTH_UNITS ON"
"ENABLE_PREDEFINED_MASS_UNITS ON"
"ENABLE_PREDEFINED_PRESSURE_UNITS ON"
"ENABLE_PREDEFINED_TEMPERATURE_UNITS ON"
"ENABLE_PREDEFINED_TIME_UNITS ON"
"ENABLE_PREDEFINED_VELOCITY_UNITS ON"
)
# Add library
file(
GLOB_RECURSE HEADERS
RELATIVE ${PROJECT_SOURCE_DIR}/include
CONFIGURE_DEPENDS "*.h"
)
add_library(MantleAPI INTERFACE)
add_library(MantleAPI::MantleAPI ALIAS MantleAPI)
target_link_libraries(MantleAPI INTERFACE units::units)
include(GNUInstallDirs)
set(INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/MantleAPI")
target_include_directories(
MantleAPI INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(MantleAPI INTERFACE cxx_std_17)
# Configure export
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/MantleAPIConfig.cmake.in" "${PROJECT_BINARY_DIR}/MantleAPIConfig.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/MantleAPIConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
# Configure install
if(MantleAPI_INSTALL)
install(DIRECTORY include/ TYPE INCLUDE)
install(TARGETS MantleAPI EXPORT MantleAPITargets)
# Should we build documentation for the project?
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_DOCUMENTATION) OR ScenarioAPI_BUILD_DOCUMENTATION)
install(
EXPORT MantleAPITargets
DESTINATION ${INSTALL_CONFIG_DIR}
NAMESPACE MantleAPI::
)
install(
FILES "${PROJECT_BINARY_DIR}/MantleAPIConfig.cmake" "${PROJECT_BINARY_DIR}/MantleAPIConfigVersion.cmake"
DESTINATION ${INSTALL_CONFIG_DIR}
COMPONENT dev
)
endif()
# Build docs
if(MantleAPI_DOC)
add_subdirectory(doc)
endif()
# Include the CPack configuration
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(ScenarioAPICPack)
# Build tests
if(MantleAPI_TEST)
enable_testing()
add_subdirectory(test)
endif()
# Configure package
if(MantleAPI_PACKAGE)
include(MantleAPICPack)
endif()
################################################################################
# Copyright (c) 2021 Daimler TSS 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_package(
units CONFIG REQUIRED
)
file(
GLOB_RECURSE HEADERS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS "*.h"
)
add_library(
ScenarioAPI INTERFACE
)
add_library(
ScenarioAPI::ScenarioAPI ALIAS ScenarioAPI
)
target_link_libraries(ScenarioAPI INTERFACE units)
include(GNUInstallDirs)
set(INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/ScenarioAPI")
target_include_directories(
ScenarioAPI
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(ScenarioAPI INTERFACE cxx_std_17)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/ScenarioAPIConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfig.cmake"
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(DIRECTORY MantleAPI TYPE INCLUDE)
install(TARGETS ScenarioAPI EXPORT ScenarioAPITargets)
install(
EXPORT ScenarioAPITargets
DESTINATION ${INSTALL_CONFIG_DIR}
NAMESPACE ScenarioAPI::
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfigVersion.cmake"
DESTINATION ${INSTALL_CONFIG_DIR}
COMPONENT dev
)
# Scenario API
# MantleAPI
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.
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.
Remark: 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.1
Version: v2.3.3
### GoogleTest
License: BSD-3-Clause License
URL: https://github.com/google/googletest
Version: v1.12.1
### CPM
License: MIT License
URL: https://github.com/cpm-cmake/CPM.cmake
Version: v0.36.0
File moved
set(CPM_DOWNLOAD_VERSION 0.36.0)
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()
include(${CPM_DOWNLOAD_LOCATION})
################################################################################
# Copyright (c) 2021 Daimler TSS GmbH
# Copyright (c) 2022 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
......@@ -8,16 +9,15 @@
# SPDX-License-Identifier: EPL-2.0
################################################################################
set(CPACK_PACKAGE_NAME "scenario_api")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "simopenpass Eclipse project team")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scenario API")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_PACKAGE_CHECKSUM SHA512)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
......
################################################################################
# Copyright (c) 2021 Daimler TSS GmbH
# Copyright (c) 2022 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
......@@ -10,11 +11,11 @@
@PACKAGE_INIT@
if(NOT TARGET ScenarioAPI::ScenarioAPI AND NOT ScenarioAPI_BINARY_DIR)
set_and_check(ScenarioAPI_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
mark_as_advanced(ScenarioAPI_INCLUDE_DIR)
include("${CMAKE_CURRENT_LIST_DIR}/ScenarioAPITargets.cmake")
endif()
include(CMakeFindDependencyMacro)
find_dependency(units)
if(NOT TARGET MantleAPI::MantleAPI AND NOT MantleAPI_BINARY_DIR)
set_and_check(MantleAPI_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
mark_as_advanced(MantleAPI_INCLUDE_DIR)
include("${CMAKE_CURRENT_LIST_DIR}/MantleAPITargets.cmake")
endif()
################################################################################
# Copyright (c) 2022 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_package(Doxygen QUIET REQUIRED dot OPTIONAL_COMPONENTS mscgen dia)
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
set(DOXYGEN_DOT_IMAGE_FORMAT svg)
set(DOXYGEN_IMAGE_PATH ${CMAKE_CURRENT_LIST_DIR}/images)
set(DOXYGEN_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_INTERACTIVE_SVG YES)
set(DOXYGEN_QUIET YES)
set(DOXYGEN_TAB_SIZE 2)
set(DOXYGEN_UML_LOOK YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
doxygen_add_docs(
${PROJECT_NAME}_doc ${PROJECT_SOURCE_DIR}/README.md ${PROJECT_SOURCE_DIR}/include COMMENT "Generate html docs"
)
......@@ -21,23 +21,30 @@
#include <cmath>
#include <cstdint>
#include <string>
#include <variant>
namespace mantle_api
{
struct ReferencedObject
struct OpenDriveRoadPosition
{
std::int32_t road{0};
std::int32_t lane{0};
/// @brief RoadId as defined in OpenDRIVE
std::string road{};
/// @brief Offset in s direction w.r.t. road, unit: [m]
units::length::meter_t s_offset{0.0};
/// @brief Offset in t direction w.r.t. reference line of road, unit: [m]
units::length::meter_t t_offset{0.0};
};
struct OpenDrivePosition
struct OpenDriveLanePosition
{
ReferencedObject referenced_object{};
/// @brief Offset in s direction, unit: [m]
/// @brief RoadId as defined in OpenDRIVE
std::string road{};
/// @brief LaneId as defined in OpenDRIVE (e.g. -1 for right lane)
std::int32_t lane{0};
/// @brief Offset in s direction w.r.t lane (same as road), unit: [m]
units::length::meter_t s_offset{0.0};
/// @brief Offset in t direction, unit: [m]
/// @brief Offset in t direction w.r.t center line of lane, unit: [m]
units::length::meter_t t_offset{0.0};
};
......@@ -49,19 +56,35 @@ struct LatLonPosition
units::angle::radian_t longitude{0.0};
};
using Position = std::variant<OpenDrivePosition, LatLonPosition, Vec3<units::length::meter_t>>;
using Position = std::variant<OpenDriveRoadPosition, OpenDriveLanePosition, LatLonPosition, Vec3<units::length::meter_t>>;
/// @brief Equality comparison for OpenDriveRoadPosition.
///
/// **Attention** Floating-point comparision may require tweaks in precision.
inline bool operator==(const OpenDriveRoadPosition& lhs, const OpenDriveRoadPosition& rhs) noexcept
{
return lhs.road == rhs.road &&
IsEqual(lhs.s_offset, rhs.s_offset) &&
IsEqual(lhs.t_offset, rhs.t_offset);
}
inline bool operator!=(const OpenDriveRoadPosition& lhs, const OpenDriveRoadPosition& rhs) noexcept
{
return !(lhs == rhs);
}
/// @brief Equality comparison for OpenDrivePosition.
/// @brief Equality comparison for OpenDriveLanePosition.
///
/// **Attention** Floating-point comparision may require tweaks in precision.
inline bool operator==(const OpenDrivePosition& lhs, const OpenDrivePosition& rhs) noexcept
inline bool operator==(const OpenDriveLanePosition& lhs, const OpenDriveLanePosition& rhs) noexcept
{
return lhs.referenced_object.road == rhs.referenced_object.road &&
lhs.referenced_object.lane == rhs.referenced_object.lane && IsEqual(lhs.s_offset, rhs.s_offset) &&
return lhs.road == rhs.road &&
lhs.lane == rhs.lane &&
IsEqual(lhs.s_offset, rhs.s_offset) &&
IsEqual(lhs.t_offset, rhs.t_offset);
}
inline bool operator!=(const OpenDrivePosition& lhs, const OpenDrivePosition& rhs) noexcept
inline bool operator!=(const OpenDriveLanePosition& lhs, const OpenDriveLanePosition& rhs) noexcept
{
return !(lhs == rhs);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment