Commit 2f3630c6 authored by Andreas Rauschert's avatar Andreas Rauschert
Browse files

Merge branch 'bugfix/buildfix_define_function_in_header_inline' into 'master'

BMW Dev-branch

See merge request !16
parents 6e78b450 8607dec3
......@@ -19,6 +19,9 @@ cc_library(
visibility = [
"//visibility:public",
],
deps = [
"@units",
],
)
cc_library(
......
......@@ -15,12 +15,12 @@
#ifndef MANTLEAPI_EXECUTION_IENVIRONMENT_H
#define MANTLEAPI_EXECUTION_IENVIRONMENT_H
#include <MantleAPI/Common/simulation_time.h>
#include <MantleAPI/EnvironmentalConditions/date_time.h>
#include <MantleAPI/Common/time_utils.h>
#include <MantleAPI/EnvironmentalConditions/road_condition.h>
#include <MantleAPI/EnvironmentalConditions/weather.h>
#include <MantleAPI/Map/i_coord_converter.h>
#include <MantleAPI/Map/i_lane_location_query_service.h>
#include <MantleAPI/Map/map_details.h>
#include <MantleAPI/Traffic/i_entity_repository.h>
#include <string>
......@@ -36,7 +36,7 @@ public:
///
/// @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;
virtual void CreateMap(const std::string& map_file_path, const mantle_api::MapDetails& map_details) = 0;
/// Creates a controller from the given config. A created controller can be assigned to multiple entities
///
......@@ -73,11 +73,11 @@ public:
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;
virtual void SetDateTime(mantle_api::Time time) = 0;
virtual mantle_api::Time GetDateTime() = 0;
/// @brief Time since start of simulation and delta time to previous step
virtual SimulationTime GetSimulationTime() = 0;
/// @brief Time since start of simulation
virtual mantle_api::Time GetSimulationTime() = 0;
virtual void SetWeather(Weather weather) = 0;
virtual void SetRoadCondition(std::vector<FrictionPatch> friction_patches) = 0;
......
......@@ -19,6 +19,7 @@
#include <MantleAPI/Common/orientation.h>
#include <MantleAPI/Common/vector.h>
#include <units.h>
#include <vector>
namespace mantle_api
{
......@@ -41,6 +42,7 @@ public:
double upwards_shift,
bool allow_invalid_positions = false) const = 0;
virtual bool IsPositionOnLane(const Vec3<units::length::meter_t>& position) const = 0;
virtual std::vector<UniqueId> GetLaneIdsAtPosition(const Vec3<units::length::meter_t>& position) const = 0;
};
} // namespace mantle_api
......
......@@ -9,21 +9,24 @@
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file simulation_time.h */
/** @file map_details.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_SIMULATION_TIME_H
#define MANTLEAPI_COMMON_SIMULATION_TIME_H
#ifndef MANTLEAPI_MAP_MAPDETAILS_H
#define MANTLEAPI_MAP_MAPDETAILS_H
#include <MantleAPI/Common/time_utils.h>
#include <MantleAPI/Common/position.h>
#include <vector>
namespace mantle_api
{
struct SimulationTime
struct MapDetails
{
Time current_sim_time{0};
Time last_delta_time{0};
virtual ~MapDetails() = default;
std::vector<Position> map_region;
};
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_SIMULATION_TIME_H
#endif // MANTLEAPI_MAP_MAPDETAILS_H
......@@ -18,6 +18,7 @@
#include <MantleAPI/Common/spline.h>
#include <MantleAPI/Common/trajectory.h>
#include <MantleAPI/Common/vector.h>
#include <MantleAPI/Traffic/traffic_light_properties.h>
#include <vector>
......@@ -28,7 +29,8 @@ enum class MovementDomain
kUndefined = 0,
kLateral,
kLongitudinal,
kBoth
kBoth,
kNone
};
enum class ControlStrategyType
......@@ -41,7 +43,8 @@ enum class ControlStrategyType
kFollowVelocitySpline,
kFollowRoute,
kAcquireLaneOffset,
kFollowTrajectory
kFollowTrajectory,
kUpdateTrafficLightStates
};
struct ControlStrategy
......@@ -180,6 +183,18 @@ struct AcquireLaneOffsetControlStrategy : public ControlStrategy
TransitionDynamics transition_dynamics;
};
struct TrafficLightStateControlStrategy : public ControlStrategy
{
TrafficLightStateControlStrategy()
{
type = ControlStrategyType::kUpdateTrafficLightStates;
movement_domain = MovementDomain::kNone;
}
std::vector<TrafficLightPhase> traffic_light_phases{};
bool repeat_states{false};
};
enum class ReferenceContext
{
kAbsolute = 0,
......
......@@ -26,14 +26,16 @@ namespace mantle_api
{
enum class EntityType
{
// Other (unspecified but known) type of moving object.
// Other (unspecified but known)
kOther = 1,
// Object is a vehicle.
kVehicle = 2,
// Object is a pedestrian.
kPedestrian = 3,
// Object is an animal.
kAnimal = 4
kAnimal = 4,
// Object is static and does not move
kStatic = 5
};
/// Basic properties that describe scenario entities.
......@@ -41,7 +43,7 @@ struct EntityProperties
{
virtual ~EntityProperties() = default;
BoundingBox bounding_box{};
BoundingBox bounding_box{Vec3<units::length::meter_t>{}, Dimension3{}};
EntityType type{EntityType::kOther};
std::string model{};
std::map<std::string, std::string> properties{};
......
......@@ -26,6 +26,26 @@
namespace mantle_api
{
struct EntityVisibilityConfig
{
/// The "graphics" flag determines, if the entity shall be shown in visualizations of the simulated environment
bool graphics{true};
/// The "traffic" flag determines, if the entity is contained in the common simulator output (e.g. OSI Ground Truth)
/// for all traffic participants
bool traffic{true};
/// The "sensors" flag can be used to simulate sensor errors (false positives / false negatives). For this the
/// "sensors" flag value has to diverge from the "traffic" flag value (e.g. false positive: traffic=false,
/// sensors=true)
bool sensors{true};
/// - Sensor errors can be specified for single sensors only. E.g. a false positive for a radar sensor would be
/// specified with traffic="false", sensors="true", sensor_names={"radar"}.
/// - For the other not named sensors implicitly the opposite applies. So in the above example e.g. for a camera
/// sensor the entity would be not visible / not contained in its OSI Sensor View.
/// - When "sensor_names" is not specified (empty vector) then the "sensors" flag applies to
/// all sensors.
std::vector<std::string> sensor_names{};
};
/// Base interface for all static and dynamic scenario entities.
class IEntity : public IIdentifiable
{
......@@ -56,6 +76,9 @@ public:
virtual void SetAssignedLaneIds(const std::vector<std::uint64_t>& assigned_lane_ids) = 0;
virtual std::vector<std::uint64_t> GetAssignedLaneIds() const = 0;
virtual void SetVisibility(const EntityVisibilityConfig& visibility) = 0;
virtual EntityVisibilityConfig GetVisibility() const = 0;
};
class IVehicle : public virtual IEntity
......
......@@ -33,7 +33,7 @@ public:
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(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 mantle_api::StaticObjectProperties& properties) = 0;
virtual IStaticObject& Create(UniqueId id, const std::string& name, const StaticObjectProperties& properties) = 0;
virtual IVehicle& GetHost() = 0;
......
......@@ -9,21 +9,50 @@
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file date_time.h */
/** @file traffic_light_properties.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#define MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#ifndef MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H
#define MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H
#include <MantleAPI/Common/time_utils.h>
#include <vector>
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
enum class TrafficLightBulbColor
{
Time date_time{0};
kUnknown = 0,
kOther = 1,
kRed = 2,
kYellow = 3,
kGreen = 4,
kBlue = 5,
kWhite = 6
};
enum class TrafficLightBulbMode
{
kUnknown = 0,
kOther = 1,
kOff = 2,
kConstant = 3,
kFlashing = 4,
kCounting = 5
};
struct TrafficLightBulbState
{
TrafficLightBulbColor color;
TrafficLightBulbMode mode;
};
struct TrafficLightPhase
{
std::vector<TrafficLightBulbState> bulb_states;
mantle_api::Time start_time{0};
mantle_api::Time end_time{0};
};
} // namespace mantle_api
#endif // MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#endif // MANTLEAPI_TRAFFIC_TRAFFICLIGHTPROPERTIES_H
......@@ -35,7 +35,7 @@ class MockConverter : public mantle_api::ICoordConverter
public:
MOCK_METHOD(mantle_api::Vec3<units::length::meter_t>, Convert, (mantle_api::Position position), (const override));
mantle_api::Position Convert(mantle_api::Vec3<units::length::meter_t> vec) const override
mantle_api::Position Convert(const mantle_api::Vec3<units::length::meter_t>& vec) const override
{
std::ignore = vec;
return mantle_api::Position{};
......@@ -74,7 +74,10 @@ public:
MOCK_METHOD(void, SetAssignedLaneIds, (const std::vector<std::uint64_t>& ids), (override));
MOCK_METHOD(std::vector<std::uint64_t>, GetAssignedLaneIds, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { std::ignore = properties; }
MOCK_METHOD(void, SetVisibility, (const EntityVisibilityConfig& visibility), (override));
MOCK_METHOD(EntityVisibilityConfig, GetVisibility, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { properties_ = std::move(properties); }
mantle_api::VehicleProperties* GetProperties() const override
{
return static_cast<mantle_api::VehicleProperties*>(properties_.get());
......@@ -112,14 +115,20 @@ public:
return false;
}
private:
MockVehicle test_vehicle_{};
std::vector<UniqueId> GetLaneIdsAtPosition(const Vec3<units::length::meter_t>& position) const override
{
std::ignore = position;
return {};
}
private:
MockVehicle test_vehicle_{};
};
class MockPedestrian : public mantle_api::IPedestrian
{
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; }
const std::string& GetName() const override { return name_; }
......@@ -148,7 +157,10 @@ public:
MOCK_METHOD(void, SetAssignedLaneIds, (const std::vector<std::uint64_t>& ids), (override));
MOCK_METHOD(std::vector<std::uint64_t>, GetAssignedLaneIds, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { std::ignore = properties; }
MOCK_METHOD(void, SetVisibility, (const EntityVisibilityConfig& visibility), (override));
MOCK_METHOD(EntityVisibilityConfig, GetVisibility, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { properties_ = std::move(properties); }
mantle_api::PedestrianProperties* GetProperties() const override
{
return static_cast<mantle_api::PedestrianProperties*>(properties_.get());
......@@ -162,7 +174,7 @@ private:
class MockStaticObject : public mantle_api::IStaticObject
{
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; }
const std::string& GetName() const override { return name_; }
......@@ -191,7 +203,10 @@ public:
MOCK_METHOD(void, SetAssignedLaneIds, (const std::vector<std::uint64_t>& ids), (override));
MOCK_METHOD(std::vector<std::uint64_t>, GetAssignedLaneIds, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { std::ignore = properties; }
MOCK_METHOD(void, SetVisibility, (const EntityVisibilityConfig& visibility), (override));
MOCK_METHOD(EntityVisibilityConfig, GetVisibility, (), (const, override));
void SetProperties(std::unique_ptr<mantle_api::EntityProperties> properties) override { properties_ = std::move(properties); }
mantle_api::StaticObjectProperties* GetProperties() const override
{
return static_cast<mantle_api::StaticObjectProperties*>(properties_.get());
......@@ -235,11 +250,6 @@ public:
return test_pedestrian_;
}
MOCK_METHOD(mantle_api::IStaticObject&,
Create,
(const std::string& name, const mantle_api::StaticObjectProperties& properties),
(override));
mantle_api::IStaticObject& Create(mantle_api::UniqueId id,
const std::string& name,
const mantle_api::StaticObjectProperties& properties) override
......@@ -250,13 +260,18 @@ public:
return test_static_object_;
}
mantle_api::IEntity& Get(const std::string& name) override
MOCK_METHOD(mantle_api::IStaticObject&,
Create,
(const std::string& name, const mantle_api::StaticObjectProperties& properties),
());
std::optional<std::reference_wrapper<IEntity>> Get(const std::string& name) override
{
std::ignore = name;
return test_vehicle_;
}
mantle_api::IEntity& Get(mantle_api::UniqueId id) override
std::optional<std::reference_wrapper<IEntity>> Get(mantle_api::UniqueId id) override
{
std::ignore = id;
return test_vehicle_;
......@@ -274,8 +289,9 @@ public:
}
void Delete(UniqueId id) override { std::ignore = id; }
// const std::vector<mantle_api::IEntity>& GetEntities() const override { return <#initializer #>{}; }
// std::vector<mantle_api::IEntity>& GetEntities() override { return <#initializer #>; }
void RegisterEntityCreatedCallback(const std::function<void(IEntity&)>& callback) override { std::ignore = callback; }
void RegisterEntityDeletedCallback(const std::function<void(const std::string&)>& callback) override { std::ignore = callback; }
void RegisterEntityDeletedCallback(const std::function<void(UniqueId)>& callback) override { std::ignore = callback; }
private:
MockVehicle test_vehicle_{};
......@@ -289,7 +305,7 @@ class MockEnvironment : public mantle_api::IEnvironment
public:
MOCK_METHOD(void,
CreateMap,
(const std::string& file_path, const std::vector<mantle_api::Position>& map_region),
(const std::string& file_path, const mantle_api::MapDetails& map_details),
(override)
);
......@@ -330,11 +346,11 @@ public:
std::ignore = friction_patches;
}
void SetDateTime(mantle_api::DateTime date_time) override { std::ignore = date_time; }
void SetDateTime(mantle_api::Time date_time) override { std::ignore = date_time; }
mantle_api::DateTime GetDateTime() override { return mantle_api::DateTime(); }
mantle_api::Time GetDateTime() override { return mantle_api::Time(); }
MOCK_METHOD(mantle_api::SimulationTime, GetSimulationTime, (), (override));
MOCK_METHOD(mantle_api::Time, GetSimulationTime, (), (override));
private:
MockQueryService query_service_{};
......
......@@ -17,7 +17,7 @@
TEST(InterfaceTest, GivenTeleportAction_When_ThenHostVehicleIsPlaced)
{
mantle_api::Position inert_pos{};
inert_pos = mantle_api::OpenDrivePosition{{0, 0}, 0, 0};
inert_pos = mantle_api::OpenDrivePosition{{0, 0}, units::length::meter_t{0}, units::length::meter_t{0}};
mantle_api::MockEnvironment env{};
env.CreateMap("dummy_map_path", {});
......@@ -30,4 +30,5 @@ TEST(InterfaceTest, GivenTeleportAction_When_ThenHostVehicleIsPlaced)
const auto* const converter = env.GetConverter();
auto world_pos = converter->Convert(inert_pos);
host_vehicle.SetPosition(world_pos);
host_vehicle.SetVisibility(mantle_api::EntityVisibilityConfig{true, false, true, {"radar"}});
}
......@@ -4,3 +4,10 @@ A collection of interfaces for abstraction between a scenario engine and an envi
It is intended to be usable with a wide variety of scenario description languages by implementing according scenario engines.
Remark: This is currently work in progress and no stable state is reached yet.
## Used libraries
### Units
License: MIT License
URL: https://github.com/nholthaus/units
Version: v2.3.1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment