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/core/RssSituationExtraction.hpp"
11 : :
12 : : namespace ad {
13 : : namespace rss {
14 : : namespace core {
15 : :
16 : : class RssSituationExtractionOppositeDirectionTests : public testing::Test
17 : : {
18 : : protected:
19 : 2 : virtual void SetUp()
20 : : {
21 : 2 : worldModel.default_ego_vehicle_rss_dynamics = getEgoRssDynamics();
22 : 2 : leadingObject = createObject(36., 0.);
23 : 2 : leadingObject.object_id = 0;
24 : 2 : constellation.constellation_type = world::ConstellationType::OppositeDirection;
25 : 2 : constellation.object_rss_dynamics = getObjectRssDynamics();
26 : 2 : constellation.ego_vehicle_rss_dynamics = getEgoRssDynamics();
27 : :
28 : : {
29 : 2 : world::OccupiedRegion occupiedRegion;
30 : 2 : occupiedRegion.lon_range.minimum = ParametricValue(0.8);
31 : 2 : occupiedRegion.lon_range.maximum = ParametricValue(1.0);
32 : 2 : occupiedRegion.segment_id = 1.;
33 : 2 : occupiedRegion.lat_range.minimum = ParametricValue(0.2);
34 : 2 : occupiedRegion.lat_range.maximum = ParametricValue(0.4);
35 : :
36 [ + - ]: 2 : leadingObject.occupied_regions.push_back(occupiedRegion);
37 : : }
38 : :
39 : 2 : followingObject = createObject(36., 0.);
40 : 2 : followingObject.object_id = 1;
41 : : {
42 : 2 : world::OccupiedRegion occupiedRegion;
43 : 2 : occupiedRegion.lon_range.minimum = ParametricValue(0.1);
44 : 2 : occupiedRegion.lon_range.maximum = ParametricValue(0.2);
45 : 2 : occupiedRegion.segment_id = 1.;
46 : 2 : occupiedRegion.lat_range.minimum = ParametricValue(0.6);
47 : 2 : occupiedRegion.lat_range.maximum = ParametricValue(0.8);
48 [ + - ]: 2 : followingObject.occupied_regions.push_back(occupiedRegion);
49 : : }
50 : 2 : }
51 : :
52 : 2 : virtual void TearDown()
53 : : {
54 : 2 : followingObject.occupied_regions.clear();
55 : 2 : leadingObject.occupied_regions.clear();
56 : 2 : constellation.ego_vehicle_road.clear();
57 : 2 : }
58 : :
59 : : world::Object followingObject;
60 : : world::Object leadingObject;
61 : : world::WorldModel worldModel;
62 : : world::Constellation constellation;
63 : : RssSituationExtraction constellationExtraction;
64 : : };
65 : :
66 : 4 : TEST_F(RssSituationExtractionOppositeDirectionTests, noLongitudinalDifference)
67 : : {
68 : 1 : core::RssSituationSnapshot situationSnapshot;
69 : :
70 [ + - ]: 1 : constellation.ego_vehicle = objectAsEgo(leadingObject);
71 [ + - ]: 1 : constellation.object = followingObject;
72 [ + - + - ]: 1 : constellation.ego_vehicle_road.push_back(longitudinalNoDifferenceRoadSegment());
73 : :
74 [ + - ]: 1 : worldModel.constellations.push_back(constellation);
75 : 1 : worldModel.time_index = 1;
76 : :
77 [ + - - + : 1 : ASSERT_TRUE(constellationExtraction.extractSituation(worldModel, situationSnapshot));
- - - - -
- - - +
- ]
78 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.time_index, worldModel.time_index);
- - - - -
- + - ]
79 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations.size(), 1u);
- - - - -
- + - ]
80 : :
81 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.longitudinal_distance, Distance(6));
- - - - -
- + - ]
82 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.structured_object_state.velocity.speed_lon_min, Speed(10));
- - - - -
- + - ]
83 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.structured_object_state.velocity.speed_lon_max, Speed(10));
- - - - -
- + - ]
84 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.dynamics.alpha_lon.accel_max,
- - - - -
- ]
85 [ + - ]: 1 : constellation.ego_vehicle_rss_dynamics.alpha_lon.accel_max);
86 : :
87 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.lateral_position,
- - - - -
- ]
88 [ + - ]: 1 : core::LateralRelativePosition::AtLeft);
89 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.lateral_distance, Distance(1));
- - - - -
- + - ]
90 [ + - ]: 1 : }
91 : :
92 : 4 : TEST_F(RssSituationExtractionOppositeDirectionTests, longitudinalDifference)
93 : : {
94 : 1 : core::RssSituationSnapshot situationSnapshot;
95 : :
96 [ + - ]: 1 : constellation.ego_vehicle = objectAsEgo(followingObject);
97 [ + - ]: 1 : constellation.object = leadingObject;
98 [ + - + - ]: 1 : constellation.ego_vehicle_road.push_back(longitudinalDifferenceRoadSegment());
99 : :
100 [ + - ]: 1 : worldModel.constellations.push_back(constellation);
101 : 1 : worldModel.time_index = 1;
102 : :
103 [ + - - + : 1 : ASSERT_TRUE(constellationExtraction.extractSituation(worldModel, situationSnapshot));
- - - - -
- - - +
- ]
104 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.time_index, worldModel.time_index);
- - - - -
- + - ]
105 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations.size(), 1u);
- - - - -
- + - ]
106 : :
107 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.longitudinal_distance, Distance(2));
- - - - -
- + - ]
108 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.structured_object_state.velocity.speed_lon_min, Speed(10));
- - - - -
- + - ]
109 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.structured_object_state.velocity.speed_lon_max, Speed(10));
- - - - -
- + - ]
110 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.dynamics.alpha_lon.accel_max,
- - - - -
- ]
111 [ + - ]: 1 : constellation.ego_vehicle_rss_dynamics.alpha_lon.accel_max);
112 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].ego_state.dynamics.alpha_lon.brake_min,
- - - - -
- ]
113 [ + - ]: 1 : constellation.ego_vehicle_rss_dynamics.alpha_lon.brake_min);
114 : :
115 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.lateral_position,
- - - - -
- ]
116 [ + - ]: 1 : core::LateralRelativePosition::AtRight);
117 [ + - - + : 1 : ASSERT_EQ(situationSnapshot.constellations[0].relative_position.lateral_distance, Distance(1));
- - - - -
- + - ]
118 [ + - ]: 1 : }
119 : :
120 : : } // namespace core
121 : : } // namespace rss
122 : : } // namespace ad
|