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 "ad/rss/structured/RssIntersectionConstellationChecker.hpp" 11 : : 12 : : namespace ad { 13 : : namespace rss { 14 : : namespace structured { 15 : : 16 : : class RssIntersectionConstellationCheckerInputRangeTests : public testing::Test 17 : : { 18 : : protected: 19 : 4 : virtual void SetUp() 20 : : { 21 : 4 : constellation.constellation_type = world::ConstellationType::IntersectionEgoHasPriority; 22 : 4 : } 23 : : 24 : 3 : void performTestRun() 25 : : { 26 : 3 : RssIntersectionConstellationChecker checker; 27 [ + - - + : 3 : EXPECT_FALSE(checker.calculateRssStateIntersection(time_index++, constellation, rssState)); - - - - - - - - ] 28 : 3 : } 29 : : core::RelativeObjectState leadingVehicle; 30 : : core::RelativeObjectState followingVehicle; 31 : : core::RelativeConstellation constellation; 32 : : state::RssState rssState; 33 : : world::TimeIndex time_index{1u}; 34 : : }; 35 : : 36 : 4 : TEST_F(RssIntersectionConstellationCheckerInputRangeTests, no_priority_vehicle) 37 : : { 38 : 1 : RssIntersectionConstellationChecker checker; 39 [ + - ]: 1 : leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(50); 40 : 1 : leadingVehicle.structured_object_state.distance_to_enter_intersection = Distance(10.); 41 : 1 : leadingVehicle.structured_object_state.distance_to_leave_intersection = Distance(10.); 42 [ + - ]: 1 : followingVehicle = createRelativeVehicleStateForLongitudinalMotion(50); 43 : 1 : followingVehicle.dynamics.alpha_lon.accel_max = Acceleration(2.); 44 : 1 : followingVehicle.dynamics.alpha_lon.brake_min = Acceleration(-4.); 45 : 1 : followingVehicle.structured_object_state.distance_to_enter_intersection = Distance(70.); 46 : 1 : followingVehicle.structured_object_state.distance_to_leave_intersection = Distance(70.); 47 : : 48 : 1 : constellation.ego_state = leadingVehicle; 49 : 1 : constellation.other_state = followingVehicle; 50 : : constellation.relative_position 51 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::InFront, Distance(60.)); 52 : : 53 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateIntersection(time_index++, constellation, rssState)); - - - - - - - - + - ] 54 [ + - ]: 1 : } 55 : : 56 : 4 : TEST_F(RssIntersectionConstellationCheckerInputRangeTests, distanceToLeaveSmallerEgo) 57 : : { 58 : 1 : constellation.ego_state = createRelativeVehicleStateForLongitudinalMotion(120); 59 : 1 : constellation.ego_state.structured_object_state.distance_to_enter_intersection = Distance(15.); 60 : 1 : constellation.ego_state.structured_object_state.distance_to_leave_intersection = Distance(14.); 61 : : 62 : 1 : constellation.ego_state.dynamics.alpha_lon.accel_max = Acceleration(2.); 63 : 1 : constellation.ego_state.dynamics.alpha_lon.brake_min = Acceleration(-4.); 64 : : 65 : 1 : constellation.other_state = createRelativeVehicleStateForLongitudinalMotion(10); 66 : 1 : constellation.other_state.dynamics.alpha_lon.accel_max = Acceleration(2.); 67 : 1 : constellation.other_state.dynamics.alpha_lon.brake_min = Acceleration(-4.); 68 : 1 : constellation.other_state.structured_object_state.distance_to_enter_intersection = Distance(16.); 69 : 1 : constellation.other_state.structured_object_state.distance_to_leave_intersection = Distance(16.); 70 : 1 : constellation.other_state.structured_object_state.has_priority = true; 71 : : 72 : : constellation.relative_position 73 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(1.)); 74 : : 75 : 1 : performTestRun(); 76 : 1 : } 77 : : 78 : 4 : TEST_F(RssIntersectionConstellationCheckerInputRangeTests, distanceToLeaveSmallerOther) 79 : : { 80 : 1 : constellation.ego_state = createRelativeVehicleStateForLongitudinalMotion(120); 81 : 1 : constellation.ego_state.structured_object_state.distance_to_enter_intersection = Distance(15.); 82 : 1 : constellation.ego_state.structured_object_state.distance_to_leave_intersection = Distance(15.); 83 : : 84 : 1 : constellation.ego_state.dynamics.alpha_lon.accel_max = Acceleration(2.); 85 : 1 : constellation.ego_state.dynamics.alpha_lon.brake_min = Acceleration(-4.); 86 : : 87 : 1 : constellation.other_state = createRelativeVehicleStateForLongitudinalMotion(10); 88 : 1 : constellation.other_state.dynamics.alpha_lon.accel_max = Acceleration(2.); 89 : 1 : constellation.other_state.dynamics.alpha_lon.brake_min = Acceleration(-4.); 90 : 1 : constellation.other_state.structured_object_state.distance_to_enter_intersection = Distance(16.); 91 : 1 : constellation.other_state.structured_object_state.distance_to_leave_intersection = Distance(15.); 92 : 1 : constellation.other_state.structured_object_state.has_priority = true; 93 : : 94 : : constellation.relative_position 95 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(1.)); 96 : : 97 : 1 : performTestRun(); 98 : 1 : } 99 : : 100 : 4 : TEST_F(RssIntersectionConstellationCheckerInputRangeTests, both_priority_vehicle) 101 : : { 102 : 1 : leadingVehicle = createRelativeVehicleStateForLongitudinalMotion(50); 103 : 1 : leadingVehicle.structured_object_state.distance_to_enter_intersection = Distance(10.); 104 : 1 : leadingVehicle.structured_object_state.distance_to_leave_intersection = Distance(10.); 105 : 1 : leadingVehicle.structured_object_state.has_priority = true; 106 : : 107 : 1 : followingVehicle = createRelativeVehicleStateForLongitudinalMotion(50); 108 : 1 : followingVehicle.dynamics.alpha_lon.accel_max = Acceleration(2.); 109 : 1 : followingVehicle.dynamics.alpha_lon.brake_min = Acceleration(-4.); 110 : 1 : followingVehicle.structured_object_state.distance_to_enter_intersection = Distance(70.); 111 : 1 : leadingVehicle.structured_object_state.distance_to_leave_intersection = Distance(70.); 112 : 1 : followingVehicle.structured_object_state.has_priority = true; 113 : : 114 : 1 : constellation.ego_state = leadingVehicle; 115 : 1 : constellation.other_state = followingVehicle; 116 : : constellation.relative_position 117 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::InFront, Distance(60.)); 118 : : 119 : 1 : performTestRun(); 120 : 1 : } 121 : : 122 : : } // namespace structured 123 : : } // namespace rss 124 : : } // namespace ad