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/RssNonIntersectionConstellationChecker.hpp"
11 : :
12 : : namespace ad {
13 : : namespace rss {
14 : : namespace structured {
15 : :
16 : : class RssOppositeDirectionConstellationCheckerTests : public testing::Test
17 : : {
18 : : protected:
19 : 12 : virtual void SetUp()
20 : : {
21 : 12 : constellation.constellation_type = world::ConstellationType::OppositeDirection;
22 : 12 : }
23 : :
24 : 12 : virtual void TearDown()
25 : : {
26 : 12 : }
27 : : core::RelativeObjectState correctVehicle;
28 : : core::RelativeObjectState oppositeVehicle;
29 : : core::RelativeConstellation constellation;
30 : : state::RssState rssState;
31 : : world::TimeIndex time_index{1u};
32 : : };
33 : :
34 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_brake_min_correct)
35 : : {
36 : 1 : RssNonIntersectionConstellationChecker checker;
37 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
38 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
39 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
40 : :
41 : 1 : constellation.ego_state = correctVehicle;
42 : 1 : constellation.other_state = oppositeVehicle;
43 : : constellation.relative_position
44 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(178.));
45 : :
46 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
47 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
48 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
49 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
50 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
51 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
52 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
53 [ + - ]: 1 : }
54 : :
55 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_shorter_ego_reaction_time)
56 : : {
57 : 1 : RssNonIntersectionConstellationChecker checker;
58 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
59 : 1 : correctVehicle.dynamics.response_time = Duration(1.);
60 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
61 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
62 : :
63 : 1 : constellation.ego_state = correctVehicle;
64 : 1 : constellation.other_state = oppositeVehicle;
65 : :
66 : : constellation.relative_position
67 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(178.));
68 : :
69 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
70 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
71 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, constellation));
72 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
73 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
74 : :
75 : : constellation.relative_position
76 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(150.));
77 : :
78 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
79 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
80 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
81 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
82 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
83 [ + - ]: 1 : }
84 : :
85 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_safe)
86 : : {
87 : 1 : RssNonIntersectionConstellationChecker checker;
88 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
89 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
90 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
91 : :
92 : 1 : constellation.ego_state = correctVehicle;
93 : 1 : constellation.other_state = oppositeVehicle;
94 : : constellation.relative_position
95 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(197.));
96 : :
97 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
98 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
99 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, constellation));
100 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
101 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
102 [ + - ]: 1 : }
103 : :
104 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_BrakeMinCorrect)
105 : : {
106 : 1 : RssNonIntersectionConstellationChecker checker;
107 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
108 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
109 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
110 : :
111 : 1 : constellation.ego_state = correctVehicle;
112 : 1 : constellation.other_state = oppositeVehicle;
113 : : constellation.relative_position
114 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(196.));
115 : :
116 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
117 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
118 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
119 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
120 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
121 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
122 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
123 [ + - ]: 1 : }
124 : :
125 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_response_1s_safe)
126 : : {
127 : 1 : RssNonIntersectionConstellationChecker checker;
128 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
129 : 1 : correctVehicle.dynamics.response_time = Duration(1.);
130 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
131 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
132 : :
133 : 1 : constellation.ego_state = correctVehicle;
134 : 1 : constellation.other_state = oppositeVehicle;
135 : : constellation.relative_position
136 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(196.));
137 : :
138 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
139 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
140 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, constellation));
141 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
142 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
143 [ + - ]: 1 : }
144 : :
145 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_brake_min_correct_ego_vehicle_in_front)
146 : : {
147 : 1 : RssNonIntersectionConstellationChecker checker;
148 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
149 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
150 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
151 : :
152 : 1 : constellation.ego_state = correctVehicle;
153 : 1 : constellation.other_state = oppositeVehicle;
154 : : constellation.relative_position
155 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::InFront, Distance(178.7));
156 : :
157 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
158 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
159 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
160 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
161 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
162 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
163 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
164 [ + - ]: 1 : }
165 : :
166 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_vehicles_at_same_position)
167 : : {
168 : 1 : RssNonIntersectionConstellationChecker checker;
169 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
170 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
171 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
172 : :
173 : 1 : constellation.ego_state = correctVehicle;
174 : 1 : constellation.other_state = oppositeVehicle;
175 : : constellation.relative_position
176 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::OverlapFront, Distance(0.));
177 : :
178 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
179 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
180 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
181 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
182 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
183 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
184 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
185 [ + - ]: 1 : }
186 : :
187 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 0kmh_vehicles_at_same_position)
188 : : {
189 : 1 : RssNonIntersectionConstellationChecker checker;
190 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(0);
191 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(0);
192 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
193 : :
194 : 1 : constellation.ego_state = correctVehicle;
195 : 1 : constellation.other_state = oppositeVehicle;
196 : : constellation.relative_position
197 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::OverlapFront, Distance(0.));
198 : :
199 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
200 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
201 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
202 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
203 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
204 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
205 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
206 [ + - ]: 1 : }
207 : :
208 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 0kmh_vehicles_very_near_min_longitudinal_safety_distance)
209 : : {
210 : 1 : RssNonIntersectionConstellationChecker checker;
211 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(0);
212 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(0);
213 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
214 : 1 : correctVehicle.dynamics.response_time = physics::Duration(0.5);
215 : 1 : oppositeVehicle.dynamics.response_time = physics::Duration(0.5);
216 : :
217 : 1 : constellation.ego_state = correctVehicle;
218 : 1 : constellation.other_state = oppositeVehicle;
219 : : constellation.relative_position
220 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(1.9));
221 : :
222 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
223 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
224 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, constellation));
225 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
226 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
227 : :
228 : 1 : constellation.ego_state.dynamics.min_longitudinal_safety_distance = physics::Distance(2.);
229 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
230 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
231 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMinCorrect, constellation));
232 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
233 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right, TestSupport::stateWithInformation(cTestSupport.cLateralNone, constellation));
- + - - -
- - - +
- ]
234 [ + - ]: 1 : }
235 : :
236 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, incorrect_vehicle_state_ego)
237 : : {
238 : 1 : RssNonIntersectionConstellationChecker checker;
239 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
240 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
241 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
242 : :
243 : 1 : correctVehicle.dynamics.alpha_lon.brake_min = Acceleration(-1);
244 : :
245 : 1 : constellation.ego_state = correctVehicle;
246 : 1 : constellation.other_state = oppositeVehicle;
247 : : constellation.relative_position
248 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(178.7));
249 : :
250 [ + - - + : 1 : ASSERT_FALSE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
251 [ + - ]: 1 : }
252 : :
253 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, incorrect_vehicle_state_other)
254 : : {
255 : 1 : RssNonIntersectionConstellationChecker checker;
256 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
257 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
258 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
259 : :
260 : 1 : oppositeVehicle.dynamics.alpha_lon.brake_min = Acceleration(-1.);
261 : :
262 : 1 : constellation.ego_state = correctVehicle;
263 : 1 : constellation.other_state = oppositeVehicle;
264 : : constellation.relative_position
265 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::AtBack, Distance(178.7));
266 : :
267 [ + - - + : 1 : ASSERT_FALSE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
268 [ + - ]: 1 : }
269 : :
270 : 4 : TEST_F(RssOppositeDirectionConstellationCheckerTests, 50kmh_brake_min_ego_opposite)
271 : : {
272 : 1 : RssNonIntersectionConstellationChecker checker;
273 [ + - ]: 1 : correctVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
274 [ + - ]: 1 : oppositeVehicle = createRelativeVehicleStateForLongitudinalMotion(50);
275 : 1 : oppositeVehicle.structured_object_state.is_in_correct_lane = false;
276 : :
277 : 1 : constellation.ego_state = oppositeVehicle;
278 : 1 : constellation.other_state = correctVehicle;
279 : : constellation.relative_position
280 [ + - ]: 1 : = createRelativeLongitudinalPosition(core::LongitudinalRelativePosition::InFront, Distance(178.7));
281 : :
282 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(time_index++, constellation, rssState));
- - - - -
- - - +
- ]
283 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinal_state,
- + - - -
- - - ]
284 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, constellation));
285 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_left,
- + - - -
- - - ]
286 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
287 [ + - + - : 1 : ASSERT_EQ(rssState.lateral_state_right,
- + - - -
- - - ]
288 [ + - ]: 1 : TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, constellation));
289 [ + - ]: 1 : }
290 : :
291 : : } // namespace structured
292 : : } // namespace rss
293 : : } // namespace ad
|