diff --git a/BUILD.bazel b/BUILD.bazel index 1241afd48a2b8ca915d26657c4eacf2b20c3dded..aa1f1e1bad8cfc0a80feb8ed575c594a9c05eafa 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -33,3 +33,10 @@ cc_test( srcs = ["test/interface_test.cpp"], deps = [":test_utils"], ) + +cc_test( + name = "map_interface_test", + timeout = "short", + srcs = ["test/MapAPI/Test/map_test.cpp"], + deps = [":test_utils"], +) diff --git a/include/MantleAPI/Common/vector.h b/include/MantleAPI/Common/vector.h index 23109ccc2e4d3a92abd917f21372a2192e4af084..14cdd68cd415a3868b8696ab4c4ee6d4b83fe69a 100644 --- a/include/MantleAPI/Common/vector.h +++ b/include/MantleAPI/Common/vector.h @@ -120,6 +120,13 @@ inline Vec3<T> operator-=(Vec3<T>& lhs, double d) noexcept return lhs; } +template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>> +struct Vec2 +{ + T x{0}; + T y{0}; +}; + } // namespace mantle_api #endif // MANTLEAPI_COMMON_VECTOR_H diff --git a/include/MapAPI/Common/base_properties.h b/include/MapAPI/Common/base_properties.h new file mode 100644 index 0000000000000000000000000000000000000000..e83230e632b52bb1bbfb8ba06ac3b152a3702ed5 --- /dev/null +++ b/include/MapAPI/Common/base_properties.h @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_BASEPROPERTIES_H +#define MANTLEAPI_MAPAPI_COMMON_BASEPROPERTIES_H + +#include <vector> + +#include "geometry.h" + +namespace mantle_api +{ +struct BaseProperties +{ + Dimension3d dimension; + Position3d position; + Orientation3d orientation; + std::vector<Vector2d> base_polygon; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_COMMON_BASEPROPERTIES_H diff --git a/include/MapAPI/Common/common.h b/include/MapAPI/Common/common.h new file mode 100644 index 0000000000000000000000000000000000000000..969ffc82119057462ce22cede8b2689e8888787b --- /dev/null +++ b/include/MapAPI/Common/common.h @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_COMMON_H +#define MANTLEAPI_MAPAPI_COMMON_COMMON_H + +#include <functional> + +#include "base_properties.h" +#include "external_reference.h" +#include "geometry.h" +#include "identifier.h" + +namespace mantle_api +{ + +template <typename T> +using RefWrapper = std::reference_wrapper<T>; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_COMMON_COMMON_H diff --git a/include/MapAPI/Common/external_reference.h b/include/MapAPI/Common/external_reference.h new file mode 100644 index 0000000000000000000000000000000000000000..bd589af0b017272790b179b7a5407710625f85ac --- /dev/null +++ b/include/MapAPI/Common/external_reference.h @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_EXTERNALREFERENCE_H +#define MANTLEAPI_MAPAPI_COMMON_EXTERNALREFERENCE_H + +#include <string> +#include <vector> + +namespace mantle_api +{ + +struct ExternalReference +{ + std::string reference; + std::string type; + std::vector<std::string> identifiers; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_COMMON_EXTERNALREFERENCE_H diff --git a/include/MapAPI/Common/geometry.h b/include/MapAPI/Common/geometry.h new file mode 100644 index 0000000000000000000000000000000000000000..224764744086ce0ddef10ba1b604525fdbe004a4 --- /dev/null +++ b/include/MapAPI/Common/geometry.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_GEOMETRY_H +#define MANTLEAPI_MAPAPI_COMMON_GEOMETRY_H + +#include "../include/MantleAPI/Common/dimension.h" +#include "../include/MantleAPI/Common/orientation.h" +#include "../include/MantleAPI/Common/vector.h" +#include "identifier.h" + +namespace mantle_api +{ + +using Vector2d = Vec2<units::length::meter_t>; +using Vector3d = Vec3<units::length::meter_t>; +using Dimension3d = Dimension3; +using Orientation3d = Orientation3<units::angle::radian_t>; + +using Position3d = Vector3d; + +} // namespace mantle_api + +#endif diff --git a/include/MapAPI/Common/identifier.h b/include/MapAPI/Common/identifier.h new file mode 100644 index 0000000000000000000000000000000000000000..603eee155b9a90fc3b4cecd665778ccf1f6378e3 --- /dev/null +++ b/include/MapAPI/Common/identifier.h @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_IDENTIFIER_H +#define MANTLEAPI_MAPAPI_COMMON_IDENTIFIER_H + +#include <cstdint> + +namespace mantle_api +{ + +using Identifier = std::uint64_t; +constexpr Identifier UndefinedId{std::numeric_limits<Identifier>::max()}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_COMMON_IDENTIFIER_H diff --git a/include/MapAPI/i_map_loader.h b/include/MapAPI/i_map_loader.h new file mode 100755 index 0000000000000000000000000000000000000000..193f5c9ea782b4b7eca2a433faaad8a083fe81e0 --- /dev/null +++ b/include/MapAPI/i_map_loader.h @@ -0,0 +1,26 @@ +#ifndef MANTLEAPI_MAPAPI_IMAPLOADER_H +#define MANTLEAPI_MAPAPI_IMAPLOADER_H + +#include <memory> +#include <string> + +#include "map.h" + +namespace mantle_api +{ + +class IMapLoader +{ +public: + virtual ~IMapLoader() = default; + + /// @brief Load a map from the given file. + /// @param map_file The path to the map input file. + /// @return A unique pointer to the loaded map object. If the file cannot be opened or the contents are invalid, + /// an exception will be thrown. + virtual [[nodiscard]] std::unique_ptr<Map> LoadMap(const std::string& map_file) const = 0; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_IMAPLOADER_H diff --git a/include/MapAPI/i_map_query.h b/include/MapAPI/i_map_query.h new file mode 100755 index 0000000000000000000000000000000000000000..1e881beda15e377bda27ae7796d1d4dd84b2a7d5 --- /dev/null +++ b/include/MapAPI/i_map_query.h @@ -0,0 +1,51 @@ +#ifndef MANTLEAPI_MAPAPI_IMAPQUERY_H +#define MANTLEAPI_MAPAPI_IMAPQUERY_H + +#include "map.h" + +namespace mantle_api +{ +class IMapQuery +{ +public: + virtual ~IMapQuery() = default; + + /// @brief Find a lane from a given lane id. + /// @param id The identifier of the lane. + /// @return A reference to the found lane object or 'std::nullopt' if not found. + virtual std::optional<RefWrapper<const Lane>> GetLaneById(Identifier id) const = 0; + + /// @brief Find a lane boundary from a given lane boundary id. + /// @param id The identifier of the lane boundary. + /// @return A reference to the found lane boundary or 'std::nullopt' if not found. + virtual std::optional<RefWrapper<const LaneBoundary>> GetLaneBoundaryById(Identifier id) const = 0; + + /// @brief For a given position, get the associated lanes. + /// @param position Position in Simulation space coordinates + /// @return List of lanes for the given position + virtual std::vector<RefWrapper<const Lane>> FindLanes(const Position3d& position) const = 0; + + /// @brief Given a line segment and a query point, compute the closest point to the query point that lays on the line + /// segment. + /// @param query_point point for which the closest point on the segment shall be returned + /// @param start start point of a line segment + /// @param end end point of a line segment + /// @return closest point on line segment + virtual Position3d ClosestPointOnLineSegment(const Position3d& query_point, const Position3d& start, const Position3d& end) const = 0; + + /// @brief Given a lane boundary and a query point, compute the closest point to the query point that lays on the lane + /// boundary. + /// @param query_point point for which the closest point on the boundary shall be returned + /// @param boundary lane boundary to find the closest point on + /// @return closest point on lane boundary + virtual Position3d ClosestPointOnBoundary(const Position3d& query_point, const LaneBoundary& boundary) const = 0; + + /// @todo the following interfaces are defined or intended to be defined in the Mantle API. Will be added after further discussion. + // GetLaneIdsAtPosition + // GetProjectedPoseAtLane + // ConvertLocaltoGlobal + // ConverGlobaltoLocal +}; +} // namespace mantle_api + +#endif // MANTLEAPI_MAPINTERFACE_IMAPQUERY_H diff --git a/include/MapAPI/lane.h b/include/MapAPI/lane.h new file mode 100644 index 0000000000000000000000000000000000000000..1b7c92bf8665e9cf673b42b81b4e0ed5855e47c8 --- /dev/null +++ b/include/MapAPI/lane.h @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_LANE_H +#define MANTLEAPI_MAPAPI_LANE_H + +#include <vector> + +#include "Common/common.h" +#include "lane_boundary.h" + +namespace mantle_api +{ +struct Lane; + +struct RoadCondition +{ + double surface_temperature; + double surface_water_film; + double surface_freezing_point; + double surface_ice; + double surface_roughness; + double surface_texture; +}; + +struct Lane +{ + using PolylinePoint = Vector3d; + using Polyline = std::vector<PolylinePoint>; + + enum class Type : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kDriving = 2, + kNonDriving = 3, + kIntersection = 4 + }; + + enum class Subtype : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNormal = 2, + kBiking = 3, + kSidewalk = 4, + kParking = 5, + kStop = 6, + kRestricted = 7, + kBorder = 8, + kShoulder = 9, + kExit = 10, + kEntry = 11, + kOnRamp = 12, + kOffRamp = 13, + kConnectingRamp = 14 + }; + + Identifier id{UndefinedId}; + Type type; + Subtype sub_type; + + /// @note: ordered with the driving direction + Polyline centerline; + + std::vector<RefWrapper<Lane>> left_adjacent_lanes; + std::vector<RefWrapper<Lane>> right_adjacent_lanes; + std::vector<RefWrapper<Lane>> successor_lanes; + std::vector<RefWrapper<Lane>> antecessor_lanes; + + std::vector<RefWrapper<LaneBoundary>> left_lane_boundaries; + std::vector<RefWrapper<LaneBoundary>> right_lane_boundaries; + std::vector<RefWrapper<LaneBoundary>> free_lane_boundaries; + + RoadCondition road_condition; + + std::vector<ExternalReference> source_references; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_LANE_H diff --git a/include/MapAPI/lane_boundary.h b/include/MapAPI/lane_boundary.h new file mode 100644 index 0000000000000000000000000000000000000000..7f2ce6db2b67beb799848f970cab9995773dd3fe --- /dev/null +++ b/include/MapAPI/lane_boundary.h @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_LANEBOUNDARY_H +#define MANTLEAPI_MAPAPI_LANEBOUNDARY_H + +#include <units.h> + +#include <vector> + +#include "Common/common.h" + +namespace mantle_api +{ + +struct StationaryObject; + +struct LaneBoundary +{ + struct BoundaryPoint + { + enum class Dash : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kStart = 2, + kContinue = 3, + kEnd = 4, + kGap = 5 + }; + + Position3d position; + units::length::meter_t width; + units::length::meter_t height; + Dash dash; + }; + + enum class Color : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNone = 2, + kWhite = 3, + kYellow = 4, + kRed = 5, + kBlue = 6, + kGreen = 7, + kViolet = 8, + kOrange = 9 + }; + + enum class Type : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNoLine = 2, + kSolidLine = 3, + kDashedLine = 4, + kBottsDots = 5, + kRoadEdge = 6, + kSnowEdge = 7, + kGrassEdge = 8, + kGravelEdge = 9, + kSoilEdge = 10, + kGuardRail = 11, + kCurb = 12, + kStructure = 13, + kBarrier = 14, + kSoundBarrier = 15 + }; + + Identifier id{UndefinedId}; + std::vector<BoundaryPoint> boundary_line; + Type type; + Color color; + + std::vector<RefWrapper<StationaryObject>> limiting_structures; + std::vector<ExternalReference> source_references; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_LANEBOUNDARY_H diff --git a/include/MapAPI/logical_lane.h b/include/MapAPI/logical_lane.h new file mode 100644 index 0000000000000000000000000000000000000000..0880ba3901348cb8b2cb237cf757ca2438844417 --- /dev/null +++ b/include/MapAPI/logical_lane.h @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_LOGICALLANE_H +#define MANTLEAPI_MAPAPI_LOGICALLANE_H + +#include <units.h> + +#include <vector> + +#include "Common/common.h" +#include "lane.h" +#include "logical_lane_boundary.h" +#include "reference_line.h" + +namespace mantle_api +{ + +struct LogicalLane; + +struct PhysicalLaneReference +{ + Lane& physical_lane; + units::length::meter_t start_s; + units::length::meter_t end_s; +}; + +struct LogicalLaneRelation +{ + LogicalLane& other_lane; + units::length::meter_t start_s; + units::length::meter_t end_s; + units::length::meter_t start_s_other; + units::length::meter_t end_s_other; +}; + +struct LogicalLane +{ + enum class Type : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNormal = 2, + kBiking = 3, + kSidewalk = 4, + kParking = 5, + kStop = 6, + kRestricted = 7, + kBorder = 8, + kShoulder = 9, + kExit = 10, + kEntry = 11, + kOnramp = 12, + kOfframp = 13, + kConnectingramp = 14, + kMedian = 15, + kCurb = 16, + kRail = 17, + kTram = 18 + }; + + /// @ref osi3::LogicalLane::MoveDirection + /// @see \link https://github.com/OpenSimulationInterface/open-simulation-interface/tree/v3.5.0 \endlink + enum class MoveDirection : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kIncreasingS = 2, + kDecreasingS = 3, + kBothAllowed = 4 + }; + + Identifier id{UndefinedId}; + units::length::meter_t start_s; + units::length::meter_t end_s; + + ReferenceLine* reference_line; + + Type type; + + std::vector<ExternalReference> source_references; + std::vector<PhysicalLaneReference> physical_lane_references; + + MoveDirection move_direction; + std::vector<LogicalLaneRelation> right_adjacent_lanes; + std::vector<LogicalLaneRelation> left_adjacent_lanes; + std::vector<LogicalLaneRelation> overlapping_lanes; + std::vector<RefWrapper<LogicalLaneBoundary>> right_boundaries; + std::vector<RefWrapper<LogicalLaneBoundary>> left_boundaries; + + std::vector<RefWrapper<LogicalLane>> predecessor_lanes; + std::vector<RefWrapper<LogicalLane>> successor_lanes; + + +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_LOGICALLANE_H diff --git a/include/MapAPI/logical_lane_assignment.h b/include/MapAPI/logical_lane_assignment.h new file mode 100644 index 0000000000000000000000000000000000000000..9292e0aa4b88e31d67b844a06a375d27e9285cdf --- /dev/null +++ b/include/MapAPI/logical_lane_assignment.h @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_COMMON_LOGICALLANEASSIGNMENT_H +#define MANTLEAPI_MAPAPI_COMMON_LOGICALLANEASSIGNMENT_H + +#include <units.h> + +#include "logical_lane.h" + +namespace mantle_api +{ +struct LogicalLaneAssignment +{ + LogicalLane& assigned_lane; + units::length::meter_t s_position; + units::length::meter_t t_position; + units::angle::radian_t angle_to_lane; +}; +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_COMMON_LOGICALLANEASSIGNMENT_H diff --git a/include/MapAPI/logical_lane_boundary.h b/include/MapAPI/logical_lane_boundary.h new file mode 100644 index 0000000000000000000000000000000000000000..b4007e45a4f650417f1a35437a761ffdaad419ff --- /dev/null +++ b/include/MapAPI/logical_lane_boundary.h @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_LOGICLANEBOUNDARY_H +#define MANTLEAPI_MAPAPI_LOGICLANEBOUNDARY_H + +#include <units.h> + +#include <vector> + +#include "Common/common.h" +#include "lane_boundary.h" +#include "reference_line.h" + +namespace mantle_api +{ +struct LogicalBoundaryPoint +{ + Position3d position; + units::length::meter_t s_position; + units::length::meter_t t_position; +}; + +struct LogicalLaneBoundary +{ + /// @ref osi3::LogicalLaneBoundary::PassingRule + /// @see \link https://github.com/OpenSimulationInterface/open-simulation-interface/tree/v3.5.0 \endlink + enum class PassingRule : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNoneAllowed = 2, + kIncreasingT = 3, + kDecreasingT = 4, + kBothAllowed = 5 + }; + + Identifier id{UndefinedId}; + std::vector<LogicalBoundaryPoint> boundary_line; + PassingRule passing_rule; + ReferenceLine* reference_line; + std::vector<RefWrapper<LaneBoundary>> physical_boundaries; + std::vector<ExternalReference> source_references; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_LOGICALLANEBOUNDARY_H diff --git a/include/MapAPI/map.h b/include/MapAPI/map.h new file mode 100644 index 0000000000000000000000000000000000000000..1f5b6ae4be8fff0ba20fe445ac6c36f2845cd688 --- /dev/null +++ b/include/MapAPI/map.h @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_MAP_H +#define MANTLEAPI_MAPAPI_MAP_H + +#include <memory> +#include <string> +#include <vector> + +#include "lane.h" +#include "lane_boundary.h" +#include "logical_lane.h" +#include "logical_lane_boundary.h" +#include "reference_line.h" +#include "stationary_object.h" +#include "traffic_light.h" +#include "traffic_sign.h" + +namespace mantle_api +{ + +struct Map +{ + using Lanes = std::vector<std::unique_ptr<Lane>>; + using LaneBoundaries = std::vector<std::unique_ptr<LaneBoundary>>; + using LogicalLanes = std::vector<std::unique_ptr<LogicalLane>>; + using LogicalLaneBoundaries = std::vector<std::unique_ptr<LogicalLaneBoundary>>; + using TrafficLights = std::vector<std::unique_ptr<TrafficLight>>; + using TrafficSigns = std::vector<std::unique_ptr<TrafficSign>>; + using ReferenceLines = std::vector<std::unique_ptr<ReferenceLine>>; + using StationaryObjects = std::vector<std::unique_ptr<StationaryObject>>; + + std::string projection_string; + std::string map_reference; + std::uint32_t country_code{std::numeric_limits<std::uint32_t>::max()}; + + Lanes lanes; + LaneBoundaries lane_boundaries; + LogicalLanes logical_lanes; + LogicalLaneBoundaries logical_lane_boundaries; + StationaryObjects stationary_objects; + TrafficLights traffic_lights; + TrafficSigns traffic_signs; + ReferenceLines reference_lines; +}; +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_MAP_H diff --git a/include/MapAPI/reference_line.h b/include/MapAPI/reference_line.h new file mode 100644 index 0000000000000000000000000000000000000000..a3df59a4e1142dd0a3f4a158cbcd3ab7e45d00e7 --- /dev/null +++ b/include/MapAPI/reference_line.h @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_REFERENCELINE_H +#define MANTLEAPI_MAPAPI_REFERENCELINE_H + +#include <vector> + +#include "Common/common.h" + +namespace mantle_api +{ +struct ReferenceLinePoint +{ + Position3d world_position; + units::length::meter_t s_position; + units::angle::radian_t t_axis_yaw; +}; + +struct ReferenceLine +{ + Identifier id{UndefinedId}; + std::vector<ReferenceLinePoint> poly_line; +}; +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_REFERENCELINE_H diff --git a/include/MapAPI/stationary_object.h b/include/MapAPI/stationary_object.h new file mode 100644 index 0000000000000000000000000000000000000000..a8bd034b385a47bb0c42531a544c562cb16cde6e --- /dev/null +++ b/include/MapAPI/stationary_object.h @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_STATIONARYOBJECT_H +#define MANTLEAPI_MAPAPI_STATIONARYOBJECT_H + +#include <string> +#include <vector> + +#include "Common/common.h" +#include "lane.h" +#include "logical_lane_assignment.h" + +namespace mantle_api +{ + +struct StationaryObject +{ + enum class Type : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kBridge = 2, + kBuilding = 3, + kPole = 4, + kPylon = 5, + kDelineator = 6, + kTree = 7, + kBarrier = 8, + kVegetation = 9, + kCurbstone = 10, + kWall = 11, + kVerticalStructure = 12, + kRectangularStructure = 13, + kOverheadStructure = 14, + kReflectiveStructure = 15, + kConstructionSiteElement = 16, + kSpeedBump = 17, + kEmittingStructure = 18 + + }; + + enum class Color : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kYellow = 2, + kGreen = 3, + kBlue = 4, + kViolet = 5, + kRed = 6, + kOrange = 7, + kBlack = 8, + kGrey = 9, + kWhite = 10 + }; + + enum class Material : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kWood = 2, + kPlastic = 3, + kConcrete = 4, + kMetal = 5, + kStone = 6, + kGlas = 7, + kMud = 8 + }; + + Identifier id{UndefinedId}; + BaseProperties base; + + Type type; + Material material; + Color color; + + std::vector<RefWrapper<Lane>> assigned_lanes; + std::vector<double> assigned_lane_percentages; + std::vector<LogicalLaneAssignment> logical_lane_assignments; + + std::string model_reference; + std::vector<ExternalReference> source_references; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_STATIONARYOBJECT_H diff --git a/include/MapAPI/traffic_light.h b/include/MapAPI/traffic_light.h new file mode 100644 index 0000000000000000000000000000000000000000..779bb877404eb235194c9e0f121cb1e50d288986 --- /dev/null +++ b/include/MapAPI/traffic_light.h @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_TRAFFICLIGHT_H +#define MANTLEAPI_MAPAPI_TRAFFICLIGHT_H + +#include <string> +#include <vector> + +#include "Common/common.h" +#include "lane.h" +#include "logical_lane_assignment.h" + +namespace mantle_api +{ + +struct TrafficLight +{ + struct TrafficSignal + { + enum class Color : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kRed = 2, + kYellow = 3, + kGreen = 4, + kBlue = 5, + kWhite = 6 + }; + + enum class Icon : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNone = 2, + kArrowStraightAhead = 3, + kArrowLeft = 4, + kArrowDiagLeft = 5, + kArrowStraightAheadLeft = 6, + kArrowRight = 7, + kArrowDiagRight = 8, + kArrowStraightAheadRight = 9, + kArrowLeftRight = 10, + kArrowDown = 11, + kArrowDownLeft = 12, + kArrowDownRight = 13, + kArrowCross = 14, + kPedestrian = 15, + kWalk = 16, + kDontWalk = 17, + kBicycle = 18, + kPedestrianAndBicycle = 19, + kCountdownSeconds = 20, + kCountdownPercent = 21, + kTram = 22, + kBus = 23, + kBusAndTram = 24 + }; + + enum class Mode : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kOff = 2, + kConstant = 3, + kFlashing = 4, + kCounting = 5 + }; + + Identifier id{UndefinedId}; + BaseProperties base; + Color color; + Icon icon; + Mode mode; + double counter; + bool is_out_of_service; + + std::vector<RefWrapper<Lane>> assigned_lanes; + std::vector<LogicalLaneAssignment> logical_lane_assignments; + + std::string model_reference; + std::vector<ExternalReference> source_references; + }; + + Identifier id{UndefinedId}; + std::vector<TrafficSignal> traffic_signals; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_TRAFFICLIGHT_H diff --git a/include/MapAPI/traffic_sign.h b/include/MapAPI/traffic_sign.h new file mode 100644 index 0000000000000000000000000000000000000000..b4cd21c84f100c8378a2a6d7bb14888bd197a54e --- /dev/null +++ b/include/MapAPI/traffic_sign.h @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_TRAFFICSIGN_H +#define MANTLEAPI_MAPAPI_TRAFFICSIGN_H + +#include <vector> + +#include "Common/common.h" +#include "traffic_sign_main_sign.h" +#include "traffic_sign_supplementary_sign.h" + +namespace mantle_api +{ + +struct TrafficSign +{ + Identifier id{UndefinedId}; + MainSign main_sign; + std::vector<SupplementarySign> supplementary_signs; + std::vector<ExternalReference> source_references; +}; +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_TRAFFICSIGN_H diff --git a/include/MapAPI/traffic_sign_common.h b/include/MapAPI/traffic_sign_common.h new file mode 100644 index 0000000000000000000000000000000000000000..eef36538931726c303a0dee2d9c7d175f5054aa9 --- /dev/null +++ b/include/MapAPI/traffic_sign_common.h @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_TRAFFICSIGNCOMMON_H +#define MANTLEAPI_MAPAPI_TRAFFICSIGNCOMMON_H + +#include <string> + +#include "Common/common.h" + +namespace mantle_api +{ + +struct TrafficSignValue +{ + enum class Unit : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNoUnit = 2, + kKilometerPerHour = 3, + kMilePerHour = 4, + kMeter = 5, + kKilometer = 6, + kFeet = 7, + kMile = 8, + kMetricTon = 9, + kLongTon = 10, + kShortTon = 11, + kHour = 15, + kMinutes = 12, + kDayOfMonth = 16, + kDay = 13, + kPercentage = 14, + kDurationDay = 17, + kDurationHour = 18, + kDurationMinute = 19 + }; + + double value; + Unit value_unit; + std::string text; +}; + +enum class TrafficSignVariability : uint8_t +{ + kUnknown = 0, + kOther = 1, + kFixed = 2, + kVariable = 3 +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_TRAFFICSIGNCOMMON_H diff --git a/include/MapAPI/traffic_sign_main_sign.h b/include/MapAPI/traffic_sign_main_sign.h new file mode 100644 index 0000000000000000000000000000000000000000..bcc83e3410a6fa3032c352ec23f546c509bc1da3 --- /dev/null +++ b/include/MapAPI/traffic_sign_main_sign.h @@ -0,0 +1,303 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_TRAFFICSIGNMAINSIGN_H +#define MANTLEAPI_MAPAPI_TRAFFICSIGNMAINSIGN_H + +#include <cstdint> +#include <string> +#include <vector> + +#include "Common/common.h" +#include "lane.h" +#include "logical_lane_assignment.h" +#include "traffic_sign_common.h" + +namespace mantle_api +{ + +enum class MainSignType : std::uint8_t +{ + kUnknown = 0, + kOther = 1, + kDangerSpot = 2, + kZebraCrossing = 87, + kFlight = 110, + kCattle = 200, + kHorseRiders = 197, + kAmphibians = 188, + kFallingRocks = 96, + kSnowOrIce = 94, + kLooseGravel = 97, + kWaterside = 102, + kClearance = 210, + kMovableBridge = 101, + kRightBeforeLeftNextIntersection = 3, + kTurnLeft = 4, + kTurnRight = 5, + kDoubleTurnLeft = 6, + kDoubleTurnRight = 7, + kHillDownwards = 8, + kHillUpwards = 9, + kUnevenRoad = 93, + kRoadSlipperyWetOrDirty = 95, + kSideWinds = 98, + kRoadNarrowing = 10, + kRoadNarrowingRight = 12, + kRoadNarrowingLeft = 11, + kRoadWorks = 13, + kTrafficQueues = 100, + kTwoWayTraffic = 14, + kAttentionTrafficLight = 15, + kPedestrians = 103, + kChildrenCrossing = 106, + kCycleRoute = 107, + kDeerCrossing = 109, + kUngatedLevelCrossing = 144, + kLevelCrossingMarker = 112, + kRailwayTrafficPriority = 135, + kGiveWay = 16, + kStop = 17, + kPriorityToOppositeDirection = 18, + kPriorityToOppositeDirectionUpsideDown = 19, + kPrescribedLeftTurn = 20, + kPrescribedRightTurn = 21, + kPrescribedStraight = 22, + kPrescribedRightWay = 24, + kPrescribedLeftWay = 23, + kPrescribedRightTurnAndStraight = 26, + kPrescribedLeftTurnAndStraight = 25, + kPrescribedLeftTurnAndRightTurn = 27, + kPrescribedLeftTurnRightTurnAndStraight = 28, + kRoundabout = 29, + kOnewayLeft = 30, + kOnewayRight = 31, + kPassLeft = 32, + kPassRight = 33, + kSideLaneOpenForTraffic = 128, + kSideLaneClosedForTraffic = 129, + kSideLaneClosingForTraffic = 130, + kBusStop = 137, + kTaxiStand = 138, + kBicyclesOnly = 145, + kHorseRidersOnly = 146, + kPedestriansOnly = 147, + kBicyclesPedestriansSharedOnly = 148, + kBicyclesPedestriansSeparatedLeftOnly = 149, + kBicyclesPedestriansSeparatedRightOnly = 150, + kPedestrianZoneBegin = 151, + kPedestrianZoneEnd = 152, + kBicycleRoadBegin = 153, + kBicycleRoadEnd = 154, + kBusLane = 34, + kBusLaneBegin = 35, + kBusLaneEnd = 36, + kAllProhibited = 37, + kMotorizedMultitrackProhibited = 38, + kTrucksProhibited = 39, + kBicyclesProhibited = 40, + kMotorcyclesProhibited = 41, + kMopedsProhibited = 155, + kHorseRidersProhibited = 156, + kHorseCarriagesProhibited = 157, + kCattleProhibited = 158, + kBusesProhibited = 159, + kCarsProhibited = 160, + kCarsTrailersProhibited = 161, + kTrucksTrailersProhibited = 162, + kTractorsProhibited = 163, + kPedestriansProhibited = 42, + kMotorVehiclesProhibited = 43, + kHazardousGoodsVehiclesProhibited = 164, + kOverWeightVehiclesProhibited = 165, + kVehiclesAxleOverWeightProhibited = 166, + kVehiclesExcessWidthProhibited = 167, + kVehiclesExcessHeightProhibited = 168, + kVehiclesExcessLengthProhibited = 169, + kDoNotEnter = 44, + kSnowChainsRequired = 170, + kWaterPollutantVehiclesProhibited = 171, + kEnvironmentalZoneBegin = 45, + kEnvironmentalZoneEnd = 46, + kNoUTurnLeft = 47, + kNoUTurnRight = 48, + kPrescribedUTurnLeft = 49, + kPrescribedUTurnRight = 50, + kMinimumDistanceForTrucks = 51, + kSpeedLimitBegin = 52, + kSpeedLimitZoneBegin = 53, + kSpeedLimitZoneEnd = 54, + kMinimumSpeedBegin = 55, + kOvertakingBanBegin = 56, + kOvertakingBanForTrucksBegin = 57, + kSpeedLimitEnd = 58, + kMinimumSpeedEnd = 59, + kOvertakingBanEnd = 60, + kOvertakingBanForTrucksEnd = 61, + kAllRestrictionsEnd = 62, + kNoStopping = 63, + kNoParking = 64, + kNoParkingZoneBegin = 65, + kNoParkingZoneEnd = 66, + kRightOfWayNextIntersection = 67, + kRightOfWayBegin = 68, + kRightOfWayEnd = 69, + kPriorityOverOppositeDirection = 70, + kPriorityOverOppositeDirectionUpsideDown = 71, + kTownBegin = 72, + kTownEnd = 73, + kCarParking = 74, + kCarParkingZoneBegin = 75, + kCarParkingZoneEnd = 76, + kSidewalkHalfParkingLeft = 172, + kSidewalkHalfParkingRight = 173, + kSidewalkParkingLeft = 174, + kSidewalkParkingRight = 175, + kSidewalkPerpendicularHalfParkingLeft = 176, + kSidewalkPerpendicularHalfParkingRight = 177, + kSidewalkPerpendicularParkingLeft = 178, + kSidewalkPerpendicularParkingRight = 179, + kLivingStreetBegin = 77, + kLivingStreetEnd = 78, + kTunnel = 79, + kEmergencyStoppingLeft = 80, + kEmergencyStoppingRight = 81, + kHighwayBegin = 82, + kHighwayEnd = 83, + kExpresswayBegin = 84, + kExpresswayEnd = 85, + kNamedHighwayExit = 183, + kNamedExpresswayExit = 184, + kNamedRoadExit = 185, + kHighwayExit = 86, + kExpresswayExit = 186, + kOnewayStreet = 187, + kCrossingGuards = 189, + kDeadend = 190, + kDeadendExcludingDesignatedActors = 191, + kFirstAidStation = 194, + kPoliceStation = 195, + kTelephone = 196, + kFillingStation = 198, + kHotel = 201, + kInn = 202, + kKiosk = 203, + kToilet = 204, + kChapel = 205, + kTouristInfo = 206, + kRepairService = 207, + kPedestrianUnderpass = 208, + kPedestrianBridge = 209, + kCamperPlace = 213, + kAdvisorySpeedLimitBegin = 214, + kAdvisorySpeedLimitEnd = 215, + kPlaceName = 216, + kTouristAttraction = 217, + kTouristRoute = 218, + kTouristArea = 219, + kShoulderNotPassableMotorVehicles = 220, + kShoulderUnsafeTrucksTractors = 221, + kTollBegin = 222, + kTollEnd = 223, + kTollRoad = 224, + kCustoms = 225, + kInternationalBorderInfo = 226, + kStreetlightRedBand = 227, + kFederalHighwayRouteNumber = 228, + kHighwayRouteNumber = 229, + kHighwayInterchangeNumber = 230, + kEuropeanRouteNumber = 231, + kFederalHighwayDirectionLeft = 232, + kFederalHighwayDirectionRight = 233, + kPrimaryRoadDirectionLeft = 234, + kPrimaryRoadDirectionRight = 235, + kSecondaryRoadDirectionLeft = 236, + kSecondaryRoadDirectionRight = 237, + kDirectionDesignatedActorsLeft = 238, + kDirectionDesignatedActorsRight = 239, + kRoutingDesignatedActors = 240, + kDirectionToHighwayLeft = 143, + kDirectionToHighwayRight = 108, + kDirectionToLocalDestinationLeft = 127, + kDirectionToLocalDestinationRight = 136, + kConsolidatedDirections = 118, + kStreetName = 119, + kDirectionPreannouncement = 120, + kDirectionPreannouncementLaneConfig = 121, + kDirectionPreannouncementHighwayEntries = 122, + kHighwayAnnouncement = 123, + kOtherRoadAnnouncement = 124, + kHighwayAnnouncementTruckStop = 125, + kHighwayPreannouncementDirections = 126, + kPoleExit = 88, + kHighwayDistanceBoard = 180, + kDetourLeft = 181, + kDetourRight = 182, + kNumberedDetour = 131, + kDetourBegin = 132, + kDetourEnd = 133, + kDetourRoutingBoard = 134, + kOptionalDetour = 111, + kOptionalDetourRouting = 199, + kRouteRecommendation = 211, + kRouteRecommendationEnd = 212, + kAnnounceLaneTransitionLeft = 192, + kAnnounceLaneTransitionRight = 193, + kAnnounceRightLaneEnd = 90, + kAnnounceLeftLaneEnd = 89, + kAnnounceRightLaneBegin = 115, + kAnnounceLeftLaneBegin = 116, + kAnnounceLaneConsolidation = 117, + kDetourCityBlock = 142, + kGate = 141, + kPoleWarning = 91, + kTrafficCone = 140, + kMobileLaneClosure = 139, + kReflectorPost = 114, + kDirectionalBoardWarning = 113, + kGuidingPlate = 104, + kGuidingPlateWedges = 105, + kParkingHazard = 99, + kTrafficLightGreenArrow = 92 +}; + +enum class DirectionScope : uint8_t +{ + kUnknown = 0, + kOther = 1, + kNoDirection = 2, + kLeft = 3, + kRight = 4, + kLeftRight = 5 +}; + +struct MainSign +{ + BaseProperties base; + TrafficSignVariability variability; + MainSignType type; + TrafficSignValue value; + DirectionScope direction_scope; + std::vector<RefWrapper<Lane>> assigned_lanes; + bool vertically_mirrored; + bool is_out_of_service; + std::string country; + std::string country_revision; + std::string code; + std::string sub_code; + std::vector<LogicalLaneAssignment> logical_lane_assignments; + + std::string model_reference; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_TRAFFICSIGNMAINSIGN_H diff --git a/include/MapAPI/traffic_sign_supplementary_sign.h b/include/MapAPI/traffic_sign_supplementary_sign.h new file mode 100644 index 0000000000000000000000000000000000000000..a37676e430a0c2c5da46dd5ad82943cd74376816 --- /dev/null +++ b/include/MapAPI/traffic_sign_supplementary_sign.h @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#ifndef MANTLEAPI_MAPAPI_TRAFFICSIGNSUPPLEMENTARYSIGN_H +#define MANTLEAPI_MAPAPI_TRAFFICSIGNSUPPLEMENTARYSIGN_H + +#include <string> +#include <vector> + +#include "Common/common.h" +#include "lane.h" +#include "logical_lane_assignment.h" +#include "traffic_sign_common.h" + +namespace mantle_api +{ + +enum class SupplementarySignType : uint8_t +{ + kUnknown = 0, + kOther = 1, + kNoSign = 2, + kValidForDistance = 3, + kValidInDistance = 4, + kTimeRange = 5, + kWeight = 6, + kRain = 7, + kFog = 8, + kSnow = 9, + kSnowRain = 10, + kLeftArrow = 11, + kRightArrow = 12, + kLeftBendArrow = 13, + kRightBendArrow = 14, + kTruck = 15, + kTractorsMayBePassed = 16, + kHazardous = 17, + kTrailer = 18, + kNight = 19, + kZone = 20, + kStop_4Way = 21, + kMotorcycle = 22, + kMotorcycleAllowed = 23, + kCar = 24, + kStopIn = 25, + kTime = 26, + kPriorityRoadBottomLeftFourWay = 27, + kPriorityRoadTopLeftFourWay = 28, + kPriorityRoadBottomRightFourWay = 29, + kArow = 30, + kPriorityRoadTopRightFourWay = 31, + kPriorityRoadBottomLeftThreeWayStraight = 32, + kPriorityRoadBottomLeftThreeWaySideways = 33, + kPriorityRoadTopLeftThreeWayStraight = 34, + kPriorityRoadBottomRightThreeWayStraight = 35, + kPriorityRoadBottomRightThreeWaySideway = 36, + kPriorityRoadTopRightThreeWayStraight = 37, + kNoWaitingSideStripes = 38, + kSpace = 39, + kAccident = 40, + kText = 41, + kParkingConstraint = 42, + kParkingDiscTimeRestriction = 43, + kWet = 44, + kExcept = 45, + kConstrainedTo = 46, + kServices = 47, + kRollingHighwayInformation = 48 +}; + +enum class SupplementarySignActor : uint8_t +{ + kUnknown = 0, + kOther = 1, + kNoActor = 2, + kAgriculturalVehicles = 3, + kBicycles = 4, + kBuses = 5, + kCampers = 6, + kCaravans = 7, + kCars = 8, + kCarsWithCaravans = 9, + kCarsWithTrailers = 10, + kCattle = 11, + kChildren = 12, + kConstructionVehicles = 13, + kDeliveryVehicles = 14, + kDisabledPersons = 15, + kEbikes = 16, + kElectricVehicles = 17, + kEmergencyVehicles = 18, + kFerryUsers = 19, + kForestryVehicles = 20, + kHazardousGoodsVehicles = 21, + kHorseCarriages = 22, + kHorseRiders = 23, + kInlineSkaters = 24, + kMedicalVehicles = 25, + kMilitaryVehicles = 26, + kMopeds = 27, + kMotorcycles = 28, + kMotorizedMultitrackVehicles = 29, + kOperationalAndUtilityVehicles = 30, + kPedestrians = 31, + kPublicTransportVehicles = 32, + kRailroadTraffic = 33, + kResidents = 34, + kSlurryTransport = 35, + kTaxis = 36, + kTractors = 37, + kTrailers = 38, + kTrams = 39, + kTrucks = 40, + kTrucksWithSemitrailers = 41, + kTrucksWithTrailers = 42, + kVehiclesWithGreenBadges = 43, + kVehiclesWithRedBadges = 44, + kVehiclesWithYellowBadges = 45, + kWaterPollutantVehicles = 46, + kWinterSportspeople = 47 +}; + +struct SupplementarySignArrow +{ + enum class Direction : std::uint8_t + { + kUnknown = 0, + kOther = 1, + kNo_direction = 2, + kDirect0Deg = 3, + kDirect45DegRight = 4, + kDirect45DegLeft = 5, + kDirect90DegRight = 6, + kDirect90DegLeft = 7, + kDirect135DegRight = 8, + kDirect135DegLeft = 9, + kDirect180Deg = 10, + kTurn45DegRight = 11, + kTurn45DegLeft = 12, + kTurn90DegRight = 13, + kTurn90DegLeft = 14, + kTurn135DegRight = 15, + kTurn135DegLeft = 16, + kTurn180DegRight = 17, + kTurn180DegLeft = 18, + kCircle0Deg = 19, + kCircle45DegRight = 20, + kCircle45DegLeft = 21, + kCircle90DegRight = 22, + kCircle90DegLeft = 23, + kCircle135DegRight = 24, + kCircle135DegLeft = 25, + kCircle180Deg = 26, + kKeepLeftToTurn0Deg = 27, + kKeepRightToTurn0Deg = 28, + kKeepLeftToTurn90DegRight = 29, + kKeepRightToTurn90DegLeft = 30, + kKeepLeftDriveBackToTurn90DegRight = 31, + kKeepRightDriveBackToTurn90DegLeft = 32 + }; + std::vector<RefWrapper<Lane>> lanes; + std::vector<Direction> direction; +}; + +struct SupplementarySign +{ + BaseProperties base; + TrafficSignVariability variability; + SupplementarySignType type; + std::vector<TrafficSignValue> values; + std::vector<RefWrapper<Lane>> assigned_lanes; + std::vector<SupplementarySignActor> actors; + std::vector<SupplementarySignArrow> arrows; + bool is_out_of_service; + std::string country; + std::string country_revision; + std::string code; + std::string sub_code; + std::vector<LogicalLaneAssignment> logical_lane_assignments; + std::string model_reference; +}; + +} // namespace mantle_api + +#endif // MANTLEAPI_MAPAPI_TRAFFICSIGNSUPPLEMENTARYSIGN_H diff --git a/test/MapAPI/Test/map_test.cpp b/test/MapAPI/Test/map_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d26490d11b1424a62cd69a97c3c333eb1363bc3b --- /dev/null +++ b/test/MapAPI/Test/map_test.cpp @@ -0,0 +1,244 @@ +/******************************************************************************* + * Copyright (c) 2023, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * Copyright (C) 2023, ANSYS, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +#include "include/MapAPI/map.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +namespace +{ + +using units::literals::operator""_m; +using namespace mantle_api; + +/////////////////////////////////////////////////////////// +/// @verbatim +/// Connected Lanes +/// IDs: +/// |-----------------------------|-----------------------------| y = 4.5 +/// | Left LaneBoundary: 100 | Left LaneBoundary: 103 | +/// | Lane: 0 | Lane: 2 | y = 3.0 +/// | Right LaneBoundary: 101 | Right LaneBoundary: 104 | +/// |-----------------------------|-----------------------------| y = 1.5 +/// | Left LaneBoundary: 101 | Left LaneBoundary: 104 | +/// | Lane: 1 | Lane: 3 | y = 0.0 +/// | Right LaneBoundary: 102 | Right LaneBoundary: 105 | +/// |-----------------------------|-----------------------------| y = -1.5 +/// ^ ^ ^ +/// x(0) (1000) (2000) +/// +/// @endverbatim + +inline auto CreateLaneBoundary(Identifier id, const units::length::meter_t start_x, const units::length::meter_t y_offset) +{ + auto lane_boundary = std::make_unique<LaneBoundary>(); + lane_boundary->id = id; + lane_boundary->boundary_line = std::vector<LaneBoundary::BoundaryPoint>{ + {.position = {.x = start_x, .y = y_offset, .z = 0.0_m}, .width = 0.13_m, .height = 0.05_m}, + {.position = {.x = start_x + 1000.0_m, .y = y_offset, .z = 0.0_m}, .width = 0.13_m, .height = 0.05_m}}; + lane_boundary->type = LaneBoundary::Type::kSolidLine; + lane_boundary->color = LaneBoundary::Color::kWhite; + return std::move(lane_boundary); +} + +inline auto CreateLane(Identifier id, const units::length::meter_t start_x, const units::length::meter_t y_offset) +{ + auto lane = std::make_unique<Lane>(); + lane->id = id; + lane->type = Lane::Type::kDriving; + lane->sub_type = Lane::Subtype::kUnknown; + lane->centerline = Lane::Polyline{ + Lane::PolylinePoint{start_x, y_offset, 0.0_m}, + Lane::PolylinePoint{start_x + 1000.0_m, y_offset, 0.0_m}}; + + return std::move(lane); +} + +inline Map CreateMapWithConnectedLanes() +{ + Map map{}; + map.projection_string = "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"; + + auto lane_boundary_100 = CreateLaneBoundary(100, 0.0_m, 4.5_m); + auto lane_boundary_101 = CreateLaneBoundary(101, 0.0_m, 1.5_m); + auto lane_boundary_102 = CreateLaneBoundary(102, 0.0_m, -1.5_m); + auto lane_boundary_103 = CreateLaneBoundary(103, 1000.0_m, 4.5_m); + auto lane_boundary_104 = CreateLaneBoundary(104, 1000.0_m, 1.5_m); + auto lane_boundary_105 = CreateLaneBoundary(105, 1000.0_m, -1.5_m); + + auto lane_0 = CreateLane(0, 0.0_m, 3.0_m); + auto lane_1 = CreateLane(1, 0.0_m, 3.0_m); + auto lane_2 = CreateLane(2, 1000.0_m, 3.0_m); + auto lane_3 = CreateLane(3, 1000.0_m, 0.0_m); + + lane_0->left_lane_boundaries.push_back(*lane_boundary_100); + lane_0->right_lane_boundaries.push_back(*lane_boundary_101); + lane_0->right_adjacent_lanes.push_back(*lane_1); + lane_0->successor_lanes.push_back(*lane_2); + + lane_1->left_lane_boundaries.push_back(*lane_boundary_101); + lane_1->right_lane_boundaries.push_back(*lane_boundary_102); + lane_1->left_adjacent_lanes.push_back(*lane_0); + lane_1->successor_lanes.push_back(*lane_3); + + lane_2->left_lane_boundaries.push_back(*lane_boundary_103); + lane_2->right_lane_boundaries.push_back(*lane_boundary_104); + lane_2->right_adjacent_lanes.push_back(*lane_3); + lane_2->antecessor_lanes.push_back(*lane_0); + + lane_3->left_lane_boundaries.push_back(*lane_boundary_104); + lane_3->right_lane_boundaries.push_back(*lane_boundary_105); + lane_3->left_adjacent_lanes.push_back(*lane_2); + lane_3->antecessor_lanes.push_back(*lane_1); + + map.lanes.emplace_back(std::move(lane_0)); + map.lanes.emplace_back(std::move(lane_1)); + map.lanes.emplace_back(std::move(lane_2)); + map.lanes.emplace_back(std::move(lane_3)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_100)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_101)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_102)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_103)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_104)); + map.lane_boundaries.emplace_back(std::move(lane_boundary_105)); + + map.logical_lanes.emplace_back(std::make_unique<LogicalLane>()); + map.logical_lane_boundaries.emplace_back(std::make_unique<LogicalLaneBoundary>()); + map.traffic_lights.emplace_back(std::make_unique<TrafficLight>()); + map.traffic_signs.emplace_back(std::make_unique<TrafficSign>()); + map.reference_lines.emplace_back(std::make_unique<ReferenceLine>()); + map.stationary_objects.emplace_back(std::make_unique<StationaryObject>()); + + map.lane_boundaries.front()->limiting_structures.push_back(*(map.stationary_objects.front())); + + return map; +} + +TEST(MapTest, GivenEmptyMap_WhenInitialized_ThenDefaultValuesAreSet) +{ + Map map; + + EXPECT_EQ(map.projection_string, ""); + EXPECT_EQ(map.map_reference, ""); + EXPECT_EQ(map.country_code, std::numeric_limits<std::uint32_t>::max()); + EXPECT_TRUE(map.lanes.empty()); + EXPECT_TRUE(map.lane_boundaries.empty()); + EXPECT_TRUE(map.logical_lanes.empty()); + EXPECT_TRUE(map.logical_lane_boundaries.empty()); + EXPECT_TRUE(map.stationary_objects.empty()); + EXPECT_TRUE(map.traffic_lights.empty()); + EXPECT_TRUE(map.traffic_signs.empty()); + EXPECT_TRUE(map.reference_lines.empty()); +} + +TEST(MapTest, GivenMapWithConnectedLanes_WhenInitialized_ThenValuesAreSet) +{ + const auto map = CreateMapWithConnectedLanes(); + + EXPECT_EQ(map.projection_string, "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"); + EXPECT_EQ(map.map_reference, ""); + EXPECT_EQ(map.country_code, std::numeric_limits<std::uint32_t>::max()); + EXPECT_EQ(map.lanes.size(), 4); + EXPECT_EQ(map.lane_boundaries.size(), 6); + EXPECT_EQ(map.logical_lanes.size(), 1); + EXPECT_EQ(map.logical_lane_boundaries.size(), 1); + EXPECT_EQ(map.stationary_objects.size(), 1); + EXPECT_EQ(map.traffic_lights.size(), 1); + EXPECT_EQ(map.traffic_signs.size(), 1); + EXPECT_EQ(map.reference_lines.size(), 1); +} + +TEST(MapTest, GivenMapWithConnectedLanes_WhenInitialized_ThenLaneBoundariesAreSetCorrectly) +{ + const auto map = CreateMapWithConnectedLanes(); + ASSERT_EQ(map.lanes.size(), 4); + + auto& lane_0 = map.lanes.at(0); + ASSERT_EQ(lane_0->left_lane_boundaries.size(), 1); + ASSERT_EQ(lane_0->right_lane_boundaries.size(), 1); + EXPECT_EQ(lane_0->left_lane_boundaries.front().get().id, 100); + EXPECT_EQ(lane_0->right_lane_boundaries.front().get().id, 101); + + auto& lane_1 = map.lanes.at(1); + ASSERT_EQ(lane_1->left_lane_boundaries.size(), 1); + ASSERT_EQ(lane_1->right_lane_boundaries.size(), 1); + EXPECT_EQ(lane_1->left_lane_boundaries.front().get().id, 101); + EXPECT_EQ(lane_1->right_lane_boundaries.front().get().id, 102); + + auto& lane_2 = map.lanes.at(2); + ASSERT_EQ(lane_2->left_lane_boundaries.size(), 1); + ASSERT_EQ(lane_2->right_lane_boundaries.size(), 1); + EXPECT_EQ(lane_2->left_lane_boundaries.front().get().id, 103); + EXPECT_EQ(lane_2->right_lane_boundaries.front().get().id, 104); + + auto& lane_3 = map.lanes.at(3); + ASSERT_EQ(lane_3->left_lane_boundaries.size(), 1); + ASSERT_EQ(lane_3->right_lane_boundaries.size(), 1); + EXPECT_EQ(lane_3->left_lane_boundaries.front().get().id, 104); + EXPECT_EQ(lane_3->right_lane_boundaries.front().get().id, 105); +} + +TEST(MapTest, GivenMapWithConnectedLanes_WhenInitialized_ThenSuccessorAndAntecessorLanesAreSetCorrectly) +{ + const auto map = CreateMapWithConnectedLanes(); + ASSERT_EQ(map.lanes.size(), 4); + + auto& lane_0 = map.lanes.at(0); + auto& lane_1 = map.lanes.at(1); + auto& lane_2 = map.lanes.at(2); + auto& lane_3 = map.lanes.at(3); + + ASSERT_EQ(lane_0->successor_lanes.size(), 1); + ASSERT_EQ(lane_0->antecessor_lanes.size(), 0); + EXPECT_EQ(lane_0->successor_lanes.front().get().id, lane_2->id); + + ASSERT_EQ(lane_1->successor_lanes.size(), 1); + ASSERT_EQ(lane_1->antecessor_lanes.size(), 0); + EXPECT_EQ(lane_1->successor_lanes.front().get().id, lane_3->id); + + ASSERT_EQ(lane_2->successor_lanes.size(), 0); + ASSERT_EQ(lane_2->antecessor_lanes.size(), 1); + EXPECT_EQ(lane_2->antecessor_lanes.front().get().id, lane_0->id); + + ASSERT_EQ(lane_3->successor_lanes.size(), 0); + ASSERT_EQ(lane_3->antecessor_lanes.size(), 1); + EXPECT_EQ(lane_3->antecessor_lanes.front().get().id, lane_1->id); +} + +TEST(MapTest, GivenMapWithConnectedLanes_WhenInitialized_ThenLeftAndRightAdjacentLaneAreSetCorrectly) +{ + const auto map = CreateMapWithConnectedLanes(); + ASSERT_EQ(map.lanes.size(), 4); + + auto& lane_0 = map.lanes.at(0); + auto& lane_1 = map.lanes.at(1); + auto& lane_2 = map.lanes.at(2); + auto& lane_3 = map.lanes.at(3); + + ASSERT_EQ(lane_0->left_adjacent_lanes.size(), 0); + ASSERT_EQ(lane_0->right_adjacent_lanes.size(), 1); + EXPECT_EQ(lane_0->right_adjacent_lanes.front().get().id, lane_1->id); + + ASSERT_EQ(lane_1->left_adjacent_lanes.size(), 1); + ASSERT_EQ(lane_1->right_adjacent_lanes.size(), 0); + EXPECT_EQ(lane_1->left_adjacent_lanes.front().get().id, lane_0->id); + + ASSERT_EQ(lane_2->left_adjacent_lanes.size(), 0); + ASSERT_EQ(lane_2->right_adjacent_lanes.size(), 1); + EXPECT_EQ(lane_2->right_adjacent_lanes.front().get().id, lane_3->id); + + ASSERT_EQ(lane_3->left_adjacent_lanes.size(), 1); + ASSERT_EQ(lane_3->right_adjacent_lanes.size(), 0); + EXPECT_EQ(lane_3->left_adjacent_lanes.front().get().id, lane_2->id); +} + +} // namespace