apollo: Apollo didn't turn right, maybe a bug
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 18.04): Linux Ubuntu 18.04
- Apollo installed from (source or binary): source
- Apollo version (3.5, 5.0, 5.5, 6.0): 6.0
- Output of
apollo.sh configif onmasterbranch:
Steps to reproduce the issue:
Hello Apollo team! Recently I am testing Apollo 6.0 with LGSVL and I found something that may be a bug of Planning module. Here is the steps of testing:
-
The case is in map BorregasAve, as this picture shows:
I use LGSVL as simulator of Apollo. For ego configuration, I use 3D ground truth and signal sensor to replace Perception module, which ensure the correctness of NPC cars and signals. -
The destination point is on the road right of junction. In this case, the ego should deal with scenario TRAFFIC LIGHT UNPROTECTED RIGHT TURN. And since I did not turn on config
enable_right_turn_on_redinmodules/planning/conf/scenario/traffic_light_unprotected_right_turn_config.pb.txt, the ego will stop before the stop line of junction. At this moment, incyber_monitor, topic of traffic light is here:
4 items represent 4 signals in picture. In cyber_monitorthey are all red now. -
After starting simulation, ego will drive to stop line and then stop:
in picture we just see 3 signals, and the last signal is here:
At this moment, cyber_monitorshows:
Seems that the last signal cannot be seen by ego, which is reasonable. -
However, after signals turn green, ego did not run, like this:
Based on log files, I found that the stage of Planning module at this moment is STOP in TRAFFIC LIGHT UNPROTECTED RIGHT TURN. Here is the code:
for (const auto& traffic_light_overlap_id :
GetContext()->current_traffic_light_overlap_ids) {
// get overlap along reference line
current_traffic_light_overlap = scenario::util::GetOverlapOnReferenceLine(
reference_line_info, traffic_light_overlap_id,
ReferenceLineInfo::SIGNAL);
if (!current_traffic_light_overlap) {
continue;
}
// set right_of_way_status
reference_line_info.SetJunctionRightOfWay(
current_traffic_light_overlap->start_s, false);
const double distance_adc_to_stop_line =
current_traffic_light_overlap->start_s - adc_front_edge_s;
auto signal_color = frame->GetSignal(traffic_light_overlap_id).color();
ADEBUG << "traffic_light_overlap_id[" << traffic_light_overlap_id
<< "] start_s[" << current_traffic_light_overlap->start_s
<< "] distance_adc_to_stop_line[" << distance_adc_to_stop_line
<< "] color[" << signal_color << "]";
// check distance to stop line
if (distance_adc_to_stop_line >
scenario_config_.max_valid_stop_distance()) {
traffic_light_all_stop = false;
break;
}
// check on traffic light color
if (signal_color != TrafficLight::GREEN) {
traffic_light_all_green = false;
traffic_light_no_right_turn_on_red =
CheckTrafficLightNoRightTurnOnRed(traffic_light_overlap_id);
break;
}
}
if (traffic_light_all_stop && traffic_light_all_green) {
return FinishStage(true);
}
if (!traffic_light_no_right_turn_on_red) {
if (traffic_light_all_stop && !traffic_light_all_green) {
// check distance pass stop line
const double distance_adc_pass_stop_line =
adc_front_edge_s - current_traffic_light_overlap->end_s;
ADEBUG << "distance_adc_pass_stop_line[" << distance_adc_pass_stop_line
<< "]";
if (distance_adc_pass_stop_line >
scenario_config_.min_pass_s_distance()) {
return FinishStage(false);
}
if (scenario_config_.enable_right_turn_on_red()) {
// when right_turn_on_red is enabled
// check on wait-time
if (GetContext()->stop_start_time == 0.0) {
GetContext()->stop_start_time = Clock::NowInSeconds();
} else {
auto start_time = GetContext()->stop_start_time;
const double wait_time = Clock::NowInSeconds() - start_time;
ADEBUG << "stop_start_time[" << start_time << "] wait_time["
<< wait_time << "]";
if (wait_time >
scenario_config_.red_light_right_turn_stop_duration_sec()) {
return FinishStage(false);
}
}
}
}
}
For the signal part, seems that Apollo will check all the traffic light overlap, if all of them are green, traffic_light_all_stop will be set as true, which causes stage transition. Besides, due to logs added by my codes, I found that a traffic light overlap seems to be created when simulation starts. That is, at the first time ego can see the signal beside the road, so ego creates a traffic light overlap for it. However, when ego passes the signal, it cannot see it any more, but the overlap is still in GetOverlapOnReferenceLine. So it will still be checked by Planning module, but the color of signal is always UNKNOWN, which stops the ego permanently.
The same problem will happen in LEFT TURN scenario too. I do not know whether it is a bug, and I cannot find related issues either. Hope for your reply, thanks!
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (13 by maintainers)
Commits related to this issue
- fix: ignore undetected traffic signal at junction Addresses #14842 — committed to YuqiHuai/BaiduApollo by YuqiHuai a year ago
- fix: ignore undetected traffic signal at junction Addresses #14842 — committed to YuqiHuai/BaiduApollo by YuqiHuai a year ago
- fix: ignore undetected traffic signal at junction Addresses #14842 — committed to YuqiHuai/BaiduApollo by YuqiHuai a year ago
- fix: ignore undetected traffic signal at junction Resolves #14842 — committed to YuqiHuai/BaiduApollo by YuqiHuai a year ago
@LordonCN Oh! That sounds good. Thanks for responding! I’ll create a pull request for the right-turn scenario fix and continue adding the fix to other scenarios to the same PR.
@1Jyfc Sounds good. Thank you for your feedback as well! This has been a long but interesting discussion.