LCOV - code coverage report
Current view: top level - tests/situation - RssSituationCheckingTestsOppositeDirection.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 128 128 100.0 %
Date: 2024-10-01 15:08:14 Functions: 22 22 100.0 %
Branches: 134 518 25.9 %

           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                 :            : #include "TestSupport.hpp"
      10                 :            : #include "situation/RssStructuredSceneNonIntersectionChecker.hpp"
      11                 :            : 
      12                 :            : namespace ad {
      13                 :            : namespace rss {
      14                 :            : namespace situation {
      15                 :            : 
      16                 :            : class RssSituationCheckingTestsOppositeDirection : public testing::Test
      17                 :            : {
      18                 :            : protected:
      19                 :         10 :   virtual void SetUp()
      20                 :            :   {
      21                 :         10 :     situation.situationType = SituationType::OppositeDirection;
      22                 :         10 :   }
      23                 :            : 
      24                 :         10 :   virtual void TearDown()
      25                 :            :   {
      26                 :         10 :   }
      27                 :            :   VehicleState correctVehicle;
      28                 :            :   VehicleState oppositeVehicle;
      29                 :            :   Situation situation;
      30                 :            :   state::RssState rssState;
      31                 :            :   world::TimeIndex timeIndex{1u};
      32                 :            : };
      33                 :            : 
      34                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_brake_min_correct)
      35                 :            : {
      36                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
      37         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
      38         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
      39                 :          1 :   oppositeVehicle.isInCorrectLane = false;
      40                 :            : 
      41                 :          1 :   situation.egoVehicleState = correctVehicle;
      42                 :          1 :   situation.otherVehicleState = oppositeVehicle;
      43         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(178.));
      44                 :            : 
      45   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      46   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
      47                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, situation));
      48   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
      49   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
      50                 :            : }
      51                 :            : 
      52                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_shorter_ego_reaction_time)
      53                 :            : {
      54                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
      55         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
      56                 :          1 :   correctVehicle.dynamics.responseTime = Duration(1.);
      57         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
      58                 :          1 :   oppositeVehicle.isInCorrectLane = false;
      59                 :            : 
      60                 :          1 :   situation.egoVehicleState = correctVehicle;
      61                 :          1 :   situation.otherVehicleState = oppositeVehicle;
      62                 :            : 
      63         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(178.));
      64                 :            : 
      65   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      66   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
      67   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      68   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      69                 :            : 
      70         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(150.));
      71                 :            : 
      72   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      73   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
      74                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, situation));
      75   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      76   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      77                 :            : }
      78                 :            : 
      79                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_safe)
      80                 :            : {
      81                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
      82         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
      83         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
      84                 :          1 :   oppositeVehicle.isInCorrectLane = false;
      85                 :            : 
      86                 :          1 :   situation.egoVehicleState = correctVehicle;
      87                 :          1 :   situation.otherVehicleState = oppositeVehicle;
      88         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(197.));
      89                 :            : 
      90   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      91   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
      92   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      93   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      94                 :            : }
      95                 :            : 
      96                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_BrakeMinCorrect)
      97                 :            : {
      98                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
      99         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     100         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     101                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     102                 :            : 
     103                 :          1 :   situation.egoVehicleState = correctVehicle;
     104                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     105         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(196.));
     106                 :            : 
     107   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     108   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
     109                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, situation));
     110   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     111   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     112                 :            : }
     113                 :            : 
     114                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_response_1s_safe)
     115                 :            : {
     116                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     117         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     118                 :          1 :   correctVehicle.dynamics.responseTime = Duration(1.);
     119         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     120                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     121                 :            : 
     122                 :          1 :   situation.egoVehicleState = correctVehicle;
     123                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     124         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(196.));
     125                 :            : 
     126   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     127   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
     128   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     129   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     130                 :            : }
     131                 :            : 
     132                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_brake_min_correct_ego_vehicle_in_front)
     133                 :            : {
     134                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     135         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     136         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     137                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     138                 :            : 
     139                 :          1 :   situation.egoVehicleState = correctVehicle;
     140                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     141                 :            :   situation.relativePosition
     142         [ +  - ]:          1 :     = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(178.7));
     143                 :            : 
     144   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     145   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
     146                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, situation));
     147   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     148   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     149                 :            : }
     150                 :            : 
     151                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_vehicles_at_same_position)
     152                 :            : {
     153                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     154         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     155         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     156                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     157                 :            : 
     158                 :          1 :   situation.egoVehicleState = correctVehicle;
     159                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     160                 :            :   situation.relativePosition
     161         [ +  - ]:          1 :     = createRelativeLongitudinalPosition(LongitudinalRelativePosition::OverlapFront, Distance(0.));
     162                 :            : 
     163   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     164   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
     165                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, situation));
     166   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     167   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     168                 :            : }
     169                 :            : 
     170                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, incorrect_vehicle_state_ego)
     171                 :            : {
     172                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     173         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     174         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     175                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     176                 :            : 
     177                 :          1 :   correctVehicle.dynamics.alphaLon.brakeMin = Acceleration(-1);
     178                 :            : 
     179                 :          1 :   situation.egoVehicleState = correctVehicle;
     180                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     181                 :            :   situation.relativePosition
     182         [ +  - ]:          1 :     = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(178.7));
     183                 :            : 
     184   [ +  -  -  +  :          1 :   ASSERT_FALSE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     185                 :            : }
     186                 :            : 
     187                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, incorrect_vehicle_state_other)
     188                 :            : {
     189                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     190         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     191         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     192                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     193                 :            : 
     194                 :          1 :   oppositeVehicle.dynamics.alphaLon.brakeMin = Acceleration(-1.);
     195                 :            : 
     196                 :          1 :   situation.egoVehicleState = correctVehicle;
     197                 :          1 :   situation.otherVehicleState = oppositeVehicle;
     198                 :            :   situation.relativePosition
     199         [ +  - ]:          1 :     = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(178.7));
     200                 :            : 
     201   [ +  -  -  +  :          1 :   ASSERT_FALSE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     202                 :            : }
     203                 :            : 
     204                 :          2 : TEST_F(RssSituationCheckingTestsOppositeDirection, 50kmh_brake_min_ego_opposite)
     205                 :            : {
     206                 :          1 :   RssStructuredSceneNonIntersectionChecker checker;
     207         [ +  - ]:          1 :   correctVehicle = createVehicleStateForLongitudinalMotion(50);
     208         [ +  - ]:          1 :   oppositeVehicle = createVehicleStateForLongitudinalMotion(50);
     209                 :          1 :   oppositeVehicle.isInCorrectLane = false;
     210                 :            : 
     211                 :          1 :   situation.egoVehicleState = oppositeVehicle;
     212                 :          1 :   situation.otherVehicleState = correctVehicle;
     213                 :            :   situation.relativePosition
     214         [ +  - ]:          1 :     = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(178.7));
     215                 :            : 
     216   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     217   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState,
          -  +  -  -  -  
                -  -  - ]
     218                 :            :             TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
     219   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     220   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
          -  +  -  -  -  
                -  -  - ]
     221                 :            : }
     222                 :            : 
     223                 :            : } // namespace situation
     224                 :            : } // namespace rss
     225                 :            : } // namespace ad

Generated by: LCOV version 1.14