Skip to content
Snippets Groups Projects
Commit 40e570a9 authored by René Paris's avatar René Paris
Browse files

feat(chore): add .clang-format


Signed-off-by: René Paris's avatarRene Paris <rene.paris@in-tech.com>
parent 4dd177ef
No related branches found
No related tags found
1 merge request!6.clang-format from simopenpass
Showing
with 275 additions and 285 deletions
---
BasedOnStyle: Google
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: Inline
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Allman
ColumnLimit: 0
......@@ -21,22 +21,21 @@
namespace mantle_api
{
/// 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
{
Vec3<units::length::meter_t> geometric_center{};
Dimension3 dimension{};
Vec3<units::length::meter_t> geometric_center{};
Dimension3 dimension{};
};
inline bool operator==(const BoundingBox& lhs, const BoundingBox& rhs) noexcept
{
return lhs.geometric_center == rhs.geometric_center &&
lhs.dimension == rhs.dimension;
return lhs.geometric_center == rhs.geometric_center &&
lhs.dimension == rhs.dimension;
}
} // namespace mantle_api
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_BOUNDINGBOX_H
#endif // MANTLEAPI_COMMON_BOUNDINGBOX_H
......@@ -20,22 +20,21 @@
namespace mantle_api
{
struct Dimension3
{
units::length::meter_t length{0};
units::length::meter_t width{0};
units::length::meter_t height{0};
units::length::meter_t length{0};
units::length::meter_t width{0};
units::length::meter_t height{0};
};
inline bool operator==(const Dimension3& lhs, const Dimension3& rhs) noexcept
{
return IsEqual(lhs.length, rhs.length) && IsEqual(lhs.width, rhs.width) && IsEqual(lhs.height, rhs.height);
return IsEqual(lhs.length, rhs.length) && IsEqual(lhs.width, rhs.width) && IsEqual(lhs.height, rhs.height);
}
inline bool operator!=(const Dimension3& lhs, const Dimension3& rhs) noexcept
{
return !(lhs == rhs);
return !(lhs == rhs);
}
} // namespace mantle_api
......
......@@ -23,7 +23,6 @@
namespace mantle_api
{
/// @brief Compares two floating point numbers for equality.
///
/// **Attention** No approximation of the correct precision for the actual value is done!
......@@ -40,7 +39,7 @@ namespace mantle_api
/// @return True if both numbers are equal within the given precision.
inline bool IsEqual(double lhs, double rhs, double precision = std::numeric_limits<double>::epsilon())
{
return std::abs(lhs - rhs) < precision;
return std::abs(lhs - rhs) < precision;
}
/// @brief Compares two floating point numbers for equality.
......@@ -60,7 +59,7 @@ inline bool IsEqual(double lhs, double rhs, double precision = std::numeric_limi
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
bool IsEqual(T lhs, T rhs, double precision = std::numeric_limits<double>::epsilon())
{
return units::math::abs(lhs - rhs) < precision;
return units::math::abs(lhs - rhs) < precision;
}
/// @brief Compares two floating point numbers for equality.
......@@ -80,11 +79,11 @@ bool IsEqual(T lhs, T rhs, double precision = std::numeric_limits<double>::epsil
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
bool GreaterOrEqual(T lhs, T rhs, double precision = std::numeric_limits<double>::epsilon())
{
if (lhs > rhs)
{
return true;
}
return IsEqual(lhs, rhs, precision);
if (lhs > rhs)
{
return true;
}
return IsEqual(lhs, rhs, precision);
}
/// @brief Compares two floating point numbers for equality.
......@@ -104,11 +103,11 @@ bool GreaterOrEqual(T lhs, T rhs, double precision = std::numeric_limits<double>
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
bool LessOrEqual(T lhs, T rhs, double precision = std::numeric_limits<double>::epsilon())
{
if (lhs < rhs)
{
return true;
}
return IsEqual(lhs, rhs, precision);
if (lhs < rhs)
{
return true;
}
return IsEqual(lhs, rhs, precision);
}
} // namespace mantle_api
......
......@@ -26,16 +26,16 @@ constexpr UniqueId InvalidId{std::numeric_limits<UniqueId>::max()};
/// Common interface for all classes that can be referenced by an ID or name.
class IIdentifiable
{
public:
virtual ~IIdentifiable() = default;
/// The unique id is provided and maintained by the scenario simulator.
virtual UniqueId GetUniqueId() const = 0;
/// Scenario specific name of an object.
///
/// The scenario description is responsible for keeping the name unique.
virtual void SetName(const std::string& name) = 0;
virtual const std::string& GetName() const = 0;
public:
virtual ~IIdentifiable() = default;
/// The unique id is provided and maintained by the scenario simulator.
virtual UniqueId GetUniqueId() const = 0;
/// Scenario specific name of an object.
///
/// The scenario description is responsible for keeping the name unique.
virtual void SetName(const std::string& name) = 0;
virtual const std::string& GetName() const = 0;
};
} // namespace mantle_api
......
......@@ -20,7 +20,6 @@
namespace units
{
UNIT_ADD(angular_acceleration,
radians_per_second_squared,
radians_per_second_squared,
......@@ -38,40 +37,39 @@ UNIT_ADD_CATEGORY_TRAIT(angular_acceleration)
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 ||
units::traits::is_angular_acceleration_unit<T>::value>>
struct Orientation3
{
T yaw{};
T pitch{};
T roll{};
T yaw{};
T pitch{};
T roll{};
};
template <typename T>
inline bool operator==(const Orientation3<T>& lhs, const Orientation3<T>& rhs) noexcept
{
return IsEqual(lhs.yaw, rhs.yaw) && IsEqual(lhs.pitch, rhs.pitch) && IsEqual(lhs.roll, rhs.roll);
return IsEqual(lhs.yaw, rhs.yaw) && IsEqual(lhs.pitch, rhs.pitch) && IsEqual(lhs.roll, rhs.roll);
}
template <typename T>
inline bool operator!=(const Orientation3<T>& lhs, const Orientation3<T>& rhs) noexcept
{
return !(lhs == rhs);
return !(lhs == rhs);
}
template <typename T>
inline Orientation3<T> operator+(const Orientation3<T>& lhs, const Orientation3<T>& rhs) noexcept
{
return Orientation3<T>{lhs.yaw + rhs.yaw, lhs.pitch + rhs.pitch, lhs.roll + rhs.roll};
return Orientation3<T>{lhs.yaw + rhs.yaw, lhs.pitch + rhs.pitch, lhs.roll + rhs.roll};
}
template <typename T>
inline Orientation3<T> operator-(const Orientation3<T>& lhs, const Orientation3<T>& rhs) noexcept
{
return Orientation3<T>{lhs.yaw - rhs.yaw, lhs.pitch - rhs.pitch, lhs.roll - rhs.roll};
return Orientation3<T>{lhs.yaw - rhs.yaw, lhs.pitch - rhs.pitch, lhs.roll - rhs.roll};
}
} // namespace mantle_api
......
......@@ -23,35 +23,33 @@
namespace mantle_api
{
struct PolyLinePoint
{
Pose pose{};
std::optional<Time> time{};
Pose pose{};
std::optional<Time> time{};
bool operator== (const PolyLinePoint& other) const
{
return other.time == time
&& other.pose == pose;
}
bool operator==(const PolyLinePoint& other) const
{
return other.time == time && other.pose == pose;
}
friend std::ostream& operator<<(std::ostream& os, const PolyLinePoint& polyLinePoint);
friend std::ostream& operator<<(std::ostream& os, const PolyLinePoint& polyLinePoint);
};
inline std::ostream& operator<<(std::ostream& os, const PolyLinePoint& polyLinePoint)
{
os << polyLinePoint.pose;
os << polyLinePoint.pose;
if(polyLinePoint.time.has_value())
{
os << ", time in ms " << polyLinePoint.time.value().count();
}
if (polyLinePoint.time.has_value())
{
os << ", time in ms " << polyLinePoint.time.value().count();
}
return os;
return os;
}
using PolyLine = std::vector<PolyLinePoint>;
} // namespace mantle_api
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_POLY_LINE_H
\ No newline at end of file
#endif // MANTLEAPI_COMMON_POLY_LINE_H
\ No newline at end of file
......@@ -17,41 +17,37 @@
#include <MantleAPI/Common/orientation.h>
#include <MantleAPI/Common/vector.h>
#include <units.h>
#include <iostream>
namespace mantle_api
{
struct Pose
{
Vec3<units::length::meter_t> position{};
Orientation3<units::angle::radian_t> orientation{};
Vec3<units::length::meter_t> position{};
Orientation3<units::angle::radian_t> orientation{};
bool operator== (const Pose& other) const
{
return other.position == position
&& other.orientation == orientation;
}
bool operator==(const Pose& other) const
{
return other.position == position && other.orientation == orientation;
}
friend inline std::ostream& operator<<(std::ostream& os, const Pose& pose);
friend inline std::ostream& operator<<(std::ostream& os, const Pose& pose);
};
std::ostream& operator<<(std::ostream& os, const Pose& pose)
{
os << "position ("
<< pose.position.x
<< ", " << pose.position.y
<< ", " << pose.position.z
<< "), orientation (" << pose.orientation.yaw
<< ", " << pose.orientation.pitch
<< ", " << pose.orientation.roll
<< ")";
return os;
os << "position ("
<< pose.position.x
<< ", " << pose.position.y
<< ", " << pose.position.z
<< "), orientation (" << pose.orientation.yaw
<< ", " << pose.orientation.pitch
<< ", " << pose.orientation.roll
<< ")";
return os;
}
} // namespace mantle_api
......
......@@ -25,29 +25,28 @@
namespace mantle_api
{
struct ReferencedObject
{
std::int32_t road{0};
std::int32_t lane{0};
std::int32_t road{0};
std::int32_t lane{0};
};
struct OpenDrivePosition
{
ReferencedObject referenced_object{};
ReferencedObject referenced_object{};
/// @brief Offset in s direction, unit: [m]
units::length::meter_t s_offset{0.0};
/// @brief Offset in t direction, unit: [m]
units::length::meter_t t_offset{0.0};
/// @brief Offset in s direction, unit: [m]
units::length::meter_t s_offset{0.0};
/// @brief Offset in t direction, unit: [m]
units::length::meter_t t_offset{0.0};
};
struct LatLonPosition
{
/// @brief GPS latitude, unit: [rad]
units::angle::radian_t latitude{0.0};
/// @brief GPS longitude, unit: [rad]
units::angle::radian_t longitude{0.0};
/// @brief GPS latitude, unit: [rad]
units::angle::radian_t latitude{0.0};
/// @brief GPS longitude, unit: [rad]
units::angle::radian_t longitude{0.0};
};
using Position = std::variant<OpenDrivePosition, LatLonPosition, Vec3<units::length::meter_t>>;
......@@ -57,14 +56,14 @@ using Position = std::variant<OpenDrivePosition, LatLonPosition, Vec3<units::len
/// **Attention** Floating-point comparision may require tweaks in precision.
inline bool operator==(const OpenDrivePosition& lhs, const OpenDrivePosition& 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) &&
IsEqual(lhs.t_offset, rhs.t_offset);
return lhs.referenced_object.road == rhs.referenced_object.road &&
lhs.referenced_object.lane == rhs.referenced_object.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
{
return !(lhs == rhs);
return !(lhs == rhs);
}
/// @brief Equality comparison for LatLonPosition.
......@@ -72,12 +71,12 @@ inline bool operator!=(const OpenDrivePosition& lhs, const OpenDrivePosition& rh
/// **Attention** Floating-point comparision may require tweaks in precision.
inline bool operator==(const LatLonPosition& lhs, const LatLonPosition& rhs) noexcept
{
return IsEqual(lhs.latitude, rhs.latitude) && IsEqual(lhs.longitude, rhs.longitude);
return IsEqual(lhs.latitude, rhs.latitude) && IsEqual(lhs.longitude, rhs.longitude);
}
inline bool operator!=(const LatLonPosition& lhs, const LatLonPosition& rhs) noexcept
{
return !(lhs == rhs);
return !(lhs == rhs);
}
} // namespace mantle_api
......
......@@ -19,11 +19,10 @@
namespace mantle_api
{
struct SimulationTime
{
Time current_sim_time{0};
Time last_delta_time{0};
Time current_sim_time{0};
Time last_delta_time{0};
};
} // namespace mantle_api
......
......@@ -25,39 +25,38 @@
namespace mantle_api
{
template <typename T>
struct SplineSegment
{
Vec3<T> a;
Vec3<T> b;
Vec3<T> c;
Vec3<T> d;
Vec3<T> a;
Vec3<T> b;
Vec3<T> c;
Vec3<T> d;
};
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
struct SplineSection
{
Time start_time{0};
Time end_time{0};
/// @brief Represents the polynomial.
///
/// The array stores in format \f$[a_3, a_2, a_1, a_0]\f$ for a polynomial in form
/// \f[
/// P(x) = \sum_{i=0}^{3} a_{i} x^{i} = a_3 x^3 + a_2 x^2 + a_1 x + a_0
/// \f]
std::array<T, 4> polynomial{0, 0, 0, 0};
Time start_time{0};
Time end_time{0};
/// @brief Represents the polynomial.
///
/// The array stores in format \f$[a_3, a_2, a_1, a_0]\f$ for a polynomial in form
/// \f[
/// P(x) = \sum_{i=0}^{3} a_{i} x^{i} = a_3 x^3 + a_2 x^2 + a_1 x + a_0
/// \f]
std::array<T, 4> polynomial{0, 0, 0, 0};
};
/// @brief Equality comparison for SplineSection.
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
inline bool operator==(const SplineSection<T>& lhs, const SplineSection<T>& rhs) noexcept
{
return lhs.start_time == rhs.start_time && lhs.end_time == rhs.end_time &&
std::equal(lhs.polynomial.begin(),
lhs.polynomial.end(),
rhs.polynomial.begin(),
[](const T& a, const T& b) { return IsEqual(a, b); });
return lhs.start_time == rhs.start_time && lhs.end_time == rhs.end_time &&
std::equal(lhs.polynomial.begin(),
lhs.polynomial.end(),
rhs.polynomial.begin(),
[](const T& a, const T& b) { return IsEqual(a, b); });
}
} // namespace mantle_api
......
......@@ -28,7 +28,7 @@ using Time = units::time::millisecond_t;
template <typename T>
inline Time SecondsToTime(T duration)
{
return units::convert<units::time::seconds, Time>(duration);
return units::convert<units::time::seconds, Time>(duration);
}
/// @brief Converts input @ref Time to [s].
......@@ -36,7 +36,7 @@ inline Time SecondsToTime(T duration)
/// @return Duration in seconds representing the passed in @ref Time.
inline double TimeToSeconds(const Time& time)
{
return units::time::second_t{time}.value();
return units::time::second_t{time}.value();
}
} // namespace mantle_api
......
......@@ -15,39 +15,39 @@
#ifndef MANTLEAPI_COMMON_TRAJECTORY_H
#define MANTLEAPI_COMMON_TRAJECTORY_H
#include <MantleAPI/Common/poly_line.h>
#include <string>
#include <variant>
#include <MantleAPI/Common/poly_line.h>
namespace mantle_api
{
struct Trajectory
{
std::string name;
std::variant<PolyLine> type;
std::string name;
std::variant<PolyLine> type;
friend std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory);
friend std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory);
};
inline std::ostream& operator<<(std::ostream& os, const Trajectory& trajectory)
{
os << "Trajectory \"" << trajectory.name;
if(std::holds_alternative<PolyLine>(trajectory.type))
os << "Trajectory \"" << trajectory.name;
if (std::holds_alternative<PolyLine>(trajectory.type))
{
const auto& polyLine = std::get<PolyLine>(trajectory.type);
for (const auto& polyLinePoint : polyLine)
{
const auto &polyLine = std::get<PolyLine>(trajectory.type);
for (const auto &polyLinePoint : polyLine)
{
os << polyLinePoint;
}
os << polyLinePoint;
}
os << "\"\n";
}
os << "\"\n";
return os;
return os;
}
} // namespace mantle_api
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_TRAJECTORY_H
\ No newline at end of file
#endif // MANTLEAPI_COMMON_TRAJECTORY_H
\ No newline at end of file
......@@ -24,85 +24,85 @@ namespace mantle_api
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
struct Vec3
{
T x{0};
T y{0};
T z{0};
T x{0};
T y{0};
T z{0};
inline T Length() const { return sqrt((x * x) + (y * y) + (z * z)); }
inline T Length() const { return sqrt((x * x) + (y * y) + (z * z)); }
};
template <typename T>
inline bool operator==(const Vec3<T>& lhs, const Vec3<T>& rhs) noexcept
{
return IsEqual(lhs.x, rhs.x) && IsEqual(lhs.y, rhs.y) && IsEqual(lhs.z, rhs.z);
return IsEqual(lhs.x, rhs.x) && IsEqual(lhs.y, rhs.y) && IsEqual(lhs.z, rhs.z);
}
template <typename T>
inline bool operator!=(const Vec3<T>& lhs, const Vec3<T>& rhs) noexcept
{
return !(lhs == rhs);
return !(lhs == rhs);
}
template <typename T>
inline Vec3<T> operator-(const Vec3<T>& lhs, const Vec3<T>& rhs) noexcept
{
return {lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z};
return {lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z};
}
template <typename T>
inline Vec3<T> operator+(const Vec3<T>& lhs, const Vec3<T>& rhs) noexcept
{
return {lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z};
return {lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z};
}
template <typename T>
inline Vec3<T> operator*(const Vec3<T>& lhs, double d) noexcept
{
return {lhs.x * d, lhs.y * d, lhs.z * d};
return {lhs.x * d, lhs.y * d, lhs.z * d};
}
template <typename T>
inline Vec3<T> operator*(double d, const Vec3<T>& rhs) noexcept
{
return rhs * d;
return rhs * d;
}
template <typename T>
inline Vec3<T> operator/(const Vec3<T>& lhs, double d) noexcept
{
return {lhs.x / d, lhs.y / d, lhs.z / d};
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;
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;
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;
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;
lhs.x -= d;
lhs.y -= d;
lhs.z -= d;
return lhs;
}
} // namespace mantle_api
......
......@@ -19,11 +19,10 @@
namespace mantle_api
{
// TODO: Delete this struct and use Time directly in Get/SetDateTime once the move to the MantleAPI is complete
struct [[deprecated]] DateTime
{
Time date_time{0};
Time date_time{0};
};
} // namespace mantle_api
......
......@@ -20,17 +20,16 @@
namespace mantle_api
{
struct Rectangle
{
Position bottom_left{};
Position top_right{};
Position bottom_left{};
Position top_right{};
};
struct FrictionPatch
{
Rectangle bounding_box{};
units::concentration::percent_t friction{100.0};
Rectangle bounding_box{};
units::concentration::percent_t friction{100.0};
};
} // namespace mantle_api
#endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_ROADCONDITION_H
......@@ -19,57 +19,56 @@
namespace mantle_api
{
enum class Precipitation
{
kUnknown,
kOther,
kNone,
kVeryLight,
kLight,
kModerate,
kHeavy,
kVeryHeavy,
kExtreme
kUnknown,
kOther,
kNone,
kVeryLight,
kLight,
kModerate,
kHeavy,
kVeryHeavy,
kExtreme
};
enum class Fog
{
kUnknown,
kOther,
kExcellentVisibility,
kGoodVisibility,
kModerateVisibility,
kPoorVisibility,
kMist,
kLight,
kThick,
kDense
kUnknown,
kOther,
kExcellentVisibility,
kGoodVisibility,
kModerateVisibility,
kPoorVisibility,
kMist,
kLight,
kThick,
kDense
};
enum class Illumination
{
kUnknown,
kOther,
kLevel1,
kLevel2,
kLevel3,
kLevel4,
kLevel5,
kLevel6,
kLevel7,
kLevel8,
kLevel9
kUnknown,
kOther,
kLevel1,
kLevel2,
kLevel3,
kLevel4,
kLevel5,
kLevel6,
kLevel7,
kLevel8,
kLevel9
};
struct Weather
{
Fog fog{Fog::kExcellentVisibility};
Precipitation precipitation{Precipitation::kNone};
Illumination illumination{Illumination::kOther};
units::concentration::percent_t humidity{0.0};
units::temperature::kelvin_t temperature{0.0};
units::pressure::pascal_t atmospheric_pressure{0.0};
Fog fog{Fog::kExcellentVisibility};
Precipitation precipitation{Precipitation::kNone};
Illumination illumination{Illumination::kOther};
units::concentration::percent_t humidity{0.0};
units::temperature::kelvin_t temperature{0.0};
units::pressure::pascal_t atmospheric_pressure{0.0};
};
} // namespace mantle_api
......
......@@ -29,58 +29,58 @@ namespace mantle_api
{
class IEnvironment
{
public:
virtual ~IEnvironment() = default;
/// Load a map file and parse it into the memory.
///
/// @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
///
/// @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. 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, UniqueId controller_id) = 0;
virtual void RemoveControllerFromEntity(UniqueId entity_id) = 0;
/// Updates the control strategies for an entity.
///
/// @param entity_id Specifies the entity to be updated
/// @param control_strategies Specifies the desired movement behaviour for the entity
virtual void UpdateControlStrategies(
UniqueId entity_id, std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies) = 0;
/// Checks, if a control strategy of a certain type for a specific entity has been fulfilled
///
/// @param entity_id The entity to check
/// @param type The control strategy type
virtual bool HasControlStrategyGoalBeenReached(UniqueId entity_id, mantle_api::ControlStrategyType type) const = 0;
virtual const ILaneLocationQueryService& GetQueryService() const = 0;
virtual const ICoordConverter* GetConverter() const = 0;
virtual IEntityRepository& GetEntityRepository() = 0;
virtual const IEntityRepository& GetEntityRepository() const = 0;
/// @brief DateTime in UTC (converted from RFC 3339 standard)
virtual void SetDateTime(DateTime date_time) = 0;
virtual DateTime GetDateTime() = 0;
/// @brief Time since start of simulation and delta time to previous step
virtual SimulationTime GetSimulationTime() = 0;
virtual void SetWeather(Weather weather) = 0;
virtual void SetRoadCondition(std::vector<FrictionPatch> friction_patches) = 0;
public:
virtual ~IEnvironment() = default;
/// Load a map file and parse it into the memory.
///
/// @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
///
/// @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. 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, UniqueId controller_id) = 0;
virtual void RemoveControllerFromEntity(UniqueId entity_id) = 0;
/// Updates the control strategies for an entity.
///
/// @param entity_id Specifies the entity to be updated
/// @param control_strategies Specifies the desired movement behaviour for the entity
virtual void UpdateControlStrategies(
UniqueId entity_id, std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies) = 0;
/// Checks, if a control strategy of a certain type for a specific entity has been fulfilled
///
/// @param entity_id The entity to check
/// @param type The control strategy type
virtual bool HasControlStrategyGoalBeenReached(UniqueId entity_id, mantle_api::ControlStrategyType type) const = 0;
virtual const ILaneLocationQueryService& GetQueryService() const = 0;
virtual const ICoordConverter* GetConverter() const = 0;
virtual IEntityRepository& GetEntityRepository() = 0;
virtual const IEntityRepository& GetEntityRepository() const = 0;
/// @brief DateTime in UTC (converted from RFC 3339 standard)
virtual void SetDateTime(DateTime date_time) = 0;
virtual DateTime GetDateTime() = 0;
/// @brief Time since start of simulation and delta time to previous step
virtual SimulationTime GetSimulationTime() = 0;
virtual void SetWeather(Weather weather) = 0;
virtual void SetRoadCondition(std::vector<FrictionPatch> friction_patches) = 0;
};
} // namespace mantle_api
......
......@@ -23,26 +23,26 @@ namespace mantle_api
{
class IScenarioEngine
{
public:
virtual ~IScenarioEngine() = default;
public:
virtual ~IScenarioEngine() = default;
/// Initialization of the scenario state, e.g. loading the scenario file, map file, etc.
virtual void Init() = 0;
/// Initialization of the scenario state, e.g. loading the scenario file, map file, etc.
virtual void Init() = 0;
/// Provide information about the scenario loaded in `Init()`
virtual ScenarioInfo GetScenarioInfo() const = 0;
/// Provide information about the scenario loaded in `Init()`
virtual ScenarioInfo GetScenarioInfo() const = 0;
/// Calculate the new state of the scenario implementation.
///
/// Calling this function after `IsFinished()` should be a no-op.
/// @see IsFinished()
virtual void Step() = 0;
/// Calculate the new state of the scenario implementation.
///
/// Calling this function after `IsFinished()` should be a no-op.
/// @see IsFinished()
virtual void Step() = 0;
/// Indicates whether the scenario implementation has finished processing the scenario (end of scenario is reached).
/// @return `true` if processing the scenario is complete, `false` otherwise.
virtual bool IsFinished() const = 0;
/// Indicates whether the scenario implementation has finished processing the scenario (end of scenario is reached).
/// @return `true` if processing the scenario is complete, `false` otherwise.
virtual bool IsFinished() const = 0;
virtual void ActivateExternalHostControl() = 0;
virtual void ActivateExternalHostControl() = 0;
};
} // namespace mantle_api
......
......@@ -22,12 +22,11 @@
namespace mantle_api
{
struct ScenarioInfo
{
Time scenario_timeout_duration;
std::string description;
std::map<std::string, std::string> additional_information;
Time scenario_timeout_duration;
std::string description;
std::map<std::string, std::string> additional_information;
};
} // namespace mantle_api
......
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