Bus NPC will be follow behavior tree like below.
Each Task/Flow node should be work like below.
Seqeuncer execute all child tasks in sequence order. Child nodes has priority and child nodes which describes in left side has higher priority.
Selector select one child task and excute it. Child nodes has priority and child nodes which describes in left side has higher priority.
If the NPC has no route, or current route was changed because of obstacles/lane change etc... Replan route.
The NPC follows the current lane and route.
The NPC follwing current lane and decelerating in order to avoid clash.
The NPC was safely stopped behind the othe object
If the Obstacle is dynamic and on the current lane (for example othe moving vehicles), the NPC wait until the obstacle moves.
If the NPC Try to avoid obstacle with lane change, the NPC checks the target lane and wait until the target lane will be clear.
If the NPC can avoid obstacle without lane violation, the NPC try to avoid obstacle by changing lanes
If the NPC Try to avoid obstacle with lane violation, the NPC checks the opposite lane and wait until the opposite lane will be clear.
If the NPC cannot avoid obstacle witout lane violation, the NPC try to avoid obstacle with violating lane.
If the NPC find the stopline in front of the NPC, the NPC try to stop at the Stopline.
If the NPC succeed to stopped in front of the stopline, the NPC try to follow lanes.
If the NPC find busstop in front of the NPC, the NPC try to stop at the BusStop.
If the NPC succeed at the BusStop, the NPC try to follow lanes.
The NPC wait until the yeild lane is clear
In this task, NPC try to pass throuhg the intersection.
The NPC wait until the yeild lane is clear
In this task, NPC try to turn left in the intersection.
The NPC wait until the yeild lane is clear
In this task, NPC try to turn right in the intersection.
If the NPC thinks lane change will be necessary in order to follow lanes, the NPC check the target lane is clear, if the lane is clear, the NPC execute lane change.
The NPC is executing lane change.
Each task node communicate with LGSVL simulator environment by using UniCom. (https://github.com/tier4/UniCom) Path planner/controller was implimented as a Gameobject which atached to the NPC.