diff --git a/launch/tier4_planning_launch/config/scenario_planning/lane_driving/motion_planning/obstacle_stop_planner/obstacle_stop_planner.param.yaml b/launch/tier4_planning_launch/config/scenario_planning/lane_driving/motion_planning/obstacle_stop_planner/obstacle_stop_planner.param.yaml index 82a77203343f7..55a21d6cd7b20 100644 --- a/launch/tier4_planning_launch/config/scenario_planning/lane_driving/motion_planning/obstacle_stop_planner/obstacle_stop_planner.param.yaml +++ b/launch/tier4_planning_launch/config/scenario_planning/lane_driving/motion_planning/obstacle_stop_planner/obstacle_stop_planner.param.yaml @@ -1,25 +1,49 @@ /**: ros__parameters: + hunting_threshold: 0.5 # even if the obstacle disappears, the stop judgment continues for hunting_threshold [s] + lowpass_gain: 0.9 # gain parameter for low pass filter [-] + max_velocity: 20.0 # max velocity [m/s] + enable_slow_down: False # whether to use slow down planner [-] + stop_planner: - stop_margin: 5.0 # stop margin distance from obstacle on the path [m] - min_behavior_stop_margin: 5.0 # stop margin distance when any other stop point is inserted in stop margin [m] - step_length: 1.0 # step length for pointcloud search range [m] - extend_distance: 0.0 # extend trajectory to consider after goal obstacle in the extend_distance - expand_stop_range: 0.0 # margin of vehicle footprint [m] + # params for stop position + stop_position: + max_longitudinal_margin: 5.0 # stop margin distance from obstacle on the path [m] + min_longitudinal_margin: 5.0 # stop margin distance when any other stop point is inserted in stop margin [m] + hold_stop_margin_distance: 0.0 # the ego keeps stopping if the ego is in this margin [m] + + # params for detection area + detection_area: + lateral_margin: 0.0 # margin of vehicle footprint [m] + step_length: 1.0 # step length for pointcloud search range [m] + extend_distance: 0.0 # extend trajectory to consider after goal obstacle in the extend_distance [m] + slow_down_planner: - # slow down planner parameters - forward_margin: 5.0 # margin distance from slow down point to vehicle front [m] - backward_margin: 0.0 # margin distance from slow down point to vehicle rear [m] - expand_slow_down_range: 1.0 # offset from vehicle side edge for expanding the search area of the surrounding point cloud [m] - max_slow_down_vel: 1.38 # max slow down velocity [m/s] - min_slow_down_vel: 0.28 # min slow down velocity [m/s] - - # slow down constraint parameters - consider_constraints: False # set "True", if no decel plan found under jerk/dec constrains, relax target slow down vel - forward_margin_min: 1.0 # min margin for relaxing slow down margin [m/s] - forward_margin_span: -0.1 # fineness param for relaxing slow down margin [m/s] - jerk_min_slow_down: -0.6 # min slow down jerk constraint [m/sss] - jerk_span: -0.01 # fineness param for planning deceleration jerk [m/sss] - jerk_start: -0.1 # init jerk used for deceleration planning [m/sss] - slow_down_vel: 1.38 # target slow down velocity [m/s] + # params for slow down section + slow_down_section: + longitudinal_forward_margin: 5.0 # margin distance from slow down point to vehicle front [m] + longitudinal_backward_margin: 0.0 # margin distance from slow down point to vehicle rear [m] + longitudinal_margin_span: -0.1 # fineness param for relaxing slow down margin (use this param if consider_constraints is True) [m/s] + min_longitudinal_forward_margin: 1.0 # min margin for relaxing slow down margin (use this param if consider_constraints is True) [m/s] + + # params for detection area + detection_area: + lateral_margin: 1.0 # offset from vehicle side edge for expanding the search area of the surrounding point cloud [m] + + # params for velocity + target_velocity: + max_slow_down_velocity: 1.38 # max slow down velocity (use this param if consider_constraints is False)[m/s] + min_slow_down_velocity: 0.28 # min slow down velocity (use this param if consider_constraints is False)[m/s] + slow_down_velocity: 1.38 # target slow down velocity (use this param if consider_constraints is True)[m/s] + + # params for deceleration constraints (use this param if consider_constraints is True) + constraints: + jerk_min_slow_down: -0.6 # min slow down jerk constraint [m/sss] + jerk_span: -0.01 # fineness param for planning deceleration jerk [m/sss] + jerk_start: -0.1 # init jerk used for deceleration planning [m/sss] + + # others + consider_constraints: False # set "True", if no decel plan found under jerk/dec constrains, relax target slow down vel [-] + velocity_threshold_decel_complete: 0.2 # use for judge whether the ego velocity converges the target slow down velocity [m/s] + acceleration_threshold_decel_complete: 0.1 # use for judge whether the ego velocity converges the target slow down velocity [m/ss] diff --git a/planning/obstacle_stop_planner/README.md b/planning/obstacle_stop_planner/README.md index be62447684982..3b0a38d194a78 100644 --- a/planning/obstacle_stop_planner/README.md +++ b/planning/obstacle_stop_planner/README.md @@ -11,22 +11,7 @@ - Adaptive Cruise Controller (ACC) - embeds target velocity in trajectory when there is a dynamic point cloud on the trajectory. -In order to stop with a `stop margin` from the obstacle exists, the stop point (`v=0`) is inserted at a distance of `baselink to front` + `stop margin` from the obstacle. The `baselink to front` means the distance between `base_link`(center of rear-wheel axis) and front of the car. - -If a stop point has already been inserted by other nodes between the obstacle and a position which is `stop margin` meters away from the obstacle, the stop point is inserted at a distance of `baselink to front` + `min behavior stop margin` from the obstacle. - -
- - -
- -When the deceleration section is inserted, the start point of the section is inserted in front of the target point cloud by the distance of `baselink to front` + `slow down forward margin`. the end point of the section is inserted behind the target point cloud by the distance of `slow down backward margin` + `baselink to rear`. The `baselink to rear` means the distance between `base_link` and rear of the car. The velocities of points in the deceleration section are modified to the deceleration velocity. `slow down backward margin` and `slow down forward margin` are determined by the parameters described below. - -
- -
- -## Input topics +### Input topics | Name | Type | Description | | --------------------------- | ----------------------------------------------- | ------------------- | @@ -37,40 +22,87 @@ When the deceleration section is inserted, the start point of the section is ins | `~/input/dynamic_objects` | autoware_auto_perception_msgs::PredictedObjects | dynamic objects | | `~/input/expand_stop_range` | tier4_planning_msgs::msg::ExpandStopRange | expand stop range | -## Output topics +### Output topics | Name | Type | Description | | ---------------------- | --------------------------------------- | -------------------------------------- | | `~output/trajectory` | autoware_auto_planning_msgs::Trajectory | trajectory to be followed | | `~output/stop_reasons` | tier4_planning_msgs::StopReasonArray | reasons that cause the vehicle to stop | -## Modules - ### Common Parameter -| Parameter | Type | Description | -| ------------------- | ------ | ---------------------------------------------------------------------------------------- | -| `enable_slow_down` | bool | enable slow down planner [-] | -| `max_velocity` | double | max velocity [m/s] | -| `hunting_threshold` | double | # even if the obstacle disappears, the stop judgment continues for hunting_threshold [s] | -| `lowpass_gain` | double | low pass gain for calculating acceleration [-] | +| Parameter | Type | Description | +| ------------------- | ------ | -------------------------------------------------------------------------------------- | +| `enable_slow_down` | bool | enable slow down planner [-] | +| `max_velocity` | double | max velocity [m/s] | +| `hunting_threshold` | double | even if the obstacle disappears, the stop judgment continues for hunting_threshold [s] | +| `lowpass_gain` | double | low pass gain for calculating acceleration [-] | + +## Obstacle Stop Planner + +### Role + +This module inserts the stop point before the obstacle with margin. In nominal case, the margin is the sum of `baselink_to_front` and `max_longitudinal_margin`. The `baselink_to_front` means the distance between `baselink`(center of rear-wheel axis) and front of the car. The detection area is generated along the processed trajectory as following figure. (This module cut off the input trajectory behind the ego position and decimates the trajectory points for reducing computational costs.) + +
+ ![example](./docs/collision_parameters.svg){width=1000} +
parameters for obstacle stop planner
+
+ +
+ ![example](./docs/stop_target.svg){width=1000} +
target for obstacle stop planner
+
+ +If another stop point has already been inserted by other modules within `max_longitudinal_margin`, the margin is the sum of `baselink_to_front` and `min_longitudinal_margin`. This feature exists to avoid stopping unnaturally position. (For example, the ego stops unnaturally far away from stop line of crosswalk that pedestrians cross to without this feature.) + +
+ ![example](./docs/min_longitudinal_margin.svg){width=1000} +
minimum longitudinal margin
+
+ +The module searches the obstacle pointcloud within detection area. When the pointcloud is found, `Adaptive Cruise Controller` modules starts to work. only when `Adaptive Cruise Controller` modules does not insert target velocity, the stop point is inserted to the trajectory. The stop point means the point with 0 velocity. + +### Restart prevention + +If it needs X meters (e.g. 0.5 meters) to stop once the vehicle starts moving due to the poor vehicle control performance, the vehicle goes over the stopping position that should be strictly observed when the vehicle starts to moving in order to approach the near stop point (e.g. 0.3 meters away). + +This module has parameter `hold_stop_margin_distance` in order to prevent from these redundant restart. If the vehicle is stopped within `hold_stop_margin_distance` meters from stop point of the module, the module judges that the vehicle has already stopped for the module's stop point and plans to keep stopping current position even if the vehicle is stopped due to other factors. + +
+ ![example](./docs/restart_prevention.svg){width=1000} +
parameters
+
+ +
+ ![example](./docs/restart.svg){width=1000} +
outside the hold_stop_margin_distance
+
+ +
+ ![example](./docs/keep_stopping.svg){width=1000} +
inside the hold_stop_margin_distance
+
-### Obstacle Stop Planner +### Parameters -#### Role +#### Stop position -`Obstacle Stop Planner` module inserts a stop point in trajectory when there is a static point cloud on the trajectory. This module does not work when `Adaptive Cruise Controller` works. +| Parameter | Type | Description | +| --------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `max_longitudinal_margin` | double | margin between obstacle and the ego's front [m] | +| `min_longitudinal_margin` | double | if any obstacle exists within `max_longitudinal_margin`, this module set margin as the value of _stop margin_ to `min_longitudinal_margin` [m] | +| `hold_stop_margin_distance` | double | parameter for restart prevention (See above section) [m] | -| Parameter | Type | Description | -| ---------------------------------------- | ------ | ----------------------------------------------------------------------------- | -| `stop_planner.stop_margin` | double | stop margin distance from obstacle on the path [m] | -| `stop_planner.min_behavior_stop_margin` | double | stop margin distance when any other stop point is inserted in stop margin [m] | -| `stop_planner.step_length` | double | step length for pointcloud search range [m] | -| `stop_planner.extend_distance` | double | extend trajectory to consider after goal obstacle in the extend_distance [m] | -| `stop_planner.expand_stop_range` | double | margin of vehicle footprint [m] | -| `stop_planner.hold_stop_margin_distance` | double | parameter for restart prevention (See following section) [m] | +#### Obstacle detection area -#### Flowchart +| Parameter | Type | Description | +| ----------------- | ------ | ----------------------------------------------------------------------------------- | +| `lateral_margin` | double | lateral margin from the vehicle footprint for collision obstacle detection area [m] | +| `step_length` | double | step length for pointcloud search range [m] | +| `extend_distance` | double | extend trajectory to consider after goal obstacle in the extend_distance [m] | + +### Flowchart ```plantuml @startuml @@ -103,52 +135,56 @@ stop @enduml ``` -First, this module cut off the trajectory behind the car and decimates the points of trajectory for reducing computational costs. +## Slow Down Planner -Then, a detection area is generated by the decimated trajectory as following figure. The detection area means the area through which the vehicle-body passes. +### Role -![vehicle_shape](./docs/vehicle_shape.drawio.svg) +This module inserts the slow down section before the obstacle with forward margin and backward margin. The forward margin is the sum of `baselink_to_front` and `longitudinal_forward_margin`, and the backward margin is the sum of `baselink_to_front` and `longitudinal_backward_margin`. The ego keeps slow down velocity in slow down section. The velocity is calculated the following equation. -The module searches the obstacle pointcloud within detection area. When the pointcloud is found, `Adaptive Cruise Controller` modules starts to work. only when `Adaptive Cruise Controller` modules does not insert target velocity, the stop point is inserted to the trajectory. The stop point means the point with 0 velocity. +$v_{target} = v_{min} + \frac{l_{ld} - l_{vw}/2}{l_{margin}} (v_{max} - v_{min} )$ -![pointcloud](./docs/point_cloud.drawio.svg) +- $v_{target}$ : slow down target velocity [m/s] +- $v_{min}$ : `min_slow_down_velocity` [m/s] +- $v_{max}$ : `max_slow_down_velocity` [m/s] +- $l_{ld}$ : lateral deviation between the obstacle and the ego footprint [m] +- $l_{margin}$ : `lateral_margin` [m] +- $l_{vw}$ : width of the ego footprint [m] -#### Restart prevention - -If it needs X meters (e.g. 0.5 meters) to stop once the vehicle starts moving due to the poor vehicle control performance, the vehicle goes over the stopping position that should be strictly observed when the vehicle starts to moving in order to approach the near stop point (e.g. 0.3 meters away). - -This module has parameter `hold_stop_margin_distance` in order to prevent from these redundant restart. If the vehicle is stopped within `hold_stop_margin_distance` meters from stop point of the module (\_front_to_stop_line < hold_stop_margin_distance), the module judges that the vehicle has already stopped for the module's stop point and plans to keep stopping current position even if the vehicle is stopped due to other factors. +The above equation means that the smaller the lateral deviation of the pointcloud, the lower the velocity of the slow down section.
- ![example](./docs/restart_prevention.svg){width=1000} -
parameters
+ ![example](./docs/slow_down_parameters.svg){width=1000} +
parameters for slow down planner
- ![example](./docs/restart.svg){width=1000} -
outside the hold_stop_margin_distance
+ ![example](./docs/slow_down_target.svg){width=1000} +
target for slow down planner
-
- ![example](./docs/keep_stopping.svg){width=1000} -
inside the hold_stop_margin_distance
-
+### Parameters + +#### Slow down section -### Slow Down Planner +| Parameter | Type | Description | +| ------------------------------ | ------ | ----------------------------------------------- | +| `longitudinal_forward_margin` | double | margin between obstacle and the ego's front [m] | +| `longitudinal_backward_margin` | double | margin between obstacle and the ego's rear [m] | -#### Role +#### Obstacle detection area -`Slow Down Planner` module inserts a deceleration point in trajectory when there is a point cloud near the trajectory. +| Parameter | Type | Description | +| ---------------- | ------ | ----------------------------------------------------------------------------------- | +| `lateral_margin` | double | lateral margin from the vehicle footprint for slow down obstacle detection area [m] | -| Parameter | Type | Description | -| --------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------- | -| `slow_down_planner.slow_down_forward_margin` | double | margin distance from slow down point to vehicle front [m] | -| `slow_down_planner.slow_down_backward_margin` | double | margin distance from slow down point to vehicle rear [m] | -| `slow_down_planner.expand_slow_down_range` | double | offset from vehicle side edge for expanding the search area of the surrounding point cloud [m] | -| `slow_down_planner.max_slow_down_vel` | double | max slow down velocity [m/s] | -| `slow_down_planner.min_slow_down_vel` | double | min slow down velocity [m/s] | +#### Slow down target velocity -#### Flowchart +| Parameter | Type | Description | +| ------------------------ | ------ | ---------------------------- | +| `max_slow_down_velocity` | double | max slow down velocity [m/s] | +| `min_slow_down_velocity` | double | min slow down velocity [m/s] | + +### Flowchart ```plantuml @startuml @@ -176,35 +212,9 @@ stop @enduml ``` -First, this module cut off the trajectory behind the car and decimates the points of trajectory for reducing computational costs. ( This is the same process as that of `Obstacle Stop planner` module. ) - -Then, a detection area is generated by the decimated trajectory as following figure. The detection area in this module is the extended area of the detection area used in `Obstacle Stop Planner` module. The distance to be extended depends on the above parameter `expand_slow_down_range`. - -![vehicle_shape_decel](./docs/vehicle_shape_decel.drawio.svg) - -The module searches the obstacle pointcloud within detection area. When the pointcloud is found, the deceleration point is inserted to the trajectory. - -![pointcloud_decel](./docs/point_cloud_decel.drawio.svg) - -The deceleration point means the point with low velocity; the value of the velocity $v_{target}$ is determined as follows. - -$v_{target} = v_{min} + \frac{l_{ld} - l_{vw}/2}{l_{er}} (v_{max} - v_{min} )$ - -- $v_{min}$ is minimum target value of `Slow Down Planner` module. The value of $v_{min}$ depends on the parameter `min_slow_down_vel`. -- $v_{max}$ is maximum target value of `Slow Down Planner` module. The value of $v_{max}$ depends on the parameter `max_slow_down_vel`. -- $l_{ld}$ is the lateral deviation of the target pointcloud. -- $l_{vw}$ is the vehicle width. -- $l_{er}$ is the expand range of detection area. The value of $l_{er}$ depends on the parameter `expand_slow_down_range` - -The above method means that the smaller the lateral deviation of the pointcloud, the lower the velocity of the deceleration point. - - - - - -### Adaptive Cruise Controller +## Adaptive Cruise Controller -#### Role +### Role `Adaptive Cruise Controller` module embeds maximum velocity in trajectory when there is a dynamic point cloud on the trajectory. The value of maximum velocity depends on the own velocity, the velocity of the point cloud ( = velocity of the front car), and the distance to the point cloud (= distance to the front car). @@ -241,7 +251,7 @@ The above method means that the smaller the lateral deviation of the pointcloud, | `adaptive_cruise_control.use_rough_velocity_estimation:` | bool | Use rough estimated velocity if the velocity estimation is failed | | `adaptive_cruise_control.rough_velocity_rate` | double | In the rough velocity estimation, the velocity of front car is estimated as self current velocity \* this value | -#### Flowchart +### Flowchart ```plantuml @startuml diff --git a/planning/obstacle_stop_planner/config/obstacle_stop_planner.param.yaml b/planning/obstacle_stop_planner/config/obstacle_stop_planner.param.yaml index 6fe30b216118e..ed4e632ebd6b3 100644 --- a/planning/obstacle_stop_planner/config/obstacle_stop_planner.param.yaml +++ b/planning/obstacle_stop_planner/config/obstacle_stop_planner.param.yaml @@ -1,28 +1,49 @@ /**: ros__parameters: - hunting_threshold: 0.5 # even if the obstacle disappears, the stop judgment continues for hunting_threshold [s] + hunting_threshold: 0.5 # even if the obstacle disappears, the stop judgment continues for hunting_threshold [s] + lowpass_gain: 0.9 # gain parameter for low pass filter [-] + max_velocity: 20.0 # max velocity [m/s] + enable_slow_down: False # whether to use slow down planner [-] stop_planner: - stop_margin: 5.0 # stop margin distance from obstacle on the path [m] - min_behavior_stop_margin: 2.0 # stop margin distance when any other stop point is inserted in stop margin [m] - step_length: 1.0 # step length for pointcloud search range [m] - extend_distance: 0.0 # extend trajectory to consider after goal obstacle in the extend_distance - expand_stop_range: 0.0 # margin of vehicle footprint [m] - hold_stop_margin_distance: 0.0 # the ego keeps stopping if the ego is in this margin [m] + # params for stop position + stop_position: + max_longitudinal_margin: 5.0 # stop margin distance from obstacle on the path [m] + min_longitudinal_margin: 2.0 # stop margin distance when any other stop point is inserted in stop margin [m] + hold_stop_margin_distance: 0.0 # the ego keeps stopping if the ego is in this margin [m] + + # params for detection area + detection_area: + lateral_margin: 0.0 # margin of vehicle footprint [m] + step_length: 1.0 # step length for pointcloud search range [m] + extend_distance: 0.0 # extend trajectory to consider after goal obstacle in the extend_distance [m] + slow_down_planner: - # slow down planner parameters - forward_margin: 5.0 # margin distance from slow down point to vehicle front [m] - backward_margin: 5.0 # margin distance from slow down point to vehicle rear [m] - expand_slow_down_range: 1.0 # offset from vehicle side edge for expanding the search area of the surrounding point cloud [m] - max_slow_down_vel: 1.38 # max slow down velocity [m/s] - min_slow_down_vel: 0.28 # min slow down velocity [m/s] - - # slow down constraint parameters - consider_constraints: False # set "True", if no decel plan found under jerk/dec constrains, relax target slow down vel - forward_margin_min: 1.0 # min margin for relaxing slow down margin [m/s] - forward_margin_span: -0.1 # fineness param for relaxing slow down margin [m/s] - jerk_min_slow_down: -0.3 # min slow down jerk constraint [m/sss] - jerk_span: -0.01 # fineness param for planning deceleration jerk [m/sss] - jerk_start: -0.1 # init jerk used for deceleration planning [m/sss] - slow_down_vel: 1.38 # target slow down velocity [m/s] + # params for slow down section + slow_down_section: + longitudinal_forward_margin: 5.0 # margin distance from slow down point to vehicle front [m] + longitudinal_backward_margin: 5.0 # margin distance from slow down point to vehicle rear [m] + longitudinal_margin_span: -0.1 # fineness param for relaxing slow down margin (use this param if consider_constraints is True) [m/s] + min_longitudinal_forward_margin: 1.0 # min margin for relaxing slow down margin (use this param if consider_constraints is True) [m/s] + + # params for detection area + detection_area: + lateral_margin: 1.0 # offset from vehicle side edge for expanding the search area of the surrounding point cloud [m] + + # params for velocity + target_velocity: + max_slow_down_velocity: 1.38 # max slow down velocity (use this param if consider_constraints is False)[m/s] + min_slow_down_velocity: 0.28 # min slow down velocity (use this param if consider_constraints is False)[m/s] + slow_down_velocity: 1.38 # target slow down velocity (use this param if consider_constraints is True)[m/s] + + # params for deceleration constraints (use this param if consider_constraints is True) + constraints: + jerk_min_slow_down: -0.3 # min slow down jerk constraint [m/sss] + jerk_span: -0.01 # fineness param for planning deceleration jerk [m/sss] + jerk_start: -0.1 # init jerk used for deceleration planning [m/sss] + + # others + consider_constraints: False # set "True", if no decel plan found under jerk/dec constrains, relax target slow down vel [-] + velocity_threshold_decel_complete: 0.2 # use for judge whether the ego velocity converges the target slow down velocity [m/s] + acceleration_threshold_decel_complete: 0.1 # use for judge whether the ego velocity converges the target slow down velocity [m/ss] diff --git a/planning/obstacle_stop_planner/docs/collision_parameters.svg b/planning/obstacle_stop_planner/docs/collision_parameters.svg new file mode 100644 index 0000000000000..a1f3c346bd305 --- /dev/null +++ b/planning/obstacle_stop_planner/docs/collision_parameters.svg @@ -0,0 +1,3 @@ + + +
Obstacle
Obsta...
velocity
veloc...
baselink_to_front [m]
baselink_to_front [m]
max_longitudinal_margin [m]
max_longitudinal_margin [m]
reference velocity
reference velocity
output velocity
output velocity
travel
distance
trave...
trajectory
trajectory
Ego
Ego
lateral_margin [m]
lateral_margin [m]
vehicle_width / 2 + lateral_margin [m]
vehicle_width / 2 + lateral_margin...
detection area for collision obstacles
detection area for collision obstacl...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/insert_decel_velocity.drawio.svg b/planning/obstacle_stop_planner/docs/insert_decel_velocity.drawio.svg deleted file mode 100644 index a49853974a2f9..0000000000000 --- a/planning/obstacle_stop_planner/docs/insert_decel_velocity.drawio.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
Obstacle
Obsta...
velocity
velocity
travel
distance
travel...
baselink to front
baselink to front
slow down forward margin
slow down forward margin
reference velocity
reference velocity
output velocity
output velocity
slow down backward margin
slow down backwa...
baselink to rear
baselink to rear
slow down
velocity
slow down...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/insert_velocity.drawio.svg b/planning/obstacle_stop_planner/docs/insert_velocity.drawio.svg deleted file mode 100644 index bba4ad8a79115..0000000000000 --- a/planning/obstacle_stop_planner/docs/insert_velocity.drawio.svg +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - -
-
-
- -

- - - stop point - - -

-
-
-
-
-
- - stop point - -
-
- - - - - - - - - -
-
-
- -

- - - v - - -

-
-
-
-
-
- - v - -
-
- - - - -
-
-
- -

- - - x - - -

-
-
-
-
-
- - x - -
-
- - - - -
-
-
- -

- - - baselink to front - - -

-
-
-
-
-
- - baselink to front - -
-
- - - - - - - - - - - - -
-
-
- -

- - - output velocity - - -

-
-
-
-
-
- - output velocity - -
-
- - - - - -
-
-
- -

- - - reference velocity - - -

-
-
-
-
-
- - reference velocity - -
-
- - - - - -
-
-
- -

- - stop margin - -

-
-
-
-
-
- - stop margin - -
-
- - - -
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/insert_velocity1.drawio.svg b/planning/obstacle_stop_planner/docs/insert_velocity1.drawio.svg deleted file mode 100644 index dd1054e17fb14..0000000000000 --- a/planning/obstacle_stop_planner/docs/insert_velocity1.drawio.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
Obstacle
Obsta...
velocity
velocity
baselink to front
baselink to front
stop margin
stop margin
reference velocity
reference velocity
output velocity
output velocity
travel
distance
travel...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/insert_velocity2.drawio.svg b/planning/obstacle_stop_planner/docs/insert_velocity2.drawio.svg deleted file mode 100644 index 941668f909b60..0000000000000 --- a/planning/obstacle_stop_planner/docs/insert_velocity2.drawio.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
Obstacle
Obsta...
velocity
velocity
baselink to front
baselink to front
min behavior stop margin
min behavior stop margin
reference velocity
reference velocity
output velocity
output velocity
travel
distance
travel...
stop point
(inserted by other nodes)
stop point...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/min_longitudinal_margin.svg b/planning/obstacle_stop_planner/docs/min_longitudinal_margin.svg new file mode 100644 index 0000000000000..fb42e7f03a641 --- /dev/null +++ b/planning/obstacle_stop_planner/docs/min_longitudinal_margin.svg @@ -0,0 +1,3 @@ + + +
Obstacle
Obsta...
velocity
veloc...
baselink_to_front [m]
baselink_to_front [m]
min_longitudinal_margin [m]
min_longitudinal_margin [m]
reference velocity
reference velocity
output velocity
output velocity
travel
distance
trave...
reference trajectory already has stop point
reference trajectory alrea...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/point_cloud.drawio.svg b/planning/obstacle_stop_planner/docs/point_cloud.drawio.svg deleted file mode 100644 index b7f2e2c5bcf45..0000000000000 --- a/planning/obstacle_stop_planner/docs/point_cloud.drawio.svg +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - - - - - - - - - - - - - - -
-
-
- obstacle point cloud -
-
-
-
- - obstacle point cloud - -
-
- - - - -
-
-
- stop point -
-
-
-
- - stop point - -
-
-
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/point_cloud_decel.drawio.svg b/planning/obstacle_stop_planner/docs/point_cloud_decel.drawio.svg deleted file mode 100644 index e0bd3001607b6..0000000000000 --- a/planning/obstacle_stop_planner/docs/point_cloud_decel.drawio.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - - - - - - - - - - - - - -
-
-
- obstacle point cloud -
-
-
-
- - obstacle point cloud - -
-
- - - - -
-
-
- deceleration point -
-
-
-
- - deceleration point - -
-
- - -
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/slow_down_parameters.svg b/planning/obstacle_stop_planner/docs/slow_down_parameters.svg new file mode 100644 index 0000000000000..dcfcd62fc3a92 --- /dev/null +++ b/planning/obstacle_stop_planner/docs/slow_down_parameters.svg @@ -0,0 +1,3 @@ + + +
trajectory
trajectory
Ego
Ego
lateral_margin [m]
lateral_margin [m]
vehicle_width / 2 + lateral_margin [m]
vehicle_width / 2 + lateral_margin [...
detection area for slow down obstacles
detection area for slow down obstacl...
Obstacle
Obsta...
velocity
veloc...
travel
distance
trave...
longitudinal_forward_margin [m]
longitudinal_forward_margin [m]
reference velocity
reference velocity
output velocity
output velocity
longitudinal_backward_margin [m]
longitudinal_backward_margin [m]
baselink_to_rear [m]
baselink_to_rear [m]
slow_down_velocity [m/s]
slow_down_velocity [m/s]
baselink_to_front [m]
baselink_to_front [m]
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/slow_down_target.svg b/planning/obstacle_stop_planner/docs/slow_down_target.svg new file mode 100644 index 0000000000000..203d703936aa6 --- /dev/null +++ b/planning/obstacle_stop_planner/docs/slow_down_target.svg @@ -0,0 +1,3 @@ + + +
Ego
Ego
detection area for slow down obstacles
detection area for slow down obstacl...
Target
Target
Not-target
(Target for stop planner)
Not-t...
Not-Target
Not-T...
Target
Target
detection area for collision obstacles
detection area for collision obstacl...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/stop_target.svg b/planning/obstacle_stop_planner/docs/stop_target.svg new file mode 100644 index 0000000000000..838321bfd8196 --- /dev/null +++ b/planning/obstacle_stop_planner/docs/stop_target.svg @@ -0,0 +1,3 @@ + + +
Ego
Ego
detection area for collision obstacles
detection area for collision obstacl...
Target
Target
Not-target
Not-t...
Not-Target
Not-T...
Target
Target
Text is not SVG - cannot display
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/vehicle_shape.drawio.svg b/planning/obstacle_stop_planner/docs/vehicle_shape.drawio.svg deleted file mode 100644 index 677e43bed4448..0000000000000 --- a/planning/obstacle_stop_planner/docs/vehicle_shape.drawio.svg +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - - - - - - - - - - - - - - - -
-
-
- Reference Trajectory -
-
-
-
- - Reference Trajectory - -
-
- - - -
-
-
- Detection Area for obstacle stop -
-
-
-
- - Detection Area for obstacle st... - -
-
- - - -
-
-
- Vehicle Shape -
-
-
-
- - Vehicle Shape - -
-
-
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/vehicle_shape_decel.drawio.svg b/planning/obstacle_stop_planner/docs/vehicle_shape_decel.drawio.svg deleted file mode 100644 index 9847751a317e4..0000000000000 --- a/planning/obstacle_stop_planner/docs/vehicle_shape_decel.drawio.svg +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Reference Trajectory -
-
-
-
- - Reference Trajectory - -
-
- - - -
-
-
- (Detection Area for obstacle stop) -
-
-
-
- - (Detection Area for obstacle st... - -
-
- - - -
-
-
- Vehicle Shape -
-
-
-
- - Vehicle Shape - -
-
- - - - -
-
-
- Detection Area for slow down -
-
-
-
- - Detection Area for slow down - -
-
- - - - - - - -
-
-
- expand slow down range -
-
-
-
- - expand slow down range - -
-
-
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/docs/velocity_limitation.drawio.svg b/planning/obstacle_stop_planner/docs/velocity_limitation.drawio.svg deleted file mode 100644 index e63c63d1ee1da..0000000000000 --- a/planning/obstacle_stop_planner/docs/velocity_limitation.drawio.svg +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - - - - - - -
-
-
- -

- - - deceleration point - - -

-
-
-
-
-
- - deceleration point - -
-
- - - - - - - - - -
-
-
- -

- - - v - - -

-
-
-
-
-
- - v - -
-
- - - - -
-
-
- -

- - - x - - -

-
-
-
-
-
- - x - -
-
- - - - -
-
-
- -

- - - baselink to front - - -

-
-
-
-
-
- - baselink to front - -
-
- - - - - - - - - - - -
-
-
- -

- - - output velocity - - -

-
-
-
-
-
- - output velocity - -
-
- - - - - -
-
-
- -

- - - reference velocity - - -

-
-
-
-
-
- - reference velocity - -
-
- - - - - -
-
-
- -

- - stop margin - -

-
-
-
-
-
- - stop margin - -
-
- - - - - - - - -
-
-
- v -
-
-
-
- - v - -
-
- - - -
-
-
- - target - -
-
-
-
- - targ... - -
-
- - - - - -
-
-
- -

- - - velocity limitation - - -

-
-
-
-
-
- - velocity limitation - -
-
- -
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file diff --git a/planning/obstacle_stop_planner/include/obstacle_stop_planner/node.hpp b/planning/obstacle_stop_planner/include/obstacle_stop_planner/node.hpp index 7d63be90db608..1294e6dccd5a1 100644 --- a/planning/obstacle_stop_planner/include/obstacle_stop_planner/node.hpp +++ b/planning/obstacle_stop_planner/include/obstacle_stop_planner/node.hpp @@ -17,6 +17,7 @@ #include "obstacle_stop_planner/adaptive_cruise_control.hpp" #include "obstacle_stop_planner/debug_marker.hpp" +#include "obstacle_stop_planner/planner_data.hpp" #include #include @@ -76,97 +77,11 @@ using tier4_planning_msgs::msg::VelocityLimit; using tier4_planning_msgs::msg::VelocityLimitClearCommand; using vehicle_info_util::VehicleInfo; -struct StopPoint -{ - TrajectoryPoint point{}; - size_t index; -}; - -struct SlowDownSection -{ - TrajectoryPoint start_point{}; - TrajectoryPoint end_point{}; - size_t slow_down_start_idx; - size_t slow_down_end_idx; - double velocity; -}; - class ObstacleStopPlannerNode : public rclcpp::Node { public: explicit ObstacleStopPlannerNode(const rclcpp::NodeOptions & node_options); - struct NodeParam - { - bool enable_slow_down; // set True, slow down for obstacle beside the path - double max_velocity; // max velocity [m/s] - double lowpass_gain; // smoothing calculated current acceleration [-] - double hunting_threshold; // keep slow down or stop state if obstacle vanished [s] - double ego_nearest_dist_threshold; // dist threshold for ego's nearest index - double ego_nearest_yaw_threshold; // yaw threshold for ego's nearest index - }; - - struct StopParam - { - double stop_margin; // stop margin distance from obstacle on the path [m] - double min_behavior_stop_margin; // margin distance, any other stop point is inserted [m] - double expand_stop_range; // margin of vehicle footprint [m] - double extend_distance; // trajectory extend_distance [m] - double step_length; // step length for pointcloud search range [m] - double stop_search_radius; // search radius for obstacle point cloud [m] - double hold_stop_margin_distance; // keep stopping if the ego is in this margin [m] - }; - - struct SlowDownParam - { - double normal_min_jerk; // min jerk limit for mild stop [m/sss] - double normal_min_acc; // min deceleration limit for mild stop [m/ss] - double limit_min_jerk; // min jerk limit [m/sss] - double limit_min_acc; // min deceleration limit [m/ss] - double forward_margin; // slow down margin(vehicle front -> obstacle) [m] - double backward_margin; // slow down margin(obstacle vehicle rear) [m] - double expand_slow_down_range; // lateral range of detection area [m] - double max_slow_down_vel; // maximum speed in slow down section [m/s] - double min_slow_down_vel; // minimum velocity in slow down section [m/s] - bool consider_constraints; // set "True", decel point is planned under jerk/dec constraints - double slow_down_vel; // target slow down velocity [m/s] - double forward_margin_min; // min margin for relaxing slow down margin [m/s] - double forward_margin_span; // fineness param for relaxing slow down margin [m/s] - double slow_down_min_jerk; // min slow down jerk constraint [m/sss] - double jerk_start; // init jerk used for deceleration planning [m/sss] - double jerk_span; // fineness param for planning deceleration jerk [m/sss] - double vel_threshold_reset_velocity_limit_; // velocity threshold, - // check complete deceleration [m/s] - double dec_threshold_reset_velocity_limit_; // acceleration threshold, - // check complete deceleration [m/ss] - double slow_down_search_radius; // search radius for slow down obstacle point cloud [m] - }; - - struct PlannerData - { - diagnostic_msgs::msg::DiagnosticStatus stop_reason_diag{}; - - geometry_msgs::msg::Pose current_pose{}; - - pcl::PointXYZ nearest_collision_point; - pcl::PointXYZ nearest_slow_down_point; - pcl::PointXYZ lateral_nearest_slow_down_point; - rclcpp::Time nearest_collision_point_time{}; - double lateral_deviation{0.0}; - - size_t trajectory_trim_index{}; - size_t decimate_trajectory_collision_index{}; - size_t decimate_trajectory_slow_down_index{}; - std::map decimate_trajectory_index_map{}; // key: decimate index - // value: original index - - bool found_collision_points{false}; - bool found_slow_down_points{false}; - bool stop_require{false}; - bool slow_down_require{false}; - bool enable_adaptive_cruise{false}; - }; - private: /* * ROS diff --git a/planning/obstacle_stop_planner/include/obstacle_stop_planner/planner_data.hpp b/planning/obstacle_stop_planner/include/obstacle_stop_planner/planner_data.hpp new file mode 100644 index 0000000000000..11fcdcdf56828 --- /dev/null +++ b/planning/obstacle_stop_planner/include/obstacle_stop_planner/planner_data.hpp @@ -0,0 +1,247 @@ +// Copyright 2022 TIER IV, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OBSTACLE_STOP_PLANNER__PLANNER_DATA_HPP_ +#define OBSTACLE_STOP_PLANNER__PLANNER_DATA_HPP_ + +#include + +#include + +#include + +namespace motion_planning +{ + +using diagnostic_msgs::msg::DiagnosticStatus; + +struct StopPoint +{ + TrajectoryPoint point{}; + + size_t index; +}; + +struct SlowDownSection +{ + TrajectoryPoint start_point{}; + + TrajectoryPoint end_point{}; + + size_t slow_down_start_idx; + + size_t slow_down_end_idx; + + double velocity; +}; + +struct NodeParam +{ + // set True, slow down for obstacle beside the path + bool enable_slow_down; + + // max velocity [m/s] + double max_velocity; + + // smoothing calculated current acceleration [-] + double lowpass_gain; + + // keep slow down or stop state if obstacle vanished [s] + double hunting_threshold; + + // dist threshold for ego's nearest index + double ego_nearest_dist_threshold; + + // yaw threshold for ego's nearest index + double ego_nearest_yaw_threshold; +}; + +struct StopParam +{ + // ============================== + // params for longitudinal margin + // ============================== + + // margin between obstacle and the ego's front [m] + double max_longitudinal_margin; + + // margin between obstacle and the ego's front [m] + // if any other stop point is inserted within max_longitudinal_margin. + double min_longitudinal_margin; + + // ================================== + // params for obstacle detection area + // ================================== + + // lateral margin between the ego's footprint and + // the boundary of the detection area for collision obstacles [m] + // if any obstacles exist within the detection area, this module plans to stop + // before the obstacle. + double lateral_margin; + + // ================================= + // params for trajectory pre-process + // ================================= + + // trajectory extend distance [m] + double extend_distance; + + // step length for pointcloud search range [m] + double step_length; + + // ====== + // others + // ====== + + // search radius for obstacle point cloud [m] + double stop_search_radius; + + // keep stopping if the ego is in this margin [m] + double hold_stop_margin_distance; +}; + +struct SlowDownParam +{ + // ================= + // params for margin + // ================= + + // margin between obstacle and the ego's front [m] + double longitudinal_forward_margin; + + // margin between obstacle and the ego's rear [m] + double longitudinal_backward_margin; + + // OPTIONAL (use this param if consider_constraints is True) + // minimum distance between obstacle and the ego's front when slow down margin is relaxed [m] + double min_longitudinal_forward_margin; + + // OPTIONAL (use this param if consider_constraints is True) + // fineness param for relaxing slow down margin [m] + double longitudinal_margin_span; + + // ================================== + // params for obstacle detection area + // ================================== + + // lateral margin between the ego's footprint and the boundary of the detection area for slow down + // obstacles [m] + double lateral_margin; + + // =================== + // params for velocity + // =================== + + // OPTIONAL (use this param if consider_constraints is False) + // maximum velocity fow slow down section [m/s] + double max_slow_down_velocity; + + // OPTIONAL (use this param if consider_constraints is False) + // minimum velocity for slow down section [m/s] + double min_slow_down_velocity; + + // OPTIONAL (use this param if consider_constraints is True) + // target slow down velocity [m/s] + double slow_down_velocity; + + // OPTIONAL (use this param if consider_constraints is True) + // velocity threshold whether the vehicle complete deceleration [m/s] + double velocity_threshold_decel_complete; + + // OPTIONAL (use this param if consider_constraints is True) + // acceleration threshold whether the vehicle complete deceleration [m/ss] + double acceleration_threshold_decel_complete; + + // =================================== + // params for deceleration constraints + // =================================== + + // OPTIONAL (use this param if consider_constraints is True) + // min jerk limit for mild stop [m/sss] + double normal_min_jerk; + + // OPTIONAL (use this param if consider_constraints is True) + // min deceleration limit for mild stop [m/ss] + double normal_min_acc; + + // OPTIONAL (use this param if consider_constraints is True) + // min jerk limit [m/sss] + double limit_min_jerk; + + // OPTIONAL (use this param if consider_constraints is True) + // min deceleration limit [m/ss] + double limit_min_acc; + + // OPTIONAL (use this param if consider_constraints is True) + // min slow down jerk constraint [m/sss] + double slow_down_min_jerk; + + // OPTIONAL (use this param if consider_constraints is True) + // init jerk used for deceleration planning [m/sss] + double jerk_start; + + // OPTIONAL (use this param if consider_constraints is True) + // fineness param for planning deceleration jerk [m/sss] + double jerk_span; + + // ====== + // others + // ====== + + // set "True", decel point is planned under jerk/dec constraints + bool consider_constraints; + + // search radius for slow down obstacle point cloud [m] + double slow_down_search_radius; +}; + +struct PlannerData +{ + DiagnosticStatus stop_reason_diag{}; + + geometry_msgs::msg::Pose current_pose{}; + + pcl::PointXYZ nearest_collision_point; + + pcl::PointXYZ nearest_slow_down_point; + + pcl::PointXYZ lateral_nearest_slow_down_point; + + rclcpp::Time nearest_collision_point_time{}; + + double lateral_deviation{0.0}; + + size_t trajectory_trim_index{}; + + size_t decimate_trajectory_collision_index{}; + + size_t decimate_trajectory_slow_down_index{}; + + // key: decimate index, value: original index + std::map decimate_trajectory_index_map{}; + + bool found_collision_points{false}; + + bool found_slow_down_points{false}; + + bool stop_require{false}; + + bool slow_down_require{false}; + + bool enable_adaptive_cruise{false}; +}; + +} // namespace motion_planning + +#endif // OBSTACLE_STOP_PLANNER__PLANNER_DATA_HPP_ diff --git a/planning/obstacle_stop_planner/src/node.cpp b/planning/obstacle_stop_planner/src/node.cpp index f41a97d8ff924..da485a4e52cdf 100644 --- a/planning/obstacle_stop_planner/src/node.cpp +++ b/planning/obstacle_stop_planner/src/node.cpp @@ -233,15 +233,15 @@ boost::optional calcDecelDistWithJerkAndAccConstraints( return {}; } boost::optional> calcFeasibleMarginAndVelocity( - const ObstacleStopPlannerNode::SlowDownParam & slow_down_param, - const double dist_baselink_to_obstacle, const double current_vel, const double current_acc) + const SlowDownParam & slow_down_param, const double dist_baselink_to_obstacle, + const double current_vel, const double current_acc) { const auto & p = slow_down_param; const auto & logger = rclcpp::get_logger("calcFeasibleMarginAndVelocity"); constexpr double epsilon = 1e-4; - if (current_vel < p.slow_down_vel + epsilon) { - return std::make_pair(p.forward_margin, p.slow_down_vel); + if (current_vel < p.slow_down_velocity + epsilon) { + return std::make_pair(p.longitudinal_forward_margin, p.slow_down_velocity); } for (double planning_jerk = p.jerk_start; planning_jerk > p.slow_down_min_jerk - epsilon; @@ -252,17 +252,18 @@ boost::optional> calcFeasibleMarginAndVelocity( const auto planning_dec = planning_jerk > p.normal_min_jerk ? p.limit_min_acc : p.normal_min_acc; const auto stop_dist = calcDecelDistWithJerkAndAccConstraints( - current_vel, p.slow_down_vel, current_acc, planning_dec, jerk_acc, jerk_dec); + current_vel, p.slow_down_velocity, current_acc, planning_dec, jerk_acc, jerk_dec); if (!stop_dist) { continue; } - if (stop_dist.get() + p.forward_margin < dist_baselink_to_obstacle) { + if (stop_dist.get() + p.longitudinal_forward_margin < dist_baselink_to_obstacle) { RCLCPP_DEBUG( logger, "[found plan] dist:%-6.2f jerk:%-6.2f margin:%-6.2f v0:%-6.2f vt:%-6.2f", - stop_dist.get(), planning_jerk, p.forward_margin, p.slow_down_vel, current_vel); - return std::make_pair(p.forward_margin, p.slow_down_vel); + stop_dist.get(), planning_jerk, p.longitudinal_forward_margin, p.slow_down_velocity, + current_vel); + return std::make_pair(p.longitudinal_forward_margin, p.slow_down_velocity); } } @@ -273,18 +274,18 @@ boost::optional> calcFeasibleMarginAndVelocity( const auto planning_dec = p.slow_down_min_jerk > p.normal_min_jerk ? p.limit_min_acc : p.normal_min_acc; const auto stop_dist = calcDecelDistWithJerkAndAccConstraints( - current_vel, p.slow_down_vel, current_acc, planning_dec, jerk_acc, jerk_dec); + current_vel, p.slow_down_velocity, current_acc, planning_dec, jerk_acc, jerk_dec); if (!stop_dist) { return {}; } - if (stop_dist.get() + p.forward_margin_min < dist_baselink_to_obstacle) { + if (stop_dist.get() + p.min_longitudinal_forward_margin < dist_baselink_to_obstacle) { const auto planning_margin = dist_baselink_to_obstacle - stop_dist.get(); RCLCPP_DEBUG( logger, "[relax margin] dist:%-6.2f jerk:%-6.2f margin:%-6.2f v0:%-6.2f vt%-6.2f", - stop_dist.get(), p.slow_down_min_jerk, planning_margin, p.slow_down_vel, current_vel); - return std::make_pair(planning_margin, p.slow_down_vel); + stop_dist.get(), p.slow_down_min_jerk, planning_margin, p.slow_down_velocity, current_vel); + return std::make_pair(planning_margin, p.slow_down_velocity); } } @@ -453,10 +454,10 @@ ObstacleStopPlannerNode::ObstacleStopPlannerNode(const rclcpp::NodeOptions & nod // Parameters { auto & p = node_param_; - p.enable_slow_down = declare_parameter("enable_slow_down", false); - p.max_velocity = declare_parameter("max_velocity", 20.0); - p.hunting_threshold = declare_parameter("hunting_threshold", 0.5); - p.lowpass_gain = declare_parameter("lowpass_gain", 0.9); + p.enable_slow_down = declare_parameter("enable_slow_down"); + p.max_velocity = declare_parameter("max_velocity"); + p.hunting_threshold = declare_parameter("hunting_threshold"); + p.lowpass_gain = declare_parameter("lowpass_gain"); lpf_acc_ = std::make_shared(p.lowpass_gain); p.ego_nearest_dist_threshold = declare_parameter("ego_nearest_dist_threshold"); p.ego_nearest_yaw_threshold = declare_parameter("ego_nearest_yaw_threshold"); @@ -465,51 +466,76 @@ ObstacleStopPlannerNode::ObstacleStopPlannerNode(const rclcpp::NodeOptions & nod { auto & p = stop_param_; const std::string ns = "stop_planner."; - p.stop_margin = declare_parameter(ns + "stop_margin", 5.0); - p.min_behavior_stop_margin = declare_parameter(ns + "min_behavior_stop_margin", 2.0); - p.expand_stop_range = declare_parameter(ns + "expand_stop_range", 0.0); - p.extend_distance = declare_parameter(ns + "extend_distance", 0.0); - p.step_length = declare_parameter(ns + "step_length", 1.0); - p.stop_margin += i.max_longitudinal_offset_m; - p.min_behavior_stop_margin += i.max_longitudinal_offset_m; + + // params for stop position + p.max_longitudinal_margin = + declare_parameter(ns + "stop_position.max_longitudinal_margin"); + p.min_longitudinal_margin = + declare_parameter(ns + "stop_position.min_longitudinal_margin"); + p.hold_stop_margin_distance = + declare_parameter(ns + "stop_position.hold_stop_margin_distance"); + + // params for detection area + p.lateral_margin = declare_parameter(ns + "detection_area.lateral_margin"); + p.extend_distance = declare_parameter(ns + "detection_area.extend_distance"); + p.step_length = declare_parameter(ns + "detection_area.step_length"); + + // apply offset + p.max_longitudinal_margin += i.max_longitudinal_offset_m; + p.min_longitudinal_margin += i.max_longitudinal_offset_m; p.stop_search_radius = p.step_length + - std::hypot(i.vehicle_width_m / 2.0 + p.expand_stop_range, i.vehicle_length_m / 2.0); - p.hold_stop_margin_distance = declare_parameter(ns + "hold_stop_margin_distance", 0.0); + std::hypot(i.vehicle_width_m / 2.0 + p.lateral_margin, i.vehicle_length_m / 2.0); } { auto & p = slow_down_param_; const std::string ns = "slow_down_planner."; + // common param - p.normal_min_jerk = declare_parameter("normal.min_jerk", -0.3); - p.normal_min_acc = declare_parameter("normal.min_acc", -1.0); - p.limit_min_jerk = declare_parameter("limit.min_jerk", -1.5); - p.limit_min_acc = declare_parameter("limit.min_acc", -2.5); - // slow down planner specific parameters - p.forward_margin = declare_parameter(ns + "forward_margin", 5.0); - p.backward_margin = declare_parameter(ns + "backward_margin", 5.0); - p.expand_slow_down_range = declare_parameter(ns + "expand_slow_down_range", 1.0); - p.max_slow_down_vel = declare_parameter(ns + "max_slow_down_vel", 4.0); - p.min_slow_down_vel = declare_parameter(ns + "min_slow_down_vel", 2.0); + p.normal_min_jerk = declare_parameter("normal.min_jerk"); + p.normal_min_acc = declare_parameter("normal.min_acc"); + p.limit_min_jerk = declare_parameter("limit.min_jerk"); + p.limit_min_acc = declare_parameter("limit.min_acc"); + + // params for slow down section + p.longitudinal_forward_margin = + declare_parameter(ns + "slow_down_section.longitudinal_forward_margin"); + p.longitudinal_backward_margin = + declare_parameter(ns + "slow_down_section.longitudinal_backward_margin"); + p.min_longitudinal_forward_margin = + declare_parameter(ns + "slow_down_section.min_longitudinal_forward_margin"); + p.longitudinal_margin_span = + declare_parameter(ns + "slow_down_section.longitudinal_margin_span"); + + // params for detection area + p.lateral_margin = declare_parameter(ns + "detection_area.lateral_margin"); + + // params for target velocity + p.max_slow_down_velocity = + declare_parameter(ns + "target_velocity.max_slow_down_velocity"); + p.min_slow_down_velocity = + declare_parameter(ns + "target_velocity.min_slow_down_velocity"); + p.slow_down_velocity = declare_parameter(ns + "target_velocity.slow_down_velocity"); + // consider jerk/dec constraints in slow down - p.consider_constraints = declare_parameter(ns + "consider_constraints", false); - p.forward_margin_min = declare_parameter(ns + "forward_margin_min", 1.0); - p.forward_margin_span = declare_parameter(ns + "forward_margin_span", -0.1); - p.slow_down_min_jerk = declare_parameter(ns + "jerk_min_slow_down", -0.3); - p.jerk_start = declare_parameter(ns + "jerk_start", -0.1); - p.jerk_span = declare_parameter(ns + "jerk_span", -0.01); - p.slow_down_vel = declare_parameter(ns + "slow_down_vel", 1.39); - p.vel_threshold_reset_velocity_limit_ = - declare_parameter(ns + "vel_threshold_reset_velocity_limit_", 0.2); - p.dec_threshold_reset_velocity_limit_ = - declare_parameter(ns + "dec_threshold_reset_velocity_limit_", 0.1); - p.forward_margin += i.max_longitudinal_offset_m; - p.forward_margin_min += i.wheel_base_m + i.front_overhang_m; - p.backward_margin += i.rear_overhang_m; + p.consider_constraints = declare_parameter(ns + "consider_constraints"); + p.slow_down_min_jerk = declare_parameter(ns + "constraints.jerk_min_slow_down"); + p.jerk_start = declare_parameter(ns + "constraints.jerk_start"); + p.jerk_span = declare_parameter(ns + "constraints.jerk_span"); + + p.velocity_threshold_decel_complete = + declare_parameter(ns + "velocity_threshold_decel_complete"); + p.acceleration_threshold_decel_complete = + declare_parameter(ns + "acceleration_threshold_decel_complete"); + + // apply offset + p.longitudinal_forward_margin += i.max_longitudinal_offset_m; + p.min_longitudinal_forward_margin += i.wheel_base_m + i.front_overhang_m; + p.longitudinal_backward_margin += i.rear_overhang_m; p.slow_down_search_radius = stop_param_.step_length + - std::hypot(i.vehicle_width_m / 2.0 + p.expand_slow_down_range, i.vehicle_length_m / 2.0); + std::hypot(i.vehicle_width_m / 2.0 + p.lateral_margin, i.vehicle_length_m / 2.0); } // Initializer @@ -700,7 +726,7 @@ void ObstacleStopPlannerNode::searchObstacle( // create one step polygon for slow_down range createOneStepPolygon( p_front, p_back, one_step_move_slow_down_range_polygon, vehicle_info, - slow_down_param_.expand_slow_down_range); + slow_down_param_.lateral_margin); debug_ptr_->pushPolygon( one_step_move_slow_down_range_polygon, p_front.position.z, PolygonType::SlowDownRange); @@ -738,7 +764,7 @@ void ObstacleStopPlannerNode::searchObstacle( std::vector one_step_move_vehicle_polygon; // create one step polygon for vehicle createOneStepPolygon( - p_front, p_back, one_step_move_vehicle_polygon, vehicle_info, stop_param.expand_stop_range); + p_front, p_back, one_step_move_vehicle_polygon, vehicle_info, stop_param.lateral_margin); debug_ptr_->pushPolygon( one_step_move_vehicle_polygon, decimate_trajectory.at(i).pose.position.z, PolygonType::Vehicle); @@ -942,8 +968,8 @@ void ObstacleStopPlannerNode::insertVelocity( slow_down_section.start_point = output.front(); slow_down_section.slow_down_end_idx = end_insert_point_with_idx.get().first; slow_down_section.end_point = end_insert_point_with_idx.get().second; - slow_down_section.velocity = - set_velocity_limit_ ? std::numeric_limits::max() : slow_down_param_.slow_down_vel; + slow_down_section.velocity = set_velocity_limit_ ? std::numeric_limits::max() + : slow_down_param_.slow_down_velocity; insertSlowDownSection(slow_down_section, output); } else if (no_hunting_slowdown_point) { @@ -996,10 +1022,10 @@ void ObstacleStopPlannerNode::externalExpandStopRangeCallback( std::lock_guard lock(mutex_); const auto & i = vehicle_info_; - stop_param_.expand_stop_range = input_msg->expand_stop_range; + stop_param_.lateral_margin = input_msg->expand_stop_range; stop_param_.stop_search_radius = stop_param_.step_length + - std::hypot(i.vehicle_width_m / 2.0 + stop_param_.expand_stop_range, i.vehicle_length_m / 2.0); + std::hypot(i.vehicle_width_m / 2.0 + stop_param_.lateral_margin, i.vehicle_length_m / 2.0); } void ObstacleStopPlannerNode::insertStopPoint( @@ -1042,9 +1068,9 @@ StopPoint ObstacleStopPlannerNode::searchInsertPoint( const StopParam & stop_param) { const auto max_dist_stop_point = - createTargetPoint(idx, stop_param.stop_margin, base_trajectory, dist_remain); + createTargetPoint(idx, stop_param.max_longitudinal_margin, base_trajectory, dist_remain); const auto min_dist_stop_point = - createTargetPoint(idx, stop_param.min_behavior_stop_margin, base_trajectory, dist_remain); + createTargetPoint(idx, stop_param.min_longitudinal_margin, base_trajectory, dist_remain); // check if stop point is already inserted by behavior planner bool is_inserted_already_stop_point = false; @@ -1099,7 +1125,7 @@ SlowDownSection ObstacleStopPlannerNode::createSlowDownSection( } const auto no_need_velocity_limit = - dist_baselink_to_obstacle + dist_remain > slow_down_param_.forward_margin; + dist_baselink_to_obstacle + dist_remain > slow_down_param_.longitudinal_forward_margin; if (set_velocity_limit_ && no_need_velocity_limit) { resetExternalVelocityLimit(current_acc, current_vel); } @@ -1107,9 +1133,10 @@ SlowDownSection ObstacleStopPlannerNode::createSlowDownSection( const auto use_velocity_limit = relax_target_vel || set_velocity_limit_; const auto update_forward_margin_from_vehicle = - use_velocity_limit ? slow_down_param_.forward_margin_min - dist_remain + use_velocity_limit ? slow_down_param_.min_longitudinal_forward_margin - dist_remain : margin_with_vel.get().first - dist_remain; - const auto update_backward_margin_from_vehicle = slow_down_param_.backward_margin + dist_remain; + const auto update_backward_margin_from_vehicle = + slow_down_param_.longitudinal_backward_margin + dist_remain; const auto velocity = use_velocity_limit ? std::numeric_limits::max() : margin_with_vel.get().second; @@ -1118,14 +1145,16 @@ SlowDownSection ObstacleStopPlannerNode::createSlowDownSection( idx, base_trajectory, update_forward_margin_from_vehicle, update_backward_margin_from_vehicle, velocity); } else { - const auto update_forward_margin_from_vehicle = slow_down_param_.forward_margin - dist_remain; - const auto update_backward_margin_from_vehicle = slow_down_param_.backward_margin + dist_remain; + const auto update_forward_margin_from_vehicle = + slow_down_param_.longitudinal_forward_margin - dist_remain; + const auto update_backward_margin_from_vehicle = + slow_down_param_.longitudinal_backward_margin + dist_remain; const auto velocity = - slow_down_param_.min_slow_down_vel + - (slow_down_param_.max_slow_down_vel - slow_down_param_.min_slow_down_vel) * + slow_down_param_.min_slow_down_velocity + + (slow_down_param_.max_slow_down_velocity - slow_down_param_.min_slow_down_velocity) * std::max(lateral_deviation - vehicle_info.vehicle_width_m / 2, 0.0) / - slow_down_param_.expand_slow_down_range; + slow_down_param_.lateral_margin; return createSlowDownSectionFromMargin( idx, base_trajectory, update_forward_margin_from_vehicle, update_backward_margin_from_vehicle, @@ -1569,7 +1598,7 @@ void ObstacleStopPlannerNode::setExternalVelocityLimit() const auto & p = slow_down_param_; auto slow_down_limit_vel = std::make_shared(); slow_down_limit_vel->stamp = this->now(); - slow_down_limit_vel->max_velocity = p.slow_down_vel; + slow_down_limit_vel->max_velocity = p.slow_down_velocity; slow_down_limit_vel->constraints.min_acceleration = p.slow_down_min_jerk < p.normal_min_jerk ? p.limit_min_acc : p.normal_min_acc; slow_down_limit_vel->constraints.max_jerk = std::abs(p.slow_down_min_jerk); @@ -1588,11 +1617,10 @@ void ObstacleStopPlannerNode::setExternalVelocityLimit() void ObstacleStopPlannerNode::resetExternalVelocityLimit( const double current_acc, const double current_vel) { - const auto reach_target_vel = - current_vel < - slow_down_param_.slow_down_vel + slow_down_param_.vel_threshold_reset_velocity_limit_; + const auto reach_target_vel = current_vel < slow_down_param_.slow_down_velocity + + slow_down_param_.velocity_threshold_decel_complete; const auto constant_vel = - std::abs(current_acc) < slow_down_param_.dec_threshold_reset_velocity_limit_; + std::abs(current_acc) < slow_down_param_.acceleration_threshold_decel_complete; const auto no_undershoot = reach_target_vel && constant_vel; if (!no_undershoot) {