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