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 578 additions and 588 deletions
...@@ -21,18 +21,17 @@ ...@@ -21,18 +21,17 @@
namespace mantle_api namespace mantle_api
{ {
/// Interface that provides functionality to query the underlying map with regard to transformation of different /// Interface that provides functionality to query the underlying map with regard to transformation of different
/// position types, curvature, elevation etc. /// position types, curvature, elevation etc.
class ICoordConverter class ICoordConverter
{ {
public: public:
virtual ~ICoordConverter() = default; virtual ~ICoordConverter() = default;
/// Converts a track position to its corresponding inertial position. /// Converts a track position to its corresponding inertial position.
virtual Vec3<units::length::meter_t> Convert(Position position) const = 0; virtual Vec3<units::length::meter_t> Convert(Position position) const = 0;
/// Converts alane position to its corresponding inertial position. /// Converts alane position to its corresponding inertial position.
virtual Position Convert(const Vec3<units::length::meter_t>& inert_pos) const = 0; virtual Position Convert(const Vec3<units::length::meter_t>& inert_pos) const = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -22,26 +22,25 @@ ...@@ -22,26 +22,25 @@
namespace mantle_api namespace mantle_api
{ {
/// Abstraction layer for all map related functions. /// Abstraction layer for all map related functions.
class ILaneLocationQueryService class ILaneLocationQueryService
{ {
public: public:
virtual ~ILaneLocationQueryService() = default; virtual ~ILaneLocationQueryService() = default;
/// TODO: Currently LaneLocationProvider just inherits from this for the sake of easily passing it to the /// TODO: Currently LaneLocationProvider just inherits from this for the sake of easily passing it to the
/// controllers /// controllers
/// Therefore the GetMapObjectById function has been removed from the interface - for now. /// Therefore the GetMapObjectById function has been removed from the interface - for now.
/// We need to think about proper interface functions we want to define here (GetLaneLocation? GetLanes? But this /// We need to think about proper interface functions we want to define here (GetLaneLocation? GetLanes? But this
/// would add a rat-tail of more interfaces we need to define (ILaneLocation, ILane, ...?) /// would add a rat-tail of more interfaces we need to define (ILaneLocation, ILane, ...?)
// virtual const IIdentifiable& GetMapObjectById(UniqueId id) = 0; // virtual const IIdentifiable& GetMapObjectById(UniqueId id) = 0;
virtual Orientation3<units::angle::radian_t> GetLaneOrientation( virtual Orientation3<units::angle::radian_t> GetLaneOrientation(
const Vec3<units::length::meter_t>& position) const = 0; const Vec3<units::length::meter_t>& position) const = 0;
virtual Vec3<units::length::meter_t> GetUpwardsShiftedLanePosition(const Vec3<units::length::meter_t>& position, virtual Vec3<units::length::meter_t> GetUpwardsShiftedLanePosition(const Vec3<units::length::meter_t>& position,
double upwards_shift, double upwards_shift,
bool allow_invalid_positions = false) const = 0; bool allow_invalid_positions = false) const = 0;
virtual bool IsPositionOnLane(const Vec3<units::length::meter_t>& position) const = 0; virtual bool IsPositionOnLane(const Vec3<units::length::meter_t>& position) const = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -21,43 +21,42 @@ ...@@ -21,43 +21,42 @@
namespace mantle_api namespace mantle_api
{ {
enum class LaneId enum class LaneId
{ {
kLeft9, kLeft9,
kLeft8, kLeft8,
kLeft7, kLeft7,
kLeft6, kLeft6,
kLeft5, kLeft5,
kLeft4, kLeft4,
kLeft3, kLeft3,
kLeft2, kLeft2,
kLeft1, kLeft1,
kRef, kRef,
kRight1, kRight1,
kRight2, kRight2,
kRight3, kRight3,
kRight4, kRight4,
kRight5, kRight5,
kRight6, kRight6,
kRight7, kRight7,
kRight8, kRight8,
kRight9 kRight9
}; };
class IRoute : public virtual IIdentifiable class IRoute : public virtual IIdentifiable
{ {
public: public:
virtual IRoute& AddWaypoint(const Vec3<units::length::meter_t>& inert_pos) = 0; virtual IRoute& AddWaypoint(const Vec3<units::length::meter_t>& inert_pos) = 0;
virtual IRoute& AddWaypoint(Vec3<units::length::meter_t>&& inert_pos) = 0; virtual IRoute& AddWaypoint(Vec3<units::length::meter_t>&& inert_pos) = 0;
virtual Vec3<units::length::meter_t> GetInertPos(units::length::meter_t route_pos, virtual Vec3<units::length::meter_t> GetInertPos(units::length::meter_t route_pos,
LaneId lane_id, LaneId lane_id,
units::length::meter_t lane_offset = units::length::meter_t{ units::length::meter_t lane_offset = units::length::meter_t{
0.0}) const = 0; 0.0}) const = 0;
virtual units::length::meter_t GetLaneWidth(units::length::meter_t route_pos, LaneId lane_id) const = 0; virtual units::length::meter_t GetLaneWidth(units::length::meter_t route_pos, LaneId lane_id) const = 0;
virtual LaneId GetLaneId(const Vec3<units::length::meter_t>& inert_pos) const = 0; virtual LaneId GetLaneId(const Vec3<units::length::meter_t>& inert_pos) const = 0;
virtual units::length::meter_t GetDistanceFromStartTo(const Vec3<units::length::meter_t>& inert_pos) const = 0; virtual units::length::meter_t GetDistanceFromStartTo(const Vec3<units::length::meter_t>& inert_pos) const = 0;
virtual units::length::meter_t GetLength() const = 0; virtual units::length::meter_t GetLength() const = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -16,196 +16,195 @@ ...@@ -16,196 +16,195 @@
#define MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H #define MANTLEAPI_TRAFFIC_CONTROLSTRATEGY_H
#include <MantleAPI/Common/spline.h> #include <MantleAPI/Common/spline.h>
#include <MantleAPI/Common/vector.h>
#include <MantleAPI/Common/trajectory.h> #include <MantleAPI/Common/trajectory.h>
#include <MantleAPI/Common/vector.h>
#include <vector> #include <vector>
namespace mantle_api namespace mantle_api
{ {
enum class MovementDomain enum class MovementDomain
{ {
kUndefined = 0, kUndefined = 0,
kLateral, kLateral,
kLongitudinal, kLongitudinal,
kBoth kBoth
}; };
enum class ControlStrategyType enum class ControlStrategyType
{ {
kUndefined = 0, kUndefined = 0,
kKeepVelocity, kKeepVelocity,
kKeepLaneOffset, kKeepLaneOffset,
kFollowHeadingSpline, kFollowHeadingSpline,
kFollowLateralOffsetSpline, kFollowLateralOffsetSpline,
kFollowVelocitySpline, kFollowVelocitySpline,
kFollowRoute, kFollowRoute,
kAcquireLaneOffset, kAcquireLaneOffset,
kFollowTrajectory kFollowTrajectory
}; };
struct ControlStrategy struct ControlStrategy
{ {
virtual ~ControlStrategy() = default; virtual ~ControlStrategy() = default;
// TODO: extend by bool use_dynamic_constraints when needed (false assumed at the moment) // TODO: extend by bool use_dynamic_constraints when needed (false assumed at the moment)
MovementDomain movement_domain{MovementDomain::kUndefined}; MovementDomain movement_domain{MovementDomain::kUndefined};
ControlStrategyType type{ControlStrategyType::kUndefined}; ControlStrategyType type{ControlStrategyType::kUndefined};
}; };
inline bool operator==(const ControlStrategy& lhs, const ControlStrategy& rhs) noexcept inline bool operator==(const ControlStrategy& lhs, const ControlStrategy& rhs) noexcept
{ {
return lhs.movement_domain == rhs.movement_domain && lhs.type == rhs.type; return lhs.movement_domain == rhs.movement_domain && lhs.type == rhs.type;
} }
inline bool operator!=(const ControlStrategy& lhs, const ControlStrategy& rhs) noexcept inline bool operator!=(const ControlStrategy& lhs, const ControlStrategy& rhs) noexcept
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
struct KeepVelocityControlStrategy : public ControlStrategy struct KeepVelocityControlStrategy : public ControlStrategy
{ {
KeepVelocityControlStrategy() KeepVelocityControlStrategy()
{ {
movement_domain = MovementDomain::kLongitudinal; movement_domain = MovementDomain::kLongitudinal;
type = ControlStrategyType::kKeepVelocity; type = ControlStrategyType::kKeepVelocity;
} }
// Doesn't need configuration attributes. Controller keeps current velocity on adding entity or update // Doesn't need configuration attributes. Controller keeps current velocity on adding entity or update
}; };
struct KeepLaneOffsetControlStrategy : public ControlStrategy struct KeepLaneOffsetControlStrategy : public ControlStrategy
{ {
KeepLaneOffsetControlStrategy() KeepLaneOffsetControlStrategy()
{ {
movement_domain = MovementDomain::kLateral; movement_domain = MovementDomain::kLateral;
type = ControlStrategyType::kKeepLaneOffset; type = ControlStrategyType::kKeepLaneOffset;
} }
// Doesn't need configuration attributes. Controller keeps current lane offset on adding entity or update // Doesn't need configuration attributes. Controller keeps current lane offset on adding entity or update
}; };
struct FollowHeadingSplineControlStrategy : public ControlStrategy struct FollowHeadingSplineControlStrategy : public ControlStrategy
{ {
FollowHeadingSplineControlStrategy() FollowHeadingSplineControlStrategy()
{ {
movement_domain = MovementDomain::kLateral; movement_domain = MovementDomain::kLateral;
type = ControlStrategyType::kFollowHeadingSpline; type = ControlStrategyType::kFollowHeadingSpline;
} }
std::vector<mantle_api::SplineSection<units::angle::radian_t>> heading_splines; std::vector<mantle_api::SplineSection<units::angle::radian_t>> heading_splines;
double default_value{0}; double default_value{0};
}; };
struct FollowVelocitySplineControlStrategy : public ControlStrategy struct FollowVelocitySplineControlStrategy : public ControlStrategy
{ {
FollowVelocitySplineControlStrategy() FollowVelocitySplineControlStrategy()
{ {
movement_domain = MovementDomain::kLongitudinal; movement_domain = MovementDomain::kLongitudinal;
type = ControlStrategyType::kFollowVelocitySpline; type = ControlStrategyType::kFollowVelocitySpline;
} }
std::vector<mantle_api::SplineSection<units::velocity::meters_per_second_t>> velocity_splines; std::vector<mantle_api::SplineSection<units::velocity::meters_per_second_t>> velocity_splines;
double default_value{0}; double default_value{0};
}; };
inline bool operator==(const FollowVelocitySplineControlStrategy& lhs, inline bool operator==(const FollowVelocitySplineControlStrategy& lhs,
const FollowVelocitySplineControlStrategy& rhs) noexcept const FollowVelocitySplineControlStrategy& rhs) noexcept
{ {
return lhs.default_value == rhs.default_value && lhs.velocity_splines == rhs.velocity_splines; return lhs.default_value == rhs.default_value && lhs.velocity_splines == rhs.velocity_splines;
} }
inline bool operator!=(const FollowVelocitySplineControlStrategy& lhs, inline bool operator!=(const FollowVelocitySplineControlStrategy& lhs,
const FollowVelocitySplineControlStrategy& rhs) noexcept const FollowVelocitySplineControlStrategy& rhs) noexcept
{ {
return !(lhs == rhs); return !(lhs == rhs);
} }
struct FollowLateralOffsetSplineControlStrategy : public ControlStrategy struct FollowLateralOffsetSplineControlStrategy : public ControlStrategy
{ {
FollowLateralOffsetSplineControlStrategy() FollowLateralOffsetSplineControlStrategy()
{ {
movement_domain = MovementDomain::kLateral; movement_domain = MovementDomain::kLateral;
type = ControlStrategyType::kFollowLateralOffsetSpline; type = ControlStrategyType::kFollowLateralOffsetSpline;
} }
std::vector<mantle_api::SplineSection<units::length::meter_t>> lateral_offset_splines; std::vector<mantle_api::SplineSection<units::length::meter_t>> lateral_offset_splines;
}; };
struct FollowRouteControlStrategy : public ControlStrategy struct FollowRouteControlStrategy : public ControlStrategy
{ {
FollowRouteControlStrategy() FollowRouteControlStrategy()
{ {
movement_domain = MovementDomain::kLateral; movement_domain = MovementDomain::kLateral;
type = ControlStrategyType::kFollowRoute; type = ControlStrategyType::kFollowRoute;
} }
std::vector<mantle_api::Vec3<units::length::meter_t>> waypoints; std::vector<mantle_api::Vec3<units::length::meter_t>> waypoints;
}; };
enum class Dimension enum class Dimension
{ {
kUndefined = 0, kUndefined = 0,
kDistance, kDistance,
kRate, kRate,
kTime kTime
}; };
enum class Shape enum class Shape
{ {
kUndefined = 0, kUndefined = 0,
kStep, kStep,
kCubic, kCubic,
kLinear, kLinear,
kSinusoidal kSinusoidal
}; };
struct TransitionDynamics struct TransitionDynamics
{ {
Dimension dimension{Dimension::kUndefined}; Dimension dimension{Dimension::kUndefined};
Shape shape{Shape::kUndefined}; Shape shape{Shape::kUndefined};
double value{0.0}; double value{0.0};
}; };
struct AcquireLaneOffsetControlStrategy : public ControlStrategy struct AcquireLaneOffsetControlStrategy : public ControlStrategy
{ {
AcquireLaneOffsetControlStrategy() AcquireLaneOffsetControlStrategy()
{ {
movement_domain = MovementDomain::kLateral; movement_domain = MovementDomain::kLateral;
type = ControlStrategyType::kAcquireLaneOffset; type = ControlStrategyType::kAcquireLaneOffset;
} }
int road_id{}; int road_id{};
int lane_id{}; int lane_id{};
units::length::meter_t offset{}; units::length::meter_t offset{};
TransitionDynamics transition_dynamics; TransitionDynamics transition_dynamics;
}; };
enum class ReferenceContext enum class ReferenceContext
{ {
kAbsolute = 0, kAbsolute = 0,
kRelative kRelative
}; };
struct FollowTrajectoryControlStrategy : public ControlStrategy struct FollowTrajectoryControlStrategy : public ControlStrategy
{ {
// TODO: Extend the FollowTrajectoryControlStrategy to support shapes like NURBS and clothoid // TODO: Extend the FollowTrajectoryControlStrategy to support shapes like NURBS and clothoid
struct TrajectoryTimeReference struct TrajectoryTimeReference
{ {
ReferenceContext domainAbsoluteRelative; ReferenceContext domainAbsoluteRelative;
double scale{0.0}; double scale{0.0};
double offset{0.0}; double offset{0.0};
}; };
FollowTrajectoryControlStrategy() FollowTrajectoryControlStrategy()
{ {
movement_domain = MovementDomain::kBoth; movement_domain = MovementDomain::kBoth;
type = ControlStrategyType::kFollowTrajectory; type = ControlStrategyType::kFollowTrajectory;
} }
Trajectory trajectory; Trajectory trajectory;
std::optional<TrajectoryTimeReference> timeReference; std::optional<TrajectoryTimeReference> timeReference;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -21,17 +21,16 @@ ...@@ -21,17 +21,16 @@
namespace mantle_api namespace mantle_api
{ {
void SetSpeed(mantle_api::IEntity* entity, double velocity) void SetSpeed(mantle_api::IEntity* entity, double velocity)
{ {
auto orientation = entity->GetOrientation(); auto orientation = entity->GetOrientation();
double cos_elevation = std::cos(orientation.pitch); double cos_elevation = std::cos(orientation.pitch);
mantle_api::Vec3d velocity_vector{velocity * std::cos(orientation.yaw) * cos_elevation, mantle_api::Vec3d velocity_vector{velocity * std::cos(orientation.yaw) * cos_elevation,
velocity * std::sin(orientation.yaw) * cos_elevation, velocity * std::sin(orientation.yaw) * cos_elevation,
velocity * -std::sin(orientation.pitch)}; velocity * -std::sin(orientation.pitch)};
entity->SetVelocity(velocity_vector); entity->SetVelocity(velocity_vector);
} }
} // namespace mantle_api } // namespace mantle_api
......
...@@ -19,154 +19,153 @@ ...@@ -19,154 +19,153 @@
#include <MantleAPI/Common/floating_point_helper.h> #include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/vector.h> #include <MantleAPI/Common/vector.h>
#include <string>
#include <map> #include <map>
#include <string>
namespace mantle_api namespace mantle_api
{ {
enum class EntityType enum class EntityType
{ {
// Other (unspecified but known) type of moving object. // Other (unspecified but known) type of moving object.
kOther = 1, kOther = 1,
// Object is a vehicle. // Object is a vehicle.
kVehicle = 2, kVehicle = 2,
// Object is a pedestrian. // Object is a pedestrian.
kPedestrian = 3, kPedestrian = 3,
// Object is an animal. // Object is an animal.
kAnimal = 4 kAnimal = 4
}; };
/// Basic properties that describe scenario entities. /// Basic properties that describe scenario entities.
struct EntityProperties struct EntityProperties
{ {
virtual ~EntityProperties() = default; virtual ~EntityProperties() = default;
BoundingBox bounding_box{}; BoundingBox bounding_box{};
EntityType type{EntityType::kOther}; EntityType type{EntityType::kOther};
std::string model{}; std::string model{};
std::map<std::string, std::string> properties{}; std::map<std::string, std::string> properties{};
}; };
inline bool operator==(const EntityProperties& lhs, const EntityProperties& rhs) noexcept inline bool operator==(const EntityProperties& lhs, const EntityProperties& rhs) noexcept
{ {
return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model; return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model;
} }
enum class VehicleClass enum class VehicleClass
{ {
kOther = 1, // Other (unspecified but known) type of vehicle. kOther = 1, // Other (unspecified but known) type of vehicle.
// Vehicle is a small car. // Vehicle is a small car.
// Definition: Hatchback car with maximum length 4 m. // Definition: Hatchback car with maximum length 4 m.
kSmall_car = 2, kSmall_car = 2,
// Vehicle is a compact car. // Vehicle is a compact car.
// Definition: Hatchback car with length between 4 and 4.5 m. // Definition: Hatchback car with length between 4 and 4.5 m.
kCompact_car = 3, kCompact_car = 3,
// Vehicle is a medium car. // Vehicle is a medium car.
// Definition: Hatchback or sedan with length between 4.5 and 5 m. // Definition: Hatchback or sedan with length between 4.5 and 5 m.
kMedium_car = 4, kMedium_car = 4,
// Vehicle is a luxury car. // Vehicle is a luxury car.
// Definition: Sedan or coupe that is longer then 5 m. // Definition: Sedan or coupe that is longer then 5 m.
kLuxury_car = 5, kLuxury_car = 5,
// Vehicle is a delivery van. // Vehicle is a delivery van.
// Definition: A delivery van. // Definition: A delivery van.
kDelivery_van = 6, kDelivery_van = 6,
// Vehicle is a heavy truck. // Vehicle is a heavy truck.
kHeavy_truck = 7, kHeavy_truck = 7,
// Vehicle is a truck with semitrailer. // Vehicle is a truck with semitrailer.
kSemitrailer = 8, kSemitrailer = 8,
// Vehicle is a trailer (possibly attached to another vehicle). // Vehicle is a trailer (possibly attached to another vehicle).
kTrailer = 9, kTrailer = 9,
// Vehicle is a motorbike or moped. // Vehicle is a motorbike or moped.
kMotorbike = 10, kMotorbike = 10,
// Vehicle is a bicycle (without motor and specific lights). // Vehicle is a bicycle (without motor and specific lights).
kBicycle = 11, kBicycle = 11,
// Vehicle is a bus. // Vehicle is a bus.
kBus = 12, kBus = 12,
// Vehicle is a tram. // Vehicle is a tram.
kTram = 13, kTram = 13,
// Vehicle is a train. // Vehicle is a train.
kTrain = 14, kTrain = 14,
// Vehicle is a wheelchair. // Vehicle is a wheelchair.
kWheelchair = 15, kWheelchair = 15,
// Vehicle type not specified properly. // Vehicle type not specified properly.
kInvalid = -1 kInvalid = -1
}; };
enum class IndicatorState enum class IndicatorState
{ {
// Indicator state is unknown (must not be used in ground truth). // Indicator state is unknown (must not be used in ground truth).
kUnknown = 0, kUnknown = 0,
// Other (unspecified but known) state of indicator. // Other (unspecified but known) state of indicator.
kOther = 1, kOther = 1,
// Indicators are off. // Indicators are off.
kOff = 2, kOff = 2,
// Left indicator is on. // Left indicator is on.
kLeft = 3, kLeft = 3,
// Right indicator is on. // Right indicator is on.
kRight = 4, kRight = 4,
// Hazard/warning light, i.e. both indicators, are on. // Hazard/warning light, i.e. both indicators, are on.
kWarning = 5 kWarning = 5
}; };
enum class ExternalControlState enum class ExternalControlState
{ {
kOff = 0, kOff = 0,
kFull = 1, kFull = 1,
kLateralOnly = 2, kLateralOnly = 2,
kLongitudinalOnly = 3 kLongitudinalOnly = 3
}; };
struct Performance struct Performance
{ {
units::velocity::meters_per_second_t max_speed{0.0}; units::velocity::meters_per_second_t max_speed{0.0};
units::acceleration::meters_per_second_squared_t max_acceleration{0.0}; units::acceleration::meters_per_second_squared_t max_acceleration{0.0};
units::acceleration::meters_per_second_squared_t max_deceleration{0.0}; units::acceleration::meters_per_second_squared_t max_deceleration{0.0};
}; };
inline bool operator==(const Performance& lhs, const Performance& rhs) noexcept inline bool operator==(const Performance& lhs, const Performance& rhs) noexcept
{ {
return IsEqual(lhs.max_speed, rhs.max_speed) && return IsEqual(lhs.max_speed, rhs.max_speed) &&
IsEqual(lhs.max_acceleration, rhs.max_acceleration) && IsEqual(lhs.max_acceleration, rhs.max_acceleration) &&
IsEqual(lhs.max_deceleration, rhs.max_deceleration); IsEqual(lhs.max_deceleration, rhs.max_deceleration);
} }
struct Axle struct Axle
{ {
units::angle::radian_t max_steering{0.0}; units::angle::radian_t max_steering{0.0};
units::length::meter_t wheel_diameter{0.0}; units::length::meter_t wheel_diameter{0.0};
units::length::meter_t track_width{0.0}; units::length::meter_t track_width{0.0};
Vec3<units::length::meter_t> bb_center_to_axle_center{}; Vec3<units::length::meter_t> bb_center_to_axle_center{};
}; };
inline bool operator==(const Axle& lhs, const Axle& rhs) noexcept inline bool operator==(const Axle& lhs, const Axle& rhs) noexcept
{ {
return IsEqual(lhs.max_steering, rhs.max_steering) && return IsEqual(lhs.max_steering, rhs.max_steering) &&
IsEqual(lhs.wheel_diameter, rhs.wheel_diameter) && IsEqual(lhs.wheel_diameter, rhs.wheel_diameter) &&
IsEqual(lhs.track_width, rhs.track_width) && IsEqual(lhs.track_width, rhs.track_width) &&
lhs.bb_center_to_axle_center == rhs.bb_center_to_axle_center; lhs.bb_center_to_axle_center == rhs.bb_center_to_axle_center;
} }
struct VehicleProperties : public EntityProperties struct VehicleProperties : public EntityProperties
{ {
VehicleClass classification{VehicleClass::kOther}; VehicleClass classification{VehicleClass::kOther};
Performance performance{}; Performance performance{};
Axle front_axle{}; Axle front_axle{};
Axle rear_axle{}; Axle rear_axle{};
bool is_host{false}; bool is_host{false};
// TODO: remove, once external control for traffic is implemented through controllers // TODO: remove, once external control for traffic is implemented through controllers
bool is_controlled_externally{false}; bool is_controlled_externally{false};
}; };
inline bool operator==(const VehicleProperties& lhs, const VehicleProperties& rhs) noexcept inline bool operator==(const VehicleProperties& lhs, const VehicleProperties& rhs) noexcept
{ {
return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model && return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model &&
lhs.classification == rhs.classification && lhs.performance == rhs.performance && lhs.classification == rhs.classification && lhs.performance == rhs.performance &&
lhs.front_axle == rhs.front_axle && lhs.rear_axle == rhs.rear_axle && lhs.front_axle == rhs.front_axle && lhs.rear_axle == rhs.rear_axle &&
lhs.is_host == rhs.is_host; lhs.is_host == rhs.is_host;
} }
struct PedestrianProperties : public EntityProperties struct PedestrianProperties : public EntityProperties
......
...@@ -27,48 +27,46 @@ ...@@ -27,48 +27,46 @@
namespace mantle_api namespace mantle_api
{ {
struct IControllerConfig struct IControllerConfig
{ {
IControllerConfig() {} IControllerConfig() {}
IControllerConfig(const IControllerConfig& controller_config) IControllerConfig(const IControllerConfig& controller_config)
: map_query_service(controller_config.map_query_service), id(controller_config.id) : map_query_service(controller_config.map_query_service), id(controller_config.id)
{ {
std::transform(controller_config.control_strategies.begin(), std::transform(controller_config.control_strategies.begin(),
controller_config.control_strategies.end(), controller_config.control_strategies.end(),
std::back_inserter(control_strategies), std::back_inserter(control_strategies),
[](auto& control_strategy) [](auto& control_strategy) { return std::make_unique<mantle_api::ControlStrategy>(*control_strategy); });
{ return std::make_unique<mantle_api::ControlStrategy>(*control_strategy); }); }
}
virtual ~IControllerConfig() = default; virtual ~IControllerConfig() = default;
// TODO: Check why map_query_service is part of the interface because it is not set from engine side but only in the // TODO: Check why map_query_service is part of the interface because it is not set from engine side but only in the
// environment on calling AddController() // environment on calling AddController()
ILaneLocationQueryService* map_query_service{nullptr}; ILaneLocationQueryService* map_query_service{nullptr};
std::uint64_t id{0}; std::uint64_t id{0};
std::vector<std::unique_ptr<mantle_api::ControlStrategy>> control_strategies; std::vector<std::unique_ptr<mantle_api::ControlStrategy>> control_strategies;
}; };
inline bool operator==(const IControllerConfig& lhs, const IControllerConfig& rhs) noexcept inline bool operator==(const IControllerConfig& lhs, const IControllerConfig& rhs) noexcept
{ {
bool control_strategies_equal = true; bool control_strategies_equal = true;
if (lhs.control_strategies.size() != rhs.control_strategies.size()) if (lhs.control_strategies.size() != rhs.control_strategies.size())
{
control_strategies_equal = false;
}
else
{
for (unsigned int i = 0; i < lhs.control_strategies.size(); i++)
{ {
if (*(lhs.control_strategies[i]) != *(rhs.control_strategies[i]))
{
control_strategies_equal = false; control_strategies_equal = false;
break;
}
} }
else }
{ return lhs.id == rhs.id && control_strategies_equal;
for (unsigned int i = 0; i < lhs.control_strategies.size(); i++)
{
if (*(lhs.control_strategies[i]) != *(rhs.control_strategies[i]))
{
control_strategies_equal = false;
break;
}
}
}
return lhs.id == rhs.id && control_strategies_equal;
} }
struct NoOpControllerConfig : public IControllerConfig struct NoOpControllerConfig : public IControllerConfig
...@@ -81,8 +79,8 @@ struct InternalControllerConfig : public IControllerConfig ...@@ -81,8 +79,8 @@ struct InternalControllerConfig : public IControllerConfig
struct ExternalControllerConfig : public IControllerConfig struct ExternalControllerConfig : public IControllerConfig
{ {
std::string name; std::string name;
std::map<std::string, std::string> parameters; std::map<std::string, std::string> parameters;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -26,61 +26,60 @@ ...@@ -26,61 +26,60 @@
namespace mantle_api namespace mantle_api
{ {
/// Base interface for all static and dynamic scenario entities. /// Base interface for all static and dynamic scenario entities.
class IEntity : public IIdentifiable class IEntity : public IIdentifiable
{ {
public: public:
virtual void SetPosition(const Vec3<units::length::meter_t>& inert_pos) = 0; virtual void SetPosition(const Vec3<units::length::meter_t>& inert_pos) = 0;
virtual Vec3<units::length::meter_t> GetPosition() const = 0; virtual Vec3<units::length::meter_t> GetPosition() const = 0;
virtual void SetVelocity(const Vec3<units::velocity::meters_per_second_t>& velocity) = 0; virtual void SetVelocity(const Vec3<units::velocity::meters_per_second_t>& velocity) = 0;
virtual Vec3<units::velocity::meters_per_second_t> GetVelocity() const = 0; virtual Vec3<units::velocity::meters_per_second_t> GetVelocity() const = 0;
virtual void SetAcceleration(const Vec3<units::acceleration::meters_per_second_squared_t>& acceleration) = 0; virtual void SetAcceleration(const Vec3<units::acceleration::meters_per_second_squared_t>& acceleration) = 0;
virtual Vec3<units::acceleration::meters_per_second_squared_t> GetAcceleration() const = 0; virtual Vec3<units::acceleration::meters_per_second_squared_t> GetAcceleration() const = 0;
virtual void SetOrientation(const Orientation3<units::angle::radian_t>& orientation) = 0; virtual void SetOrientation(const Orientation3<units::angle::radian_t>& orientation) = 0;
virtual Orientation3<units::angle::radian_t> GetOrientation() const = 0; virtual Orientation3<units::angle::radian_t> GetOrientation() const = 0;
virtual void SetOrientationRate( virtual void SetOrientationRate(
const Orientation3<units::angular_velocity::radians_per_second_t>& orientation_rate) = 0; const Orientation3<units::angular_velocity::radians_per_second_t>& orientation_rate) = 0;
virtual Orientation3<units::angular_velocity::radians_per_second_t> GetOrientationRate() const = 0; virtual Orientation3<units::angular_velocity::radians_per_second_t> GetOrientationRate() const = 0;
virtual void SetOrientationAcceleration( virtual void SetOrientationAcceleration(
const Orientation3<units::angular_acceleration::radians_per_second_squared_t>& orientation_acceleration) = 0; const Orientation3<units::angular_acceleration::radians_per_second_squared_t>& orientation_acceleration) = 0;
virtual Orientation3<units::angular_acceleration::radians_per_second_squared_t> GetOrientationAcceleration() virtual Orientation3<units::angular_acceleration::radians_per_second_squared_t> GetOrientationAcceleration()
const = 0; const = 0;
virtual void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) = 0; virtual void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) = 0;
virtual EntityProperties* GetProperties() const = 0; virtual EntityProperties* GetProperties() const = 0;
virtual void SetAssignedLaneIds(const std::vector<std::uint64_t>& assigned_lane_ids) = 0; virtual void SetAssignedLaneIds(const std::vector<std::uint64_t>& assigned_lane_ids) = 0;
virtual std::vector<std::uint64_t> GetAssignedLaneIds() const = 0; virtual std::vector<std::uint64_t> GetAssignedLaneIds() const = 0;
}; };
class IVehicle : public virtual IEntity class IVehicle : public virtual IEntity
{ {
public: public:
virtual VehicleProperties* GetProperties() const = 0; virtual VehicleProperties* GetProperties() const = 0;
virtual void SetIndicatorState(IndicatorState state) = 0; virtual void SetIndicatorState(IndicatorState state) = 0;
virtual IndicatorState GetIndicatorState() const = 0; virtual IndicatorState GetIndicatorState() const = 0;
// virtual bool IsHost() const = 0; // virtual bool IsHost() const = 0;
// virtual void SetHost() = 0; // virtual void SetHost() = 0;
}; };
class IPedestrian : public virtual IEntity class IPedestrian : public virtual IEntity
{ {
public: public:
virtual PedestrianProperties* GetProperties() const = 0; virtual PedestrianProperties* GetProperties() const = 0;
}; };
class IStaticObject : public virtual IEntity class IStaticObject : public virtual IEntity
{ {
public: public:
virtual StaticObjectProperties* GetProperties() const = 0; virtual StaticObjectProperties* GetProperties() const = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -28,27 +28,27 @@ namespace mantle_api ...@@ -28,27 +28,27 @@ namespace mantle_api
/// This interface provides CRUD functionality for scenario entities. /// This interface provides CRUD functionality for scenario entities.
class IEntityRepository class IEntityRepository
{ {
public: public:
virtual IVehicle& Create(const std::string& name, const VehicleProperties& properties) = 0; virtual IVehicle& Create(const std::string& name, const VehicleProperties& properties) = 0;
virtual IVehicle& Create(UniqueId id, const std::string& name, const VehicleProperties& properties) = 0; virtual IVehicle& Create(UniqueId id, const std::string& name, const VehicleProperties& properties) = 0;
virtual IPedestrian& Create(const std::string& name, const PedestrianProperties& properties) = 0; virtual IPedestrian& Create(const std::string& name, const PedestrianProperties& properties) = 0;
virtual IPedestrian& Create(UniqueId id, const std::string& name, const PedestrianProperties& properties) = 0; virtual IPedestrian& Create(UniqueId id, const std::string& name, const PedestrianProperties& properties) = 0;
virtual IStaticObject& Create(const std::string& name, const StaticObjectProperties& properties) = 0; virtual IStaticObject& Create(const std::string& name, const StaticObjectProperties& properties) = 0;
virtual IStaticObject& Create(UniqueId id, const std::string& name, const StaticObjectProperties& properties) = 0; virtual IStaticObject& Create(UniqueId id, const std::string& name, const StaticObjectProperties& properties) = 0;
virtual IVehicle& GetHost() = 0; virtual IVehicle& GetHost() = 0;
virtual std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) = 0; virtual std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) = 0;
virtual std::optional<std::reference_wrapper<IEntity>> Get(UniqueId id) = 0; virtual std::optional<std::reference_wrapper<IEntity>> Get(UniqueId id) = 0;
virtual bool Contains(UniqueId id) const = 0; virtual bool Contains(UniqueId id) const = 0;
virtual void Delete(const std::string& name) = 0; virtual void Delete(const std::string& name) = 0;
virtual void Delete(UniqueId id) = 0; virtual void Delete(UniqueId id) = 0;
virtual const std::vector<std::unique_ptr<mantle_api::IEntity>>& GetEntities() const = 0; virtual const std::vector<std::unique_ptr<mantle_api::IEntity>>& GetEntities() const = 0;
virtual void RegisterEntityCreatedCallback(const std::function<void(IEntity&)>& callback) = 0; virtual void RegisterEntityCreatedCallback(const std::function<void(IEntity&)>& callback) = 0;
virtual void RegisterEntityDeletedCallback(const std::function<void(const std::string&)>& callback) = 0; virtual void RegisterEntityDeletedCallback(const std::function<void(const std::string&)>& callback) = 0;
virtual void RegisterEntityDeletedCallback(const std::function<void(UniqueId)>& callback) = 0; virtual void RegisterEntityDeletedCallback(const std::function<void(UniqueId)>& callback) = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
This diff is collapsed.
...@@ -16,18 +16,18 @@ ...@@ -16,18 +16,18 @@
TEST(InterfaceTest, GivenTeleportAction_When_ThenHostVehicleIsPlaced) TEST(InterfaceTest, GivenTeleportAction_When_ThenHostVehicleIsPlaced)
{ {
mantle_api::Position inert_pos{}; mantle_api::Position inert_pos{};
inert_pos = mantle_api::OpenDrivePosition{{0, 0}, 0, 0}; inert_pos = mantle_api::OpenDrivePosition{{0, 0}, 0, 0};
mantle_api::MockEnvironment env{}; mantle_api::MockEnvironment env{};
env.CreateMap("dummy_map_path", {}); env.CreateMap("dummy_map_path", {});
mantle_api::VehicleProperties vehicle_properties; mantle_api::VehicleProperties vehicle_properties;
vehicle_properties.is_host = true; vehicle_properties.is_host = true;
vehicle_properties.model = "G12"; vehicle_properties.model = "G12";
auto& repo = env.GetEntityRepository(); auto& repo = env.GetEntityRepository();
auto& host_vehicle = repo.Create(0, "host", vehicle_properties); auto& host_vehicle = repo.Create(0, "host", vehicle_properties);
const auto* const converter = env.GetConverter(); const auto* const converter = env.GetConverter();
auto world_pos = converter->Convert(inert_pos); auto world_pos = converter->Convert(inert_pos);
host_vehicle.SetPosition(world_pos); host_vehicle.SetPosition(world_pos);
} }
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