LCOV - code coverage report
Current view: top level - src/situation - RssStructuredSceneNonIntersectionChecker.hpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 2 2 100.0 %
Date: 2024-04-16 14:13:10 Functions: 2 2 100.0 %
Branches: 0 0 -

           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 <map>
      15                 :            : #include "ad/rss/situation/Situation.hpp"
      16                 :            : #include "ad/rss/state/RssState.hpp"
      17                 :            : #include "ad/rss/world/TimeIndex.hpp"
      18                 :            : 
      19                 :            : /*!
      20                 :            :  * @brief namespace ad
      21                 :            :  */
      22                 :            : namespace ad {
      23                 :            : /*!
      24                 :            :  * @brief namespace rss
      25                 :            :  */
      26                 :            : namespace rss {
      27                 :            : /*!
      28                 :            :  * @brief namespace situation
      29                 :            :  */
      30                 :            : namespace situation {
      31                 :            : 
      32                 :            : /**
      33                 :            :  * @brief Class to check whether a non-intersection structured scene is safe and to determine the proper response for
      34                 :            :  * the situation
      35                 :            :  *
      36                 :            :  * Note: Implements the checks and responses given by the definitions 1-10 of the RSS paper (arXiv:1708.06374v6)
      37                 :            :  *
      38                 :            :  * Class performs required check to if situation is safe
      39                 :            :  * Class will maintain the previous state of the situation in order to provide the proper response.
      40                 :            :  */
      41                 :            : class RssStructuredSceneNonIntersectionChecker
      42                 :            : {
      43                 :            : public:
      44                 :            :   /**
      45                 :            :    * @brief Constructor
      46                 :            :    */
      47                 :        760 :   RssStructuredSceneNonIntersectionChecker() = default;
      48                 :            : 
      49                 :            :   /**
      50                 :            :    * @brief Destructor
      51                 :            :    */
      52                 :        760 :   ~RssStructuredSceneNonIntersectionChecker() = default;
      53                 :            : 
      54                 :            :   /**
      55                 :            :    * @brief Calculate safety checks and determine required rssState for structured non intersection situations
      56                 :            :    *
      57                 :            :    * @param[in]  timeIndex the time index of the situation
      58                 :            :    * @param[in]  situation situation to analyze
      59                 :            :    * @param[out] rssState  rssState of the ego vehicle
      60                 :            :    *
      61                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      62                 :            :    */
      63                 :            :   bool calculateRssStateNonIntersection(world::TimeIndex const &timeIndex,
      64                 :            :                                         Situation const &situation,
      65                 :            :                                         state::RssState &rssState);
      66                 :            : 
      67                 :            : private:
      68                 :            :   /**
      69                 :            :    * @brief Calculate safety checks and determine required rssState for non intersection same direction scenario
      70                 :            :    *
      71                 :            :    * @param[in]  timeIndex the time index of the situation
      72                 :            :    * @param[in]  situation situation to analyze
      73                 :            :    * @param[out] rssState  response state of the ego vehicle
      74                 :            :    *
      75                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      76                 :            :    */
      77                 :            :   bool calculateRssStateSameDirection(Situation const &situation, state::RssState &rssState);
      78                 :            : 
      79                 :            :   /**
      80                 :            :    * @brief Calculate safety checks and determine required rssState for non intersection opposite direction scenario
      81                 :            :    *
      82                 :            :    * @param[in]  timeIndex the time index of the situation
      83                 :            :    * @param[in]  situation situation to analyze
      84                 :            :    * @param[out] rssState  response state of the ego vehicle
      85                 :            :    *
      86                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      87                 :            :    */
      88                 :            :   bool calculateRssStateOppositeDirection(Situation const &situation, state::RssState &rssState);
      89                 :            : 
      90                 :            :   /**
      91                 :            :    * @brief Calculate safety checks and determine required rssState for longitudinal direction for
      92                 :            :    * non intersection scenario when both vehicles are driving in same direction
      93                 :            :    *
      94                 :            :    * @param[in]  situation situation to analyze
      95                 :            :    * @param[out] rssState  rssState of the ego vehicle
      96                 :            :    *
      97                 :            :    * @returns false if a failure occurred during calculations, true otherwise
      98                 :            :    *
      99                 :            :    */
     100                 :            :   bool calculateLongitudinalRssStateSameDirection(Situation const &situation, state::LongitudinalRssState &rssState);
     101                 :            : 
     102                 :            :   /**
     103                 :            :    * @brief Calculate safety checks and determine required rssState for longitudinal direction for
     104                 :            :    * non intersection scenario when vehicles are driving in opposite direction
     105                 :            :    *
     106                 :            :    * @param[in]  situation situation to analyze
     107                 :            :    * @param[out] rssState  rssState of the ego vehicle
     108                 :            :    *
     109                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     110                 :            :    *
     111                 :            :    */
     112                 :            :   bool calculateLongitudinalRssStateOppositeDirection(Situation const &situation,
     113                 :            :                                                       state::LongitudinalRssState &rssState);
     114                 :            : 
     115                 :            :   /**
     116                 :            :    * @brief Calculate safety checks and determine required rssState for lateral direction
     117                 :            :    *
     118                 :            :    * @param[in] situation      situation to analyze
     119                 :            :    * @param[out] rssStateLeft  rssState of the ego vehicle at its left side
     120                 :            :    * @param[out] rssStateRight rssState of the ego vehicle at its right side
     121                 :            :    *
     122                 :            :    * @returns false if a failure occurred during calculations, true otherwise
     123                 :            :    *
     124                 :            :    */
     125                 :            :   bool calculateLateralRssState(Situation const &situation,
     126                 :            :                                 state::LateralRssState &rssStateLeft,
     127                 :            :                                 state::LateralRssState &rssStateRight);
     128                 :            : 
     129                 :            :   struct RssSafeState
     130                 :            :   {
     131                 :            :     bool longitudinalSafe{false};
     132                 :            :     bool lateralSafe{false};
     133                 :            :   };
     134                 :            : 
     135                 :            :   /**
     136                 :            :    * @brief typedef for the mapping of object id to the corresponding RssSafeState before the danger threshold time
     137                 :            :    */
     138                 :            :   typedef std::map<situation::SituationId, RssSafeState> RssSafeStateBeforeDangerThresholdTimeMap;
     139                 :            : 
     140                 :            :   /**
     141                 :            :    * @brief the state of each situation before the danger threshold time of last timestep
     142                 :            :    *
     143                 :            :    * Needs to be stored to check which is the proper response required to solve an unclear situation
     144                 :            :    */
     145                 :            :   RssSafeStateBeforeDangerThresholdTimeMap mLastStatesBeforeDangerThresholdTime;
     146                 :            :   /**
     147                 :            :    * @brief the new state of each situation before the danger threshold time of current timestep
     148                 :            :    *
     149                 :            :    */
     150                 :            :   RssSafeStateBeforeDangerThresholdTimeMap mNewStatesBeforeDangerThresholdTime;
     151                 :            : 
     152                 :            :   /**
     153                 :            :    * @brief time index of the current processing step
     154                 :            :    * If time index increases we need to update the state maps
     155                 :            :    */
     156                 :            :   world::TimeIndex mCurrentTimeIndex{0u};
     157                 :            : };
     158                 :            : 
     159                 :            : } // namespace situation
     160                 :            : } // namespace rss
     161                 :            : } // namespace ad

Generated by: LCOV version 1.14