Commit 5f24d65d authored by Arun Das's avatar Arun Das
Browse files

Update interface

parent e425759b
/*******************************************************************************
* 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
*******************************************************************************/
################################################################################
# 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
################################################################################
cc_library(
name = "mantle_api",
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 bounding_box.h */
......@@ -15,20 +15,24 @@
#ifndef MANTLEAPI_COMMON_BOUNDINGBOX_H
#define MANTLEAPI_COMMON_BOUNDINGBOX_H
#include <MantleAPI/Common/i_position.h>
#include <MantleAPI/Common/dimension.h>
#include <MantleAPI/Common/vector.h>
namespace mantle_api
{
/// Bounding box is defined in local object coordinate system.
/// The origin of the object coordinate system is defined in relation to the geometric center.
/// Bounding box is defined in local entity coordinate system.
/// The origin of the entity coordinate system is defined in relation to the geometric center.
struct BoundingBox
{
Vec3d geometric_center{0.0, 0.0, 0.0};
double width{0.0};
double length{0.0};
double height{0.0};
Dimension3d dimension{0.0, 0.0, 0.0};
};
inline bool operator==(const BoundingBox& lhs, const BoundingBox& rhs) noexcept
{
return lhs.geometric_center == rhs.geometric_center && lhs.dimension == rhs.dimension;
}
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_BOUNDINGBOX_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 dimension.h */
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 floating_point_helper.h */
//-----------------------------------------------------------------------------
#ifndef THIRDPARTY_MANTLEAPI_INCLUDE_MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
#define THIRDPARTY_MANTLEAPI_INCLUDE_MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
#ifndef MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
#define MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
#include <cmath>
#include <limits>
#include <type_traits>
namespace mantle_api
{
......@@ -90,4 +91,4 @@ bool LessOrEqual(T lhs, T rhs, T precision = std::numeric_limits<T>::epsilon())
}
} // namespace mantle_api
#endif // THIRDPARTY_MANTLEAPI_INCLUDE_MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
#endif // MANTLEAPI_COMMON_FLOATING_POINT_HELPER_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 i_identifiable.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_IIDENTIFIABLE_H
#define MANTLEAPI_COMMON_IIDENTIFIABLE_H
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 orientation.h */
//-----------------------------------------------------------------------------
#ifndef SIMULATOR_ORIENTATION_H
#define SIMULATOR_ORIENTATION_H
#ifndef MANTLEAPI_COMMON_ORIENTATION_H
#define MANTLEAPI_COMMON_ORIENTATION_H
#include <MantleAPI/Common/floating_point_helper.h>
......@@ -24,6 +23,9 @@ namespace mantle_api
template <typename T>
struct Orientation3
{
Orientation3() = default;
Orientation3(T yaw, T pitch, T roll) : yaw{yaw}, pitch{pitch}, roll{roll} {}
T yaw{};
T pitch{};
T roll{};
......@@ -41,6 +43,16 @@ inline bool operator!=(const Orientation3d& lhs, const Orientation3d& rhs) noexc
return !(lhs == rhs);
}
inline Orientation3d operator+(const Orientation3d& lhs, const Orientation3d& rhs) noexcept
{
return Orientation3d{lhs.yaw + rhs.yaw, lhs.pitch + rhs.pitch, lhs.roll + rhs.roll};
}
inline Orientation3d operator-(const Orientation3d& lhs, const Orientation3d& rhs) noexcept
{
return Orientation3d{lhs.yaw - rhs.yaw, lhs.pitch - rhs.pitch, lhs.roll - rhs.roll};
}
} // namespace mantle_api
#endif // SIMULATOR_ORIENTATION_H
#endif // MANTLEAPI_COMMON_ORIENTATION_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 pose.h */
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 position.h */
//-----------------------------------------------------------------------------
#ifndef SCENARIOABSTRACT_COMMON_IPOSITION_H
#define SCENARIOABSTRACT_COMMON_IPOSITION_H
#ifndef MANTLEAPI_COMMON_IPOSITION_H
#define MANTLEAPI_COMMON_IPOSITION_H
#include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/vector.h>
......@@ -79,4 +79,4 @@ inline bool operator!=(const LatLonPosition& lhs, const LatLonPosition& rhs) noe
}
} // namespace mantle_api
#endif // SCENARIOABSTRACT_COMMON_IPOSITION_H
#endif // MANTLEAPI_COMMON_IPOSITION_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 simulation_time.h */
//-----------------------------------------------------------------------------
#ifndef SCENARIOABSTRACT_COMMON_SIMULATION_TIME_H
#define SCENARIOABSTRACT_COMMON_SIMULATION_TIME_H
#ifndef MANTLEAPI_COMMON_SIMULATION_TIME_H
#define MANTLEAPI_COMMON_SIMULATION_TIME_H
#include <chrono>
namespace mantle_api
{
using SimulationTime = std::chrono::duration<std::int64_t, std::milli>;
/// @brief Converts input in [s] to @ref SimulationTime.
/// @tparam T Input type, eg. `double`.
/// @param duration Input value
/// @return Duration representing the given input in units of @ref SimulationTime.
template <typename T>
inline SimulationTime SecondsToSimulationTime(T duration)
{
return std::chrono::duration_cast<SimulationTime>(std::chrono::duration<T>{duration});
}
/// @brief Converts input @ref SimulationTime to [s].
/// @param time Simulation time
/// @return Duration ins seconds representing the passed in @ref SimulationTime.
inline double SimulationTimeToSeconds(const SimulationTime& time)
{
return static_cast<double>(time.count()) / 1000.0;
}
} // namespace mantle_api
#endif // SCENARIOABSTRACT_COMMON_SIMULATION_TIME_H
\ No newline at end of file
#endif // MANTLEAPI_COMMON_SIMULATION_TIME_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 spline.h */
//-----------------------------------------------------------------------------
#ifndef SCENARIOABSTRACT_COMMON_SPLINE_H
#define SCENARIOABSTRACT_COMMON_SPLINE_H
#ifndef MANTLEAPI_COMMON_SPLINE_H
#define MANTLEAPI_COMMON_SPLINE_H
#include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/simulation_time.h>
......@@ -47,4 +47,4 @@ inline bool operator==(const SplineSection& lhs, const SplineSection& rhs) noexc
} // namespace mantle_api
#endif // SCENARIOABSTRACT_COMMON_SPLINE_H
\ No newline at end of file
#endif // MANTLEAPI_COMMON_SPLINE_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 vector.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_VECTOR_H
#define MANTLEAPI_COMMON_VECTOR_H
......@@ -55,6 +54,11 @@ inline Vec3d operator+(const Vec3d& lhs, const Vec3d& rhs) noexcept
return {lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z};
}
inline Vec3d operator*(const Vec3d& lhs, double d) noexcept
{
return {lhs.x * d, lhs.y * d, lhs.z * d};
}
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_VECTOR_H
/*******************************************************************************
* 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 date_time.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#define MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#include <MantleAPI/Common/simulation_time.h>
#include <chrono>
namespace mantle_api
{
struct DateTime
{
SimulationTime date_time_ms{0};
};
} // namespace mantle_api
#endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
/*******************************************************************************
* 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
*******************************************************************************/
* 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 road_condition.h */
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 weather.h */
......@@ -17,8 +17,6 @@
#include <chrono>
using Milliseconds = std::chrono::duration<int64_t, std::ratio<1, 1000>>;
namespace mantle_api
{
enum class Precipitation
......@@ -65,14 +63,12 @@ enum class Illumination
struct Weather
{
Fog fog{Fog::kUnknown};
Precipitation precipitation{Precipitation::kUnknown};
Illumination illumination{Illumination::kUnknown};
Fog fog{Fog::kExcellentVisibility};
Precipitation precipitation{Precipitation::kNone};
Illumination illumination{Illumination::kOther};
double humidity_percent{0.0};
double temperature_kelvin{0.0};
double atmospheric_pressure_pascal{0.0};
Milliseconds date_time_ms{0}; // TODO: we should move this out of the weather...?!
};
} // namespace mantle_api
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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 i_environment.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_EXECUTION_IENVIRONMENT_H
#define MANTLEAPI_EXECUTION_IENVIRONMENT_H
#include <MantleAPI/EnvironmentalConditions/date_time.h>
#include <MantleAPI/EnvironmentalConditions/road_condition.h>
#include <MantleAPI/EnvironmentalConditions/weather.h>
#include <MantleAPI/Map/i_coord_converter.h>
......@@ -41,18 +41,29 @@ class IEnvironment
/// environment.
virtual void CreateMap(const std::string& 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.
/// Creates a controller from the given config. A created controller can be assigned to multiple entities
///
/// @param config Specifies what kind of controller shall be created. The config needs to contain an ID to
/// @param config Specifies what kind of controller shall be created. The config needs to contain a controller ID
/// in order to be able to assign this controller to an entity.
virtual void CreateController(std::unique_ptr<IControllerConfig> config) = 0;
/// Assigns an entity to a copy of the specified controller. This controller needs to be created beforehand.
/// Assigns an entity to a copy of the specified controller. This controller needs to be created beforehand. Only
/// one controller can be added to an entity
///
/// @param entity The entity to be manipulated by the specified controller.
/// @param controller_id Identifies the controller to manipulate the entity.
virtual void AddEntityToController(IEntity& entity, std::uint64_t controller_id) = 0;
virtual void RemoveControllerFromEntity(std::uint64_t entity_id) = 0;
/// Updates the control strategies in the composite controller.
///
/// @param controller_id Specifies the controller to be updated
/// @param control_strategies Specifies the desired movement behaviour for the entity
virtual void UpdateControlStrategies(
std::uint64_t controller_id,
std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies) = 0;
virtual const ILaneLocationQueryService& GetQueryService() const = 0;
virtual const ICoordConverter* GetConverter() const = 0;
......@@ -60,8 +71,8 @@ class IEnvironment
virtual const IEntityRepository& GetEntityRepository() const = 0;
/// @brief DateTime in UTC (converted from RFC 3339 standard)
virtual void SetDateTime(std::chrono::duration<std::int64_t, std::milli> date_time) = 0;
virtual std::chrono::duration<std::int64_t, std::milli> GetDateTime() = 0;
virtual void SetDateTime(DateTime date_time) = 0;
virtual DateTime GetDateTime() = 0;
virtual void SetWeather(Weather weather) = 0;
virtual void SetRoadCondition(std::vector<FrictionPatch> friction_patches) = 0;
......
/*******************************************************************************
* 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
*******************************************************************************/
* 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
*******************************************************************************/