ApolloAuto / apollo

An open autonomous driving platform
Apache License 2.0
24.72k stars 9.62k forks source link

About traffic_light_unprotected_left_turn in Apollo Planning module #15201

Open Cyrus-k opened 7 months ago

Cyrus-k commented 7 months ago

Hello,developers. Recently, I am working on a project about planning module and when I learnt Apollo's code, a question occurred. In scenario TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN, I notice there exists a transition from stage_approach to lane_follow. This code can be found in stage_approach.cc in code about TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN. The condition of this transition is GetContext()->current_traffic_light_overlap_ids.empty(). But in my opinion, once Apollo Planning module decided to enter TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN scenario, there must be an overlap. So I do not understand why current_traffic_light_overlap_ids() can be empty. The overlap cannot disappear during stage_approach in TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN. So I do not think this transition can be achieved during driving procedure. So is this code below a dead code? if (GetContext()->current_traffic_light_overlap_ids.empty()) { return FinishScenario(); } Or there exists some real driving scenarios that can trigger this transition?I hope for your guide. Thank you very much.

YuqiHuai commented 7 months ago

Maybe it was added to make sure Apollo doesn't "accidentally" go into TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN with no traffic light. This safe-check pattern can also be found in other scenario stage, for example https://github.com/ApolloAuto/apollo/blob/a3c851fc5844e0684b9c5108231fcc2c15cebb8e/modules/planning/scenarios/bare_intersection/unprotected/stage_approach.cc#L56C1-L58C4

Also, I believe I never managed to get Apollo to enter the unprotected left turn stage. I had to give a green light for Apollo to enter the intersection and once the green light was given Apollo entered the protected stage...