Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK --------------------------------- 2 : : // 3 : : // Copyright (C) 2018-2021 Intel Corporation 4 : : // 5 : : // SPDX-License-Identifier: LGPL-2.1-only 6 : : // 7 : : // ----------------- END LICENSE BLOCK ----------------------------------- 8 : : /** 9 : : * @file 10 : : */ 11 : : 12 : : #pragma once 13 : : 14 : : #include <limits> 15 : : #include "ad/rss/world/Object.hpp" 16 : : #include "ad/rss/world/RoadSegment.hpp" 17 : : 18 : : /*! 19 : : * @brief namespace ad 20 : : */ 21 : : namespace ad { 22 : : /*! 23 : : * @brief namespace rss 24 : : */ 25 : : namespace rss { 26 : : /*! 27 : : * @brief namespace structured 28 : : */ 29 : : namespace structured { 30 : : 31 : : /** 32 : : * @brief class to store information of object position dimensions 33 : : */ 34 : : class ObjectDimensions 35 : : { 36 : : public: 37 : 28263 : ObjectDimensions() 38 : 28263 : { 39 : 28263 : longitudinalDimensions.maximum = std::numeric_limits<physics::Distance>::lowest(); 40 : 28263 : longitudinalDimensions.minimum = std::numeric_limits<physics::Distance>::max(); 41 : : 42 : 28262 : lateralDimensions.maximum = std::numeric_limits<physics::Distance>::lowest(); 43 : 28262 : lateralDimensions.minimum = std::numeric_limits<physics::Distance>::max(); 44 : 28262 : } 45 : : 46 : : /** 47 : : * @brief range of longitudinal object position 48 : : */ 49 : : physics::MetricRange longitudinalDimensions; 50 : : 51 : : /** 52 : : * @brief range of lateral object position 53 : : */ 54 : : physics::MetricRange lateralDimensions; 55 : : 56 : : /** 57 : : * @brief flag to indicate if the object is on the positive driving lane 58 : : */ 59 : : bool onPositiveLane{false}; 60 : : 61 : : /** 62 : : * @brief flag to indicate if the object is on the negative driving lane 63 : : */ 64 : : bool onNegativeLane{false}; 65 : : 66 : : /** 67 : : * @brief range of intersection position 68 : : * 69 : : * minimum: minimal distance to intersection entry 70 : : * maximum: maximum distance to intersection exit 71 : : */ 72 : : physics::MetricRange intersectionPosition; 73 : : }; 74 : : 75 : : /** 76 : : * @brief class to calculate object positions 77 : : * 78 : : * class will receive road and lane segments in consecutive order and will : 79 : : * - calculate the position of the object specified by the occupied_regions in the constellation coordinate system 80 : : * - calculate the position to intersection if laneSegments are part of an intersection 81 : : * - determine whether the object is on lanes in positive or negative driving direction 82 : : */ 83 : : class RssObjectPositionExtractor 84 : : { 85 : : public: 86 : : /** 87 : : * @brief Constructor 88 : : * 89 : : * @param occupied_regions representing the object 90 : : */ 91 : : explicit RssObjectPositionExtractor(world::OccupiedRegionVector const &occupied_regions); 92 : : 93 : : /** 94 : : * @brief Indicate that there is a new road segment 95 : : * 96 : : * @param[in] longitudinalStart metric range in the constellation based coordinate system to the start of the 97 : : * road segment 98 : : * @param[in] roadSegment the new road segment 99 : : * 100 : : * @returns return false if an error occurred, true otherwise. 101 : : */ 102 : : bool newRoadSegment(physics::MetricRange const &longitudinalStart, world::RoadSegment const &roadSegment); 103 : : 104 : : /** 105 : : * @brief Add information of the next adjacent laneSegement 106 : : * 107 : : * @param[in] lateral_distance minimal and maximal lateral distance to the begin of the segment 108 : : * @param[in] laneSegment the information about the laneSegment 109 : : * 110 : : * @returns false if an error occurred, true otherwise. 111 : : */ 112 : : bool newLaneSegment(physics::MetricRange lateral_distance, world::LaneSegment const &laneSegment); 113 : : 114 : : /** 115 : : * @brief Retrieve the objectDimension information back from the class 116 : : * 117 : : * @param[out] objectDimensions 118 : : * 119 : : * @returns true if calculation is complete, false if not all occupied_regions are processed yet 120 : : */ 121 : : bool getObjectDimensions(ObjectDimensions &objectDimensions); 122 : : 123 : : private: 124 : : world::OccupiedRegionVector mOccupiedRegions; 125 : : 126 : : physics::MetricRange mCurrentLongitudinalRoadSegmentStart; 127 : : physics::Distance mRoadSegmentMinLengthAfterIntersectingArea{0.}; 128 : : 129 : : enum class IntersectionState 130 : : { 131 : : BeforeIntersection, 132 : : WithinIntersection, 133 : : AfterIntersection 134 : : }; 135 : : IntersectionState mIntersectionState{IntersectionState::BeforeIntersection}; 136 : : 137 : : ObjectDimensions mObjectDimensions; 138 : : }; 139 : : 140 : : } // namespace structured 141 : : } // namespace rss 142 : : } // namespace ad