LCOV - code coverage report
Current view: top level - tests/situation - RssSituationCheckingTestsIntersectionPriority.cpp (source / functions) Hit Total Coverage
Test: ad_rss Lines: 75 75 100.0 %
Date: 2024-04-30 13:12:49 Functions: 8 8 100.0 %
Branches: 57 242 23.6 %

           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/RssStructuredSceneIntersectionChecker.hpp"
      11                 :            : 
      12                 :            : namespace ad {
      13                 :            : namespace rss {
      14                 :            : namespace situation {
      15                 :            : 
      16                 :            : class RssSituationCheckingTestsIntersectionPriority : public testing::Test
      17                 :            : {
      18                 :            : protected:
      19                 :          3 :   virtual void SetUp()
      20                 :            :   {
      21                 :          3 :     situation.situationType = SituationType::IntersectionEgoHasPriority;
      22                 :          3 :   }
      23                 :            : 
      24                 :          3 :   virtual void TearDown()
      25                 :            :   {
      26                 :          3 :   }
      27                 :            :   VehicleState leadingVehicle;
      28                 :            :   VehicleState followingVehicle;
      29                 :            :   Situation situation;
      30                 :            :   state::RssState rssState;
      31                 :            :   world::TimeIndex timeIndex{1u};
      32                 :            : };
      33                 :            : 
      34                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionPriority, 50kmh_safe_distance_ego_leading)
      35                 :            : {
      36                 :          1 :   RssStructuredSceneIntersectionChecker checker;
      37         [ +  - ]:          1 :   leadingVehicle = createVehicleStateForLongitudinalMotion(120);
      38                 :          1 :   leadingVehicle.distanceToEnterIntersection = Distance(2.);
      39                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(2.);
      40                 :          1 :   leadingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      41                 :          1 :   leadingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      42                 :          1 :   leadingVehicle.hasPriority = true;
      43                 :            : 
      44         [ +  - ]:          1 :   followingVehicle = createVehicleStateForLongitudinalMotion(30);
      45                 :          1 :   followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      46                 :          1 :   followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      47                 :          1 :   followingVehicle.distanceToEnterIntersection = Distance(12.);
      48                 :          1 :   followingVehicle.distanceToLeaveIntersection = Distance(12.);
      49                 :            : 
      50                 :          1 :   situation.otherVehicleState = followingVehicle;
      51                 :          1 :   situation.egoVehicleState = leadingVehicle;
      52         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(10.));
      53                 :            : 
      54   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      55   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
      56   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      57   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      58                 :            : }
      59                 :            : 
      60                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionPriority, 50kmh_safe_distance_ego_following)
      61                 :            : {
      62                 :          1 :   RssStructuredSceneIntersectionChecker checker;
      63         [ +  - ]:          1 :   leadingVehicle = createVehicleStateForLongitudinalMotion(50);
      64                 :          1 :   leadingVehicle.distanceToEnterIntersection = Distance(10.);
      65                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(10.);
      66         [ +  - ]:          1 :   followingVehicle = createVehicleStateForLongitudinalMotion(50);
      67                 :          1 :   followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      68                 :          1 :   followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      69                 :          1 :   followingVehicle.distanceToEnterIntersection = Distance(70.);
      70                 :          1 :   followingVehicle.distanceToLeaveIntersection = Distance(70.);
      71                 :            : 
      72                 :          1 :   situation.otherVehicleState = leadingVehicle;
      73                 :          1 :   situation.egoVehicleState = followingVehicle;
      74                 :          1 :   situation.egoVehicleState.hasPriority = true;
      75         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(60.));
      76                 :            : 
      77   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
      78   [ -  +  -  -  :          1 :   ASSERT_TRUE(rssState.longitudinalState.isSafe);
          -  -  -  -  -  
                      - ]
      79   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
      80   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      81   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
      82                 :            : }
      83                 :            : 
      84                 :          2 : TEST_F(RssSituationCheckingTestsIntersectionPriority, 50km_h_stop_before_intersection)
      85                 :            : {
      86                 :          1 :   RssStructuredSceneIntersectionChecker checker;
      87         [ +  - ]:          1 :   leadingVehicle = createVehicleStateForLongitudinalMotion(50);
      88                 :          1 :   leadingVehicle.distanceToEnterIntersection = Distance(80.);
      89                 :          1 :   leadingVehicle.distanceToLeaveIntersection = Distance(80.);
      90                 :          1 :   leadingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      91                 :          1 :   leadingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      92         [ +  - ]:          1 :   followingVehicle = createVehicleStateForLongitudinalMotion(50);
      93                 :          1 :   followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
      94                 :          1 :   followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
      95                 :          1 :   followingVehicle.distanceToEnterIntersection = Distance(110.);
      96                 :          1 :   followingVehicle.distanceToLeaveIntersection = Distance(110.);
      97                 :            : 
      98                 :          1 :   situation.otherVehicleState = leadingVehicle;
      99                 :          1 :   situation.egoVehicleState = followingVehicle;
     100                 :          1 :   situation.egoVehicleState.hasPriority = true;
     101         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(30.));
     102                 :            : 
     103   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     104   [ -  +  -  -  :          1 :   ASSERT_TRUE(rssState.longitudinalState.isSafe);
          -  -  -  -  -  
                      - ]
     105   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
          -  +  -  -  -  
                -  -  - ]
     106   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     107   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     108                 :            : 
     109                 :          1 :   situation.otherVehicleState.distanceToEnterIntersection = Distance(70.);
     110                 :          1 :   situation.otherVehicleState.distanceToLeaveIntersection = Distance(70.);
     111                 :          1 :   situation.egoVehicleState.distanceToEnterIntersection = Distance(100.);
     112                 :          1 :   situation.egoVehicleState.distanceToLeaveIntersection = Distance(100.);
     113         [ +  - ]:          1 :   situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::Overlap, Distance(0.));
     114                 :            : 
     115   [ +  -  -  +  :          1 :   ASSERT_TRUE(checker.calculateRssStateIntersection(timeIndex++, situation, rssState));
          -  -  -  -  -  
                -  -  - ]
     116   [ -  +  -  -  :          1 :   ASSERT_FALSE(rssState.longitudinalState.isSafe);
          -  -  -  -  -  
                      - ]
     117   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalNone, situation));
          -  +  -  -  -  
                -  -  - ]
     118   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     119   [ +  -  +  -  :          1 :   ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
          -  +  -  -  -  
                -  -  - ]
     120                 :            : }
     121                 :            : 
     122                 :            : } // namespace situation
     123                 :            : } // namespace rss
     124                 :            : } // namespace ad

Generated by: LCOV version 1.14