diff --git a/MantleAPI/include/MantleAPI/Common/i_identifiable.h b/MantleAPI/include/MantleAPI/Common/i_identifiable.h index 24b6a9274e77645887a9bc142631cdc1bf8c5989..bd9f1b1b46113ff715404c9357d55723c3dac561 100644 --- a/MantleAPI/include/MantleAPI/Common/i_identifiable.h +++ b/MantleAPI/include/MantleAPI/Common/i_identifiable.h @@ -21,6 +21,7 @@ namespace mantle_api { using UniqueId = std::uint64_t; +constexpr UniqueId InvalidId{std::numeric_limits<UniqueId>::max()}; /// Common interface for all classes that can be referenced by an ID or name. class IIdentifiable diff --git a/MantleAPI/include/MantleAPI/Common/vector.h b/MantleAPI/include/MantleAPI/Common/vector.h index 86cff86bb11715d86a908dae427f2b3c851248df..498cbdc715327d9247c5459298ce3e429162ecdf 100644 --- a/MantleAPI/include/MantleAPI/Common/vector.h +++ b/MantleAPI/include/MantleAPI/Common/vector.h @@ -72,6 +72,38 @@ inline Vec3d operator/(const Vec3d& lhs, double d) noexcept return {lhs.x / d, lhs.y / d, lhs.z / d}; } +inline Vec3d operator+=(Vec3d& lhs, const Vec3d& rhs) noexcept +{ + lhs.x += rhs.x; + lhs.y += rhs.y; + lhs.z += rhs.z; + return lhs; +} + +inline Vec3d operator-=(Vec3d& lhs, const Vec3d& rhs) noexcept +{ + lhs.x -= rhs.x; + lhs.y -= rhs.y; + lhs.z -= rhs.z; + return lhs; +} + +inline Vec3d operator+=(Vec3d& lhs, double d) noexcept +{ + lhs.x += d; + lhs.y += d; + lhs.z += d; + return lhs; +} + +inline Vec3d operator-=(Vec3d& lhs, double d) noexcept +{ + lhs.x -= d; + lhs.y -= d; + lhs.z -= d; + return lhs; +} + } // namespace mantle_api #endif // MANTLEAPI_COMMON_VECTOR_H diff --git a/MantleAPI/include/MantleAPI/Execution/i_environment.h b/MantleAPI/include/MantleAPI/Execution/i_environment.h index c5e0876ff44ae1cc8b43cbab6b16f93d5c38df8b..bbd668623bd6b52eecabe34b2579f3febb15304f 100644 --- a/MantleAPI/include/MantleAPI/Execution/i_environment.h +++ b/MantleAPI/include/MantleAPI/Execution/i_environment.h @@ -35,9 +35,9 @@ class IEnvironment /// Load a map file and parse it into the memory. /// - /// @param file_path raw map file path from the scenario file. Resolving to a valid file path is done in the - /// environment. - virtual void CreateMap(const std::string& file_path, const std::vector<Position>& map_region) = 0; + /// @param file_path map file path from the scenario file. If this path is not resolved by the engine, the + /// environment must do so. + virtual void CreateMap(const std::string& map_file_path, const std::vector<Position>& map_region) = 0; /// Creates a controller from the given config. A created controller can be assigned to multiple entities /// diff --git a/MantleAPI/include/MantleAPI/Traffic/entity_helper.h b/MantleAPI/include/MantleAPI/Traffic/entity_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..28dba80691e5248c3df99b8c745967187b9fd8e7 --- /dev/null +++ b/MantleAPI/include/MantleAPI/Traffic/entity_helper.h @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * + * 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 + *******************************************************************************/ + +//----------------------------------------------------------------------------- +/** @file entity_helper.h */ +//----------------------------------------------------------------------------- + +#ifndef MANTLEAPI_TRAFFIC_ENTITY_HELPER_H +#define MANTLEAPI_TRAFFIC_ENTITY_HELPER_H + +#include <MantleAPI/Traffic/i_entity.h> + +#include <cmath> + +namespace mantle_api +{ + +void SetSpeed(mantle_api::IEntity* entity, double velocity) +{ + auto orientation = entity->GetOrientation(); + + double cos_elevation = std::cos(orientation.pitch); + mantle_api::Vec3d velocity_vector{velocity * std::cos(orientation.yaw) * cos_elevation, + velocity * std::sin(orientation.yaw) * cos_elevation, + velocity * -std::sin(orientation.pitch)}; + + entity->SetVelocity(velocity_vector); +} + +} // namespace mantle_api + +#endif // MANTLEAPI_TRAFFIC_ENTITY_HELPER_H diff --git a/MantleAPI/include/MantleAPI/Traffic/i_controller_config.h b/MantleAPI/include/MantleAPI/Traffic/i_controller_config.h index 3d2355bd7257319a89524d67c29aed6896f509c9..c6e23d7eaf349131d678302af053004f257e20c0 100644 --- a/MantleAPI/include/MantleAPI/Traffic/i_controller_config.h +++ b/MantleAPI/include/MantleAPI/Traffic/i_controller_config.h @@ -22,6 +22,7 @@ #include <MantleAPI/Map/i_lane_location_query_service.h> #include <algorithm> +#include <map> #include <memory> #include <vector> @@ -82,6 +83,7 @@ struct InternalControllerConfig : public IControllerConfig struct ExternalControllerConfig : public IControllerConfig { std::string name; + std::map<std::string, std::string> parameters; }; } // namespace mantle_api diff --git a/MantleAPI/test/MantleAPI/Test/test_utils.h b/MantleAPI/test/MantleAPI/Test/test_utils.h index a0692893f0575d3d29e1c3dbe78c0a5efb774322..86b24a873e6a506ce1b5e2724d8260d90b81bf71 100644 --- a/MantleAPI/test/MantleAPI/Test/test_utils.h +++ b/MantleAPI/test/MantleAPI/Test/test_utils.h @@ -335,7 +335,7 @@ class MockEnvironment : public mantle_api::IEnvironment mantle_api::DateTime GetDateTime() override { return mantle_api::DateTime(); } - mantle_api::SimulationTime GetSimulationTime() override { return mantle_api::SimulationTime(); } + MOCK_METHOD(mantle_api::SimulationTime, GetSimulationTime, (), (override)); private: MockQueryService query_service_{};