diff --git a/planning/behavior_velocity_crosswalk_module/README.md b/planning/behavior_velocity_crosswalk_module/README.md
index 5f82fe839fda6..37c3fb58049a6 100644
--- a/planning/behavior_velocity_crosswalk_module/README.md
+++ b/planning/behavior_velocity_crosswalk_module/README.md
@@ -1,204 +1,169 @@
-## Crosswalk
+# Crosswalk
-### Role
+## Role
-This module judges whether the ego should stop in front of the crosswalk in order to provide safe passage of pedestrians and bicycles based on object's behavior and surround traffic.
+This module judges whether the ego should stop in front of the crosswalk in order to provide safe passage of crosswalk users such as pedestrians and bicycles based on the objects' behavior and surround traffic.
-### Activation Timing
+## Features
-The manager launch crosswalk scene modules when the reference path conflicts crosswalk lanelets.
+### Yield
-### Module Parameters
+#### Target Object
-#### Common parameters
+The target object's type is filtered by the following parameters in the `object_filtering.target_object` namespace.
-| Parameter | Type | Description |
-| ----------------------------- | ---- | ------------------------------- |
-| `common.show_processing_time` | bool | whether to show processing time |
+| Parameter | Unit | Type | Description |
+| ------------ | ---- | ---- | ---------------------------------------------- |
+| `unknown` | [-] | bool | whether to look and stop by UNKNOWN objects |
+| `pedestrian` | [-] | bool | whether to look and stop by PEDESTRIAN objects |
+| `bicycle` | [-] | bool | whether to look and stop by BICYCLE objects |
+| `motorcycle` | [-] | bool | whether to look and stop by MOTORCYCLE objects |
-#### Parameters for input data
+In order to detect crosswalk users crossing outside the crosswalk as well, the crosswalk module creates an attention area around the crosswalk shown as the yellow polygon in the figure. If the object's predicted path collides with the attention area, the object will be targeted for yield.
-| Parameter | Type | Description |
-| ------------------------------------ | ------ | ---------------------------------------------- |
-| `common.traffic_light_state_timeout` | double | [s] timeout threshold for traffic light signal |
+
-#### Parameters for stop position
+The parameter is in the `object_filtering.target_object` namespace.
-The crosswalk module determines a stop position at least `stop_distance_from_object` away from the object.
+| Parameter | Unit | Type | Description |
+| --------------------------- | ---- | ------ | ------------------------------------------------------------------------------------------------- |
+| `crosswalk_attention_range` | [m] | double | the detection area is defined as -X meters before the crosswalk to +X meters behind the crosswalk |
-
+#### Stop Position
-The stop line is the reference point for the stopping position of the vehicle, but if there is no stop line in front of the crosswalk, the position `stop_distance_from_crosswalk` meters before the crosswalk is the virtual stop line for the vehicle. Then, if the stop position determined from `stop_distance_from_object` exists in front of the stop line determined from the HDMap or `stop_distance_from_crosswalk`, the actual stop position is determined according to `stop_distance_from_object` in principle, and vice versa.
+First of all, `stop_distance_from_object [m]` is always kept at least between the ego and the target object for safety.
-
+When the stop line exists in the lanelet map, the stop position is calculated based on the line.
+When the stop line does **NOT** exist in the lanelet map, the stop position is calculated by keeping `stop_distance_from_crosswalk [m]` between the ego and the crosswalk.
-
+
+
+
+
+
+
+
+
On the other hand, if pedestrian (bicycle) is crossing **wide** crosswalks seen in scramble intersections, and the pedestrian position is more than `far_object_threshold` meters away from the stop line, the actual stop position is determined to be `stop_distance_from_object` and pedestrian position, not at the stop line.
-See the workflow in algorithms section.
+In the `stop_position` namespace,
-| Parameter | Type | Description |
-| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `stop_position.stop_distance_from_object` | double | [m] the vehicle decelerates to be able to stop in front of object with margin |
-| `stop_position.stop_distance_from_crosswalk` | double | [m] make stop line away from crosswalk when no explicit stop line exists |
-| `stop_position.far_object_threshold` | double | [m] if objects cross X meters behind the stop line, the stop position is determined according to the object position (stop_distance_from_object meters before the object) |
-| `stop_position.stop_position_threshold` | double | [m] threshold for check whether the vehicle stop in front of crosswalk |
+| Parameter | | Type | Description |
+| ------------------------------ | --- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `stop_position_threshold` | [m] | double | If the ego vehicle has stopped near the stop line than this value, this module assumes itself to have achieved yielding. |
+| `stop_distance_from_crosswalk` | [m] | double | make stop line away from crosswalk for the Lanelet2 map with no explicit stop lines |
+| `far_object_threshold` | [m] | double | If objects cross X meters behind the stop line, the stop position is determined according to the object position (stop_distance_from_object meters before the object) for the case where the crosswalk width is very wide |
+| `stop_distance_from_object` | [m] | double | the vehicle decelerates to be able to stop in front of object with margin |
-#### Parameters for ego's slow down velocity
+#### Yield decision
-| Parameter | Type | Description |
-| --------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------- |
-| `slow_velocity` | double | [m/s] target vehicle velocity when module receive slow down command from FOA |
-| `max_slow_down_jerk` | double | [m/sss] minimum jerk deceleration for safe brake |
-| `max_slow_down_accel` | double | [m/ss] minimum accel deceleration for safe brake |
-| `no_relax_velocity` | double | [m/s] if the current velocity is less than X m/s, ego always stops at the stop position(not relax deceleration constraints) |
+The module makes a decision to yield only when the pedestrian traffic light is **GREEN** or **UNKNOWN**.
+Calculating the collision point, the decision is based on the following variables.
-#### Parameters for stuck vehicle
+- TTC: Time-To-Collision which is the time for the **ego** to reach the virtual collision point.
+- TTV: Time-To-Vehicle which is the time for the **object** to reach the virtual collision point.
-If there are low speed or stop vehicle ahead of the crosswalk, and there is not enough space between the crosswalk and the vehicle (see following figure), closing the distance to that vehicle could cause Ego to be stuck on the crosswalk. So, in this situation, this module plans to stop before the crosswalk and wait until the vehicles move away, even if there are no pedestrians or bicycles.
+Depending on the relative relationship between TTC and TTV, the ego's behavior at crosswalks can be classified into three categories based on [1]
-
+- A. **TTC >> TTV**: The object has enough time to cross before the ego.
+ - No stop planning.
+- B. **TTC ≒ TTV**: There is a risk of collision.
+ - **Stop point is inserted in the ego's path**.
+- C. **TTC << TTV**: Ego has enough time to cross before the object.
+ - No stop planning.
-| Parameter | Type | Description |
-| ------------------------------------------------ | ------ | ---------------------------------------------------------------------- |
-| `stuck_vehicle.stuck_vehicle_velocity` | double | [m/s] maximum velocity threshold whether the vehicle is stuck |
-| `stuck_vehicle.max_stuck_vehicle_lateral_offset` | double | [m] maximum lateral offset for stuck vehicle position should be looked |
-| `stuck_vehicle.stuck_vehicle_attention_range` | double | [m] the detection area is defined as X meters behind the crosswalk |
+
+
+
+
+
+
+
+
-#### Parameters for pass judge logic
+The boundary of A and B is interpolated from `ego_pass_later_margin_x` and `ego_pass_later_margin_y`. In the case of the upper figure, `ego_pass_later_margin_x` is `{0, 1, 2}` and `ego_pass_later_margin_y` is `{1, 4, 6}` for example.
+The same way, the boundary of B and C is calculated from `ego_pass_first_margin_x` and `ego_pass_first_margin_y`. In the case of the upper figure, `ego_pass_first_margin_x` is `{3, 5}` and `ego_pass_first_margin_y` is `{0, 1}` for example.
-Also see algorithm section.
+In the `pass_judge` namespace,
-| Parameter | Type | Description |
-| ------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `pass_judge.ego_pass_first_margin` | double | [s] time margin for ego pass first situation |
-| `pass_judge.ego_pass_later_margin` | double | [s] time margin for object pass first situation |
-| `pass_judge.stop_object_velocity_threshold` | double | [m/s] velocity threshold for the module to judge whether the objects is stopped |
-| `pass_judge.min_object_velocity` | double | [m/s] minimum object velocity (compare the estimated velocity by perception module with this parameter and adopt the larger one to calculate TTV.) |
-| `pass_judge.timeout_no_intention_to_walk` | double | [s] if the pedestrian does not move for X seconds after stopping before the crosswalk, the module judge that ego is able to pass first. |
-| `pass_judge.timeout_ego_stop_for_yield` | double | [s] the amount of time which ego should be stopping to query whether it yields or not. |
+| Parameter | | Type | Description |
+| ---------------------------------- | ----- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
+| `ego_pass_first_margin_x` | [[s]] | double | time to collision margin vector for ego pass first situation (the module judges that ego don't have to stop at TTC + MARGIN < TTV condition) |
+| `ego_pass_first_margin_y` | [[s]] | double | time to vehicle margin vector for ego pass first situation (the module judges that ego don't have to stop at TTC + MARGIN < TTV condition) |
+| `ego_pass_first_additional_margin` | [s] | double | additional time margin for ego pass first situation to suppress chattering |
+| `ego_pass_later_margin_x` | [[s]] | double | time to vehicle margin vector for object pass first situation (the module judges that ego don't have to stop at TTV + MARGIN < TTC condition) |
+| `ego_pass_later_margin_y` | [[s]] | double | time to collision margin vector for object pass first situation (the module judges that ego don't have to stop at TTV + MARGIN < TTC condition) |
+| `ego_pass_later_additional_margin` | [s] | double | additional time margin for object pass first situation to suppress chattering |
-#### Parameters for object filtering
+### Smooth Yield Decision
-As a countermeasure against pedestrians attempting to cross outside the crosswalk area, this module watches not only the crosswalk zebra area but also in front of and behind space of the crosswalk, and if there are pedestrians or bicycles attempting to pass through the watch area, this module judges whether ego should pass or stop.
+When the object is stopped around the crosswalk but has no intention to walk, the ego will yield the object forever.
+To prevent this dead lock behavior, the ego will cancel the yield depending on the situation.
-
+#### When there is no traffic light
-This module mainly looks the following objects as target objects. There are also optional flags that enables the pass/stop decision for `motorcycle` and `unknown` objects.
-
-- pedestrian
-- bicycle
-
-| Parameter | Type | Description |
-| --------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
-| `crosswalk_attention_range` | double | [m] the detection area is defined as -X meters before the crosswalk to +X meters behind the crosswalk |
-| `target/unknown` | bool | whether to look and stop by UNKNOWN objects |
-| `target/bicycle` | bool | whether to look and stop by BICYCLE objects |
-| `target/motorcycle` | bool | whether to look and stop MOTORCYCLE objects |
-| `target/pedestrian` | bool | whether to look and stop PEDESTRIAN objects |
-
-### Inner-workings / Algorithms
-
-#### Stop position
-
-The stop position is determined by the existence of the stop line defined by the HDMap, the positional relationship between the stop line and the pedestrians and bicycles, and each parameter.
-
-```plantuml
-start
-:calculate stop point from **stop_distance_from_object** (POINT-1);
-if (There is the stop line in front of the crosswalk?) then (yes)
- :calculate stop point from stop line (POINT-2.1);
-else (no)
- :calculate stop point from **stop_distance_from_crosswalk** (POINT-2.2);
-endif
-if (The distance ego to **POINT-1** is shorter than the distance ego to **POINT-2**) then (yes)
- :ego stops at POINT-1;
-else if (The distance ego to **POINT-1** is longer than the distance ego to **POINT-2** + **far_object_threshold**) then (yes)
- :ego stops at POINT-1;
-else (no)
- :ego stops at POINT-2;
-endif
-end
-```
+For the object stopped around the crosswalk but has no intention to walk (\*1), when the ego keeps stopping to yield for a certain time (\*2), the ego cancels the yield and start driving.
-#### Pass judge logic
+\*1:
+The time is calculated by the interpolation of distance between the object and crosswalk with `distance_map_for_no_intention_to_walk` and `timeout_map_for_no_intention_to_walk`.
-At first, this module determines whether the pedestrians or bicycles are likely to cross the crosswalk based on the color of the pedestrian traffic light signal related to the crosswalk. Only when the pedestrian traffic signal is **RED**, this module judges that the objects will not cross the crosswalk and skip the pass judge logic.
+In the `pass_judge` namespace,
-Secondly, this module makes a decision as to whether ego should stop in front of the crosswalk or pass through based on the relative relationship between TTC(Time-To-Collision) and TTV(Time-To-Vehicle). The TTC is the time it takes for ego to reach the virtual collision point, and the TTV is the time it takes for the object to reach the virtual collision point.
+| Parameter | | Type | Description |
+| --------------------------------------- | ----- | ------ | --------------------------------------------------------------------------------- |
+| `distance_map_for_no_intention_to_walk` | [[m]] | double | distance map to calculate the timeout for no intention to walk with interpolation |
+| `timeout_map_for_no_intention_to_walk` | [[s]] | double | timeout map to calculate the timeout for no intention to walk with interpolation |
-
+\*2:
+In the `pass_judge` namespace,
-Depending on the relative relationship between TTC and TTV, the ego's behavior at crosswalks can be classified into three categories.
+| Parameter | | Type | Description |
+| ---------------------------- | --- | ------ | ----------------------------------------------------------------------------------------------------------------------- |
+| `timeout_ego_stop_for_yield` | [s] | double | If the ego maintains the stop for this amount of time, then the ego proceeds, assuming it has stopped long time enough. |
-1. **TTC >> TTV**: The objects have enough time to cross first before ego reaches the crosswalk. (Type-A)
-2. **TTC ≒ TTV**: There is a risk of a near miss and collision between ego and objects at the virtual collision point. (Type-B)
-3. **TTC << TTV**: Ego has enough time to path through the crosswalk before the objects reach the virtual collision point. (Type-C)
+#### When there is traffic light
-This module judges that ego is able to pass through the crosswalk without collision risk when the relative relationship between TTC and TTV is **Type-A** and **Type-C**. On the other hand, this module judges that ego needs to stop in front of the crosswalk prevent collision with objects in **Type-B** condition. The time margin can be set by parameters `ego_pass_first_margin` and `ego_pass_later_margin`. This logic is designed based on [1].
+For the object stopped around the crosswalk but has no intention to walk (\*1), the ego will cancel the yield without stopping.
+This comes from the assumption that the object has no intention to walk since it is stopped even though the pedestrian traffic light is green.
-
+\*1:
+The crosswalk user's intention to walk is calculated in the same way as `When there is no traffic light`.
-This module uses the larger value of estimated object velocity and `min_object_velocity` in calculating TTV in order to avoid division by zero.
-
-```plantuml
-start
-if (Pedestrian's traffic light signal is **RED**?) then (yes)
-else (no)
- if (There are objects around the crosswalk?) then (yes)
- :calculate TTC & TTV;
- if (TTC < TTV + **ego_pass_first_margin** && TTV < TTC + **ego_pass_later_margin**) then (yes)
- :STOP;
- else (no)
- :PASS;
- endif
- endif
-endif
-end
-```
+
+
+
+
+
+
+
+
-#### Dead lock prevention
+#### New Object Handling
-If there are objects stop within a radius of `min_object_velocity * ego_pass_later_margin` meters from virtual collision point, this module judges that ego should stop based on the pass judge logic described above at all times. In such a situation, even if the pedestrian has no intention of crossing, ego continues the stop decision on the spot. So, this module has another logic for dead lock prevention, and if the object continues to stop for more than `timeout_no_intention_to_walk` seconds after ego stops in front of the crosswalk, this module judges that the object has no intention of crossing and switches from **STOP** state to **PASS** state. The parameter `stop_object_velocity_threshold` is used to judge whether the objects are stopped or not. In addition, if the object starts to move after the module judges that the object has no intention of crossing, this module judges whether ego should stop or not once again.
+Due to the perception's limited performance where the tree or poll is recognized as a pedestrian or the tracking failure in the crowd or occlusion, even if the surrounding environment does not change, the new pedestrian (= the new ID's pedestrian) may suddenly appear unexpectedly.
+When this happens when the ego is going to pass the crosswalk, the ego will stop suddenly.
-
+To fix this issue, the option `disable_yield_for_new_stopped_object` is prepared.
+If set to true, the new stopped object will be ignored during the yield decision around the crosswalk with a traffic light.
+
+In the `pass_judge` namespace,
+
+| Parameter | | Type | Description |
+| -------------------------------------- | --- | ---- | ------------------------------------------------------------------------------------------------ |
+| `disable_yield_for_new_stopped_object` | [-] | bool | If set to true, the new stopped object will be ignored around the crosswalk with a traffic light |
-#### Safety Slow Down Behavior
+### Safety Slow Down Behavior
In current autoware implementation if there are no target objects around a crosswalk, ego vehicle
will not slow down for the crosswalk. However, if ego vehicle to slow down to a certain speed in
@@ -207,27 +172,103 @@ it is instructed
in [lanelet2_format_extension.md](https://github.com/autowarefoundation/autoware_common/blob/main/tmp/lanelet2_extension/docs/lanelet2_format_extension.md)
document.
-### Limitations
+| Parameter | | Type | Description |
+| --------------------- | ------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
+| `slow_velocity` | [m/s] | double | target vehicle velocity when module receive slow down command from FOA |
+| `max_slow_down_jerk` | [m/sss] | double | minimum jerk deceleration for safe brake |
+| `max_slow_down_accel` | [m/ss] | double | minimum accel deceleration for safe brake |
+| `no_relax_velocity` | [m/s] | double | if the current velocity is less than X m/s, ego always stops at the stop position(not relax deceleration constraints) |
-When multiple crosswalks are nearby (such as intersection), this module may make a stop decision even at crosswalks where the object has no intention of crossing.
+### Stuck Vehicle Detection
+
+The feature will make the ego not to stop on the crosswalk.
+When there are low-speed or stopped vehicle ahead of the crosswalk, and there is not enough space between the crosswalk and the vehicle, the crosswalk module will plan to stop before the crosswalk even if there are no pedestrians or bicycles.
+
+`min_acc`, `min_jerk`, and `max_jerk` are met. If the ego cannot stop before the crosswalk with these parameters, the stop position will move forward.
+
+
+
+In the `stuck_vehicle` namespace,
+
+| Parameter | Unit | Type | Description |
+| ---------------------------------- | ------- | ------ | ----------------------------------------------------------------------- |
+| `stuck_vehicle_velocity` | [m/s] | double | maximum velocity threshold whether the target vehicle is stopped or not |
+| `max_stuck_vehicle_lateral_offset` | [m] | double | maximum lateral offset of the target vehicle position |
+| `stuck_vehicle_attention_range` | [m] | double | detection area length ahead of the crosswalk |
+| `min_acc` | [m/ss] | double | minimum acceleration to stop |
+| `min_jerk` | [m/sss] | double | minimum jerk to stop |
+| `max_jerk` | [m/sss] | double | maximum jerk to stop |
+
+### Others
+
+In the `common` namespace,
+
+| Parameter | Unit | Type | Description |
+| ----------------------------- | ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
+| `show_processing_time` | [-] | bool | whether to show processing time |
+| `traffic_light_state_timeout` | [s] | double | timeout threshold for traffic light signal |
+| `enable_rtc` | [-] | bool | if true, the scene modules should be approved by (request to cooperate)rtc function. if false, the module can be run without approval from rtc. |
+
+## Known Issues
+
+- The yield decision may be sometimes aggressive or conservative depending on the case.
+ - The main reason is that the crosswalk module does not know the ego's position in the future. The detailed ego's position will be determined after the whole planning.
+ - Currently the module assumes that the ego will move with a constant velocity.
+
+## Debugging
+
+### Visualization of debug markers
+
+`/planning/scenario_planning/lane_driving/behavior_planning/behavior_velocity_planner/debug/crosswalk` shows the following markers.
-### Known Issues
+- Yellow polygons
+ - Ego footprints' polygon to calculate the collision check.
+- Pink polygons
+ - Object footprints' polygon to calculate the collision check.
+- The color of crosswalk
+ - Considering the traffic light's color, red means the target crosswalk and white means the ignored crosswalk.
+- Texts
+ - It shows the module id, TTC, TTV, and the module state.
+
+### Visualization of Time-To-Collision
-### Debugging
+```sh
+ros2 run behavior_velocity_crosswalk_module time_to_collision_plotter.py
+```
-By `ros2 run behavior_velocity_crosswalk_module time_to_collision_plotter.py`, you can visualize the following figure of the ego and pedestrian's time to collision.
+enables you to visualize the following figure of the ego and pedestrian's time to collision.
The label of each plot is `-`.
-### References/External links
+## Trouble Shooting
+
+### Behavior
+
+- Q. The ego stopped around the crosswalk even though there were no crosswalk user objects.
+ - A. See [Stuck Vehicle Detection](https://autowarefoundation.github.io/autoware.universe/pr-5583/planning/behavior_velocity_crosswalk_module/#stuck-vehicle-detection).
+- Q. The crosswalk virtual wall suddenly appeared resulting in the sudden stop.
+ - A. There may be a crosswalk user started moving when the ego was close to the crosswalk.
+- Q. The crosswalk module decides to stop even when the pedestrian traffic light is red.
+ - A. The lanelet map may be incorrect. The pedestrian traffic light and the crosswalk have to be related.
+- Q. In the planning simulation, the crosswalk module does the yield decision to stop on all the crosswalks.
+ - A. This is because the pedestrian traffic light is unknown by default. In this case, the crosswalk does the yield decision for safety.
+
+### Parameter Tuning
+
+- Q. The ego's yield behavior is too conservative.
+ - A. Tune `ego_pass_later_margin` described in [Yield Decision](https://autowarefoundation.github.io/autoware.universe/pr-5583/planning/behavior_velocity_crosswalk_module/#stuck-vehicle-detection)
+- Q. The ego's yield behavior is too aggressive.
+ - A. Tune `ego_pass_later_margin` described in [Yield Decision](https://autowarefoundation.github.io/autoware.universe/pr-5583/planning/behavior_velocity_crosswalk_module/#stuck-vehicle-detection)
+
+## References/External links
[1] 佐藤 みなみ, 早坂 祥一, 清水 政行, 村野 隆彦, 横断歩行者に対するドライバのリスク回避行動のモデル化, 自動車技術会論文集, 2013, 44 巻, 3 号, p. 931-936.
diff --git a/planning/behavior_velocity_crosswalk_module/docs/crosswalk_attention_range.svg b/planning/behavior_velocity_crosswalk_module/docs/crosswalk_attention_range.svg
index 270a61264fe66..26e6118756bd8 100644
--- a/planning/behavior_velocity_crosswalk_module/docs/crosswalk_attention_range.svg
+++ b/planning/behavior_velocity_crosswalk_module/docs/crosswalk_attention_range.svg
@@ -1,213 +1,132 @@
+
-