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 RssSituationCheckingTestsLongitudinal : public testing::Test
17 : : {
18 : : protected:
19 : 11 : virtual void SetUp()
20 : : {
21 : 11 : situation.situationType = SituationType::SameDirection;
22 : 11 : situation.situationId = SituationId(111);
23 : 11 : }
24 : :
25 : 11 : virtual void TearDown()
26 : : {
27 : 11 : }
28 : : VehicleState leadingVehicle;
29 : : VehicleState followingVehicle;
30 : : Situation situation;
31 : : state::RssState rssState;
32 : : world::TimeIndex timeIndex{1u};
33 : : };
34 : :
35 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_ego_safe_distance)
36 : : {
37 : 1 : RssStructuredSceneNonIntersectionChecker checker;
38 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(100);
39 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(10);
40 : :
41 : 1 : situation.egoVehicleState = leadingVehicle;
42 : 1 : situation.otherVehicleState = followingVehicle;
43 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::InFront, Distance(95.));
44 : :
45 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
46 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
47 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
48 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
49 : : }
50 : :
51 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_safe)
52 : : {
53 : 1 : RssStructuredSceneNonIntersectionChecker checker;
54 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
55 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
56 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
57 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
58 : :
59 : 1 : situation.egoVehicleState = followingVehicle;
60 : 1 : situation.otherVehicleState = leadingVehicle;
61 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(60.));
62 : :
63 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
64 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
65 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
66 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
67 : : }
68 : :
69 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_unsafe)
70 : : {
71 : 1 : RssStructuredSceneNonIntersectionChecker checker;
72 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
73 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
74 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
75 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
76 : :
77 : 1 : situation.egoVehicleState = followingVehicle;
78 : 1 : situation.otherVehicleState = leadingVehicle;
79 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(58.));
80 : :
81 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
82 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
83 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
84 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
85 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
86 : : }
87 : :
88 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_maxspeed_safe)
89 : : {
90 : 1 : RssStructuredSceneNonIntersectionChecker checker;
91 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
92 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
93 : 1 : followingVehicle.dynamics.maxSpeedOnAcceleration = kmhToMeterPerSec(50.);
94 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
95 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
96 : :
97 : 1 : situation.egoVehicleState = followingVehicle;
98 : 1 : situation.otherVehicleState = leadingVehicle;
99 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(40.));
100 : :
101 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
102 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
103 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
104 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
105 : : }
106 : :
107 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_maxspeed_unsafe)
108 : : {
109 : 1 : RssStructuredSceneNonIntersectionChecker checker;
110 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
111 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
112 : 1 : followingVehicle.dynamics.maxSpeedOnAcceleration = kmhToMeterPerSec(50.);
113 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
114 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
115 : :
116 : 1 : situation.egoVehicleState = followingVehicle;
117 : 1 : situation.otherVehicleState = leadingVehicle;
118 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(38.));
119 : :
120 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
121 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
122 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
123 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
124 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
125 : : }
126 : :
127 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_40kmh_maxspeed_unsafe)
128 : : {
129 : 1 : RssStructuredSceneNonIntersectionChecker checker;
130 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
131 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
132 : 1 : followingVehicle.dynamics.maxSpeedOnAcceleration = kmhToMeterPerSec(40.);
133 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
134 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
135 : :
136 : 1 : situation.egoVehicleState = followingVehicle;
137 : 1 : situation.otherVehicleState = leadingVehicle;
138 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(38.));
139 : :
140 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
141 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
142 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
143 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
144 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
145 : : }
146 : :
147 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_no_accel_unsafe)
148 : : {
149 : 1 : RssStructuredSceneNonIntersectionChecker checker;
150 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(50);
151 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
152 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(0.);
153 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
154 : :
155 : 1 : situation.egoVehicleState = followingVehicle;
156 : 1 : situation.otherVehicleState = leadingVehicle;
157 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(39.));
158 : :
159 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
160 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
161 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
162 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
163 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralBrakeMin, situation));
- + - - -
- - - ]
164 : : }
165 : :
166 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_other_standing)
167 : : {
168 : 1 : RssStructuredSceneNonIntersectionChecker checker;
169 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(0);
170 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
171 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
172 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
173 : :
174 : 1 : situation.egoVehicleState = followingVehicle;
175 : 1 : situation.otherVehicleState = leadingVehicle;
176 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(71.8));
177 : :
178 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
179 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
180 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
181 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
182 : :
183 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(71.6));
184 : :
185 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
186 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
187 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
188 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
189 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
190 : : }
191 : :
192 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_50kmh_maxspeed_other_standing)
193 : : {
194 : 1 : RssStructuredSceneNonIntersectionChecker checker;
195 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(0);
196 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(50);
197 : 1 : followingVehicle.dynamics.maxSpeedOnAcceleration = kmhToMeterPerSec(50.);
198 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
199 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
200 : :
201 : 1 : situation.egoVehicleState = followingVehicle;
202 : 1 : situation.otherVehicleState = leadingVehicle;
203 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(52.));
204 : :
205 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
206 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
207 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
208 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
209 : :
210 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(50.));
211 : :
212 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
213 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
214 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
215 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
216 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
217 : : }
218 : :
219 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_leading_other_0kmh_other_standing)
220 : : {
221 : 1 : RssStructuredSceneNonIntersectionChecker checker;
222 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(0);
223 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(0);
224 : 1 : followingVehicle.dynamics.alphaLon.accelMax = Acceleration(2.);
225 : 1 : followingVehicle.dynamics.alphaLon.brakeMin = Acceleration(-4.);
226 : :
227 : 1 : situation.egoVehicleState = followingVehicle;
228 : 1 : situation.otherVehicleState = leadingVehicle;
229 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(6.1));
230 : :
231 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
232 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState, TestSupport::stateWithInformation(cTestSupport.cLongitudinalSafe, situation));
- + - - -
- - - ]
233 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
234 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
235 : :
236 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(6.));
237 : :
238 [ + - - + : 1 : ASSERT_TRUE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
239 [ + - + - : 1 : ASSERT_EQ(rssState.longitudinalState,
- + - - -
- - - ]
240 : : TestSupport::stateWithInformation(cTestSupport.cLongitudinalBrakeMin, situation));
241 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateLeft, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
242 [ + - + - : 1 : ASSERT_EQ(rssState.lateralStateRight, TestSupport::stateWithInformation(cTestSupport.cLateralNone, situation));
- + - - -
- - - ]
243 : : }
244 : :
245 : 2 : TEST_F(RssSituationCheckingTestsLongitudinal, same_direction_both_negative_velocity)
246 : : {
247 : 1 : RssStructuredSceneNonIntersectionChecker checker;
248 [ + - ]: 1 : leadingVehicle = createVehicleStateForLongitudinalMotion(-50);
249 [ + - ]: 1 : followingVehicle = createVehicleStateForLongitudinalMotion(-50);
250 : :
251 : 1 : situation.egoVehicleState = followingVehicle;
252 : 1 : situation.otherVehicleState = leadingVehicle;
253 [ + - ]: 1 : situation.relativePosition = createRelativeLongitudinalPosition(LongitudinalRelativePosition::AtBack, Distance(71.6));
254 : :
255 [ + - - + : 1 : ASSERT_FALSE(checker.calculateRssStateNonIntersection(timeIndex++, situation, rssState));
- - - - -
- - - ]
256 : : }
257 : :
258 : : } // namespace situation
259 : : } // namespace rss
260 : : } // namespace ad
|