Filter out those obstacles that are close to the ADC so that we will ignore them and drive normally unless they really kick into our lane.
62 {
63 if (!feature.has_lane() || !feature.lane().has_lane_graph()) {
64 return;
65 }
66 const LaneGraph& lane_graph = feature.lane().lane_graph();
67 int num_lane_sequence = lane_graph.lane_sequence_size();
68 std::vector<LaneChangeType> lane_change_type(num_lane_sequence,
70 std::pair<int, double> change(-1, -1.0);
71 std::pair<int, double> all(-1, -1.0);
72
78 for (int i = 0; i < num_lane_sequence; ++i) {
79 const LaneSequence& sequence = lane_graph.lane_sequence(i);
81 (*enable_lane_sequence)[i] = false;
83 continue;
84 }
86
91 continue;
92 }
93
94
96 adc_trajectory_container);
97 ADEBUG <<
"Distance to ADC " << std::fixed << std::setprecision(6)
98 << distance;
99 if (distance > 0.0 && distance < FLAGS_lane_change_dist) {
100 bool obs_within_its_own_lane = true;
101 for (int j = 0; j < feature.polygon_point_size(); j++) {
102 Eigen::Vector2d position(feature.polygon_point(j).x(),
103 feature.polygon_point(j).y());
104 std::shared_ptr<const LaneInfo> lane_info =
106 if (lane_info == nullptr) {
107 obs_within_its_own_lane = false;
108 break;
109 }
110
111 double lane_s = 0.0;
112 double lane_l = 0.0;
114
115 double left = 0.0;
116 double right = 0.0;
117 lane_info->GetWidth(lane_s, &left, &right);
118
119 if (lane_l > left || lane_l < -right) {
120 obs_within_its_own_lane = false;
121 break;
122 }
123 }
124
125 if (obs_within_its_own_lane) {
126 (*enable_lane_sequence)[i] = false;
128 << "] due to small distance " << distance << ".";
129 }
130 }
131 }
132
136 for (int i = 0; i < num_lane_sequence; ++i) {
137 const LaneSequence& sequence = lane_graph.lane_sequence(i);
138
139 if (!(*enable_lane_sequence)[i]) {
140 ADEBUG <<
"Disabled lane sequence [" <<
ToString(sequence) <<
"].";
141 continue;
142 }
143
144 double probability = sequence.probability();
145 if (LaneSequenceWithMaxProb(lane_change_type[i], probability, all.second)) {
146 all.first = i;
147 all.second = probability;
148 }
149 if (LaneChangeWithMaxProb(lane_change_type[i], probability,
150 change.second)) {
151 change.first = i;
152 change.second = probability;
153 }
154 }
155
156 double lane_sequence_threshold = FLAGS_lane_sequence_threshold_cruise;
157 if (feature.has_junction_feature()) {
158 lane_sequence_threshold = FLAGS_lane_sequence_threshold_junction;
159 }
160
161 for (int i = 0; i < num_lane_sequence; ++i) {
162 const LaneSequence& sequence = lane_graph.lane_sequence(i);
163
164 if (!(*enable_lane_sequence)[i]) {
165 ADEBUG <<
"Disabled lane sequence [" <<
ToString(sequence) <<
"].";
166 continue;
167 }
168
169 double probability = sequence.probability();
170 if (probability < lane_sequence_threshold && i != all.first) {
171 (*enable_lane_sequence)[i] = false;
172 } else if (change.first >= 0 && change.first < num_lane_sequence &&
175 lane_change_type[i] != lane_change_type[change.first]) {
176 (*enable_lane_sequence)[i] = false;
177 }
178 }
179}
LaneChangeType GetLaneChangeType(const std::string &lane_id, const LaneSequence &lane_sequence)
Get lane change type
std::string ToString(const LaneSequence &sequence)
Convert a lane sequence to string
double GetLaneChangeDistanceWithADC(const LaneSequence &lane_sequence, const Obstacle *ego_vehicle_ptr, const ADCTrajectoryContainer *adc_trajectory_container)
Get lane change distance with ADC