Skip to content
Snippets Groups Projects
Commit 9eacba9e authored by Arun Das's avatar Arun Das
Browse files

Update and check control strategies for entity and not for controller; * and / operator for vectors


Signed-off-by: default avatarArun Das <arun.das@bmw.de>
parent 7f62c6d1
No related branches found
No related tags found
1 merge request!4Update and check control strategies for entity and not for controller; * and / operator for vectors
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* *
...@@ -17,11 +18,20 @@ ...@@ -17,11 +18,20 @@
#include <MantleAPI/Common/floating_point_helper.h> #include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/time_utils.h> #include <MantleAPI/Common/time_utils.h>
#include <MantleAPI/Common/vector.h>
#include <array> #include <array>
namespace mantle_api namespace mantle_api
{ {
struct SplineSegment
{
mantle_api::Vec3d a;
mantle_api::Vec3d b;
mantle_api::Vec3d c;
mantle_api::Vec3d d;
};
struct SplineSection struct SplineSection
{ {
mantle_api::Time start_time{0}; mantle_api::Time start_time{0};
......
...@@ -62,6 +62,16 @@ inline Vec3d operator*(const Vec3d& lhs, double d) noexcept ...@@ -62,6 +62,16 @@ inline Vec3d operator*(const Vec3d& 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*(double d, const Vec3d& rhs) noexcept
{
return rhs * d;
}
inline Vec3d operator/(const Vec3d& lhs, double d) noexcept
{
return {lhs.x / d, lhs.y / d, lhs.z / d};
}
} // namespace mantle_api } // namespace mantle_api
#endif // MANTLEAPI_COMMON_VECTOR_H #endif // MANTLEAPI_COMMON_VECTOR_H
...@@ -54,19 +54,19 @@ class IEnvironment ...@@ -54,19 +54,19 @@ class IEnvironment
virtual void RemoveControllerFromEntity(std::uint64_t entity_id) = 0; virtual void RemoveControllerFromEntity(std::uint64_t entity_id) = 0;
/// Updates the control strategies in the composite controller. /// Updates the control strategies for an entity.
/// ///
/// @param controller_id Specifies the controller 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(
std::uint64_t controller_id, std::uint64_t entity_id,
std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies) = 0; std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies) = 0;
/// Checks, if a control strategy of a certain type in a specific controller is fulfilled /// Checks, if a control strategy of a certain type for a specific entity has been fulfilled
/// ///
/// @param controller_id The controller to check /// @param entity_id The entity to check
/// @param type The control strategy type /// @param type The control strategy type
virtual bool HasControlStrategyGoalBeenReached(std::uint64_t controller_id, virtual bool HasControlStrategyGoalBeenReached(std::uint64_t entity_id,
mantle_api::ControlStrategyType type) const = 0; mantle_api::ControlStrategyType type) const = 0;
virtual const ILaneLocationQueryService& GetQueryService() const = 0; virtual const ILaneLocationQueryService& GetQueryService() const = 0;
......
...@@ -36,7 +36,9 @@ class ILaneLocationQueryService ...@@ -36,7 +36,9 @@ class ILaneLocationQueryService
// virtual const IIdentifiable& GetMapObjectById(UniqueId id) = 0; // virtual const IIdentifiable& GetMapObjectById(UniqueId id) = 0;
virtual Orientation3d GetLaneOrientation(const Vec3d& position) const = 0; virtual Orientation3d GetLaneOrientation(const Vec3d& position) const = 0;
virtual Vec3d GetUpwardsShiftedLanePosition(const Vec3d& position, double upwards_shift) const = 0; virtual Vec3d GetUpwardsShiftedLanePosition(const Vec3d& position,
double upwards_shift,
bool allow_invalid_positions = false) const = 0;
virtual bool IsPositionOnLane(const Vec3d& position) const = 0; virtual bool IsPositionOnLane(const Vec3d& position) const = 0;
}; };
} // namespace mantle_api } // namespace mantle_api
......
...@@ -46,7 +46,7 @@ class MockConverter : public mantle_api::ICoordConverter ...@@ -46,7 +46,7 @@ class MockConverter : public mantle_api::ICoordConverter
class MockVehicle : public mantle_api::IVehicle class MockVehicle : public mantle_api::IVehicle
{ {
public: public:
mantle_api::UniqueId GetUniqueId() const override { return 0; } MOCK_METHOD(mantle_api::UniqueId, GetUniqueId, (), (const, override));
void SetName(const std::string& name) override { name_ = name; } void SetName(const std::string& name) override { name_ = name; }
const std::string& GetName() const override { return name_; } const std::string& GetName() const override { return name_; }
...@@ -98,10 +98,13 @@ class MockQueryService : public mantle_api::ILaneLocationQueryService ...@@ -98,10 +98,13 @@ class MockQueryService : public mantle_api::ILaneLocationQueryService
return {}; return {};
} }
Vec3d GetUpwardsShiftedLanePosition(const Vec3d& position, double upwards_shift) const override Vec3d GetUpwardsShiftedLanePosition(const Vec3d& position,
double upwards_shift,
bool allowed_to_leave_lane = false) const override
{ {
std::ignore = position; std::ignore = position;
std::ignore = upwards_shift; std::ignore = upwards_shift;
std::ignore = allowed_to_leave_lane;
return mantle_api::Vec3d(); return mantle_api::Vec3d();
} }
bool IsPositionOnLane(const Vec3d& position) const override bool IsPositionOnLane(const Vec3d& position) const override
...@@ -304,13 +307,13 @@ class MockEnvironment : public mantle_api::IEnvironment ...@@ -304,13 +307,13 @@ class MockEnvironment : public mantle_api::IEnvironment
MOCK_METHOD(void, MOCK_METHOD(void,
UpdateControlStrategies, UpdateControlStrategies,
(std::uint64_t controller_id, (std::uint64_t entity_id,
std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies), std::vector<std::unique_ptr<mantle_api::ControlStrategy>>& control_strategies),
(override)); (override));
MOCK_METHOD(bool, MOCK_METHOD(bool,
HasControlStrategyGoalBeenReached, HasControlStrategyGoalBeenReached,
(std::uint64_t controller_id, mantle_api::ControlStrategyType type), (std::uint64_t entity_id, mantle_api::ControlStrategyType type),
(const, override)); (const, override));
const mantle_api::ILaneLocationQueryService& GetQueryService() const override { return query_service_; } const mantle_api::ILaneLocationQueryService& GetQueryService() const override { return query_service_; }
......
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