Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(motion_velocity_planner): add new motion velocity planning #1338

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,56 @@ def launch_setup(context, *args, **kwargs):
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

# motion velocity planner
with open(LaunchConfiguration("motion_velocity_planner_param_path").perform(context), "r") as f:
motion_velocity_planner_param = yaml.safe_load(f)["/**"]["ros__parameters"]
with open(
LaunchConfiguration("motion_velocity_smoother_param_path").perform(context), "r"
) as f:
motion_velocity_smoother_param = yaml.safe_load(f)["/**"]["ros__parameters"]
with open(
LaunchConfiguration("motion_velocity_smoother_type_param_path").perform(context), "r"
) as f:
behavior_velocity_smoother_type_param = yaml.safe_load(f)["/**"]["ros__parameters"]
with open(
LaunchConfiguration("motion_velocity_planner_out_of_lane_module_param_path").perform(
context
),
"r",
) as f:
out_of_lane_param = yaml.safe_load(f)["/**"]["ros__parameters"]
motion_velocity_planner_component = ComposableNode(
package="autoware_motion_velocity_planner_node",
plugin="autoware::motion_velocity_planner::MotionVelocityPlannerNode",
name="motion_velocity_planner",
namespace="",
remappings=[
("~/input/trajectory", "obstacle_avoidance_planner/trajectory"),
("~/input/dynamic_objects", "/perception/object_recognition/objects"),
("~/input/occupancy_grid", "/perception/occupancy_grid_map/map"),
("~/input/vector_map", "/map/vector_map"),
("~/output/trajectory", "motion_velocity_planner/trajectory"),
("~/input/vehicle_odometry", "/localization/kinematic_state"),
("~/input/accel", "/localization/acceleration"),
("~/input/no_ground_pointcloud", "/perception/obstacle_segmentation/pointcloud"),
("~/input/traffic_signals", "/perception/traffic_light_recognition/traffic_signals"),
("~/input/virtual_traffic_light_states", "/perception/virtual_traffic_light_states"),
("~/input/occupancy_grid", "/perception/occupancy_grid_map/map"),
("~/output/stop_reasons", "/planning/scenario_planning/status/stop_reasons"),
("~/output/velocity_factors", "/planning/velocity_factors/motion_velocity_planner"),
],
parameters=[
motion_velocity_planner_param,
vehicle_info_param,
nearest_search_param,
common_param,
motion_velocity_smoother_param,
behavior_velocity_smoother_type_param,
out_of_lane_param,
],
extra_arguments=[{"use_intra_process_comms": LaunchConfiguration("use_intra_process")}],
)

# surround obstacle checker
with open(
LaunchConfiguration("surround_obstacle_checker_param_path").perform(context), "r"
Expand Down Expand Up @@ -206,7 +256,7 @@ def launch_setup(context, *args, **kwargs):
),
("~/input/objects", "/perception/object_recognition/objects"),
("~/input/odometry", "/localization/kinematic_state"),
("~/input/trajectory", "obstacle_velocity_limiter/trajectory"),
("~/input/trajectory", "motion_velocity_planner/trajectory"),
],
parameters=[
nearest_search_param,
Expand All @@ -227,7 +277,7 @@ def launch_setup(context, *args, **kwargs):
name="obstacle_cruise_planner",
namespace="",
remappings=[
("~/input/trajectory", "obstacle_velocity_limiter/trajectory"),
("~/input/trajectory", "motion_velocity_planner/trajectory"),
("~/input/odometry", "/localization/kinematic_state"),
("~/input/acceleration", "/localization/acceleration"),
("~/input/objects", "/perception/object_recognition/objects"),
Expand All @@ -250,7 +300,7 @@ def launch_setup(context, *args, **kwargs):
name="obstacle_cruise_planner_relay",
namespace="",
parameters=[
{"input_topic": "obstacle_velocity_limiter/trajectory"},
{"input_topic": "motion_velocity_planner/trajectory"},
{"output_topic": "/planning/scenario_planning/lane_driving/trajectory"},
{"type": "autoware_auto_planning_msgs/msg/Trajectory"},
],
Expand All @@ -263,6 +313,7 @@ def launch_setup(context, *args, **kwargs):
package="rclcpp_components",
executable=LaunchConfiguration("container_executable"),
composable_node_descriptions=[
motion_velocity_planner_component,
obstacle_velocity_limiter_component,
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@

<arg name="input_path_topic" default="/planning/scenario_planning/lane_driving/behavior_planning/path"/>
<arg name="use_surround_obstacle_check" default="true"/>
<arg name="launch_motion_out_of_lane_module" default="true"/>
<arg name="launch_module_list_end" default="&quot;&quot;]"/>

<!-- assemble launch config for motion velocity planner -->
<arg name="motion_velocity_planner_launch_modules" default="["/>
<let
name="motion_velocity_planner_launch_modules"
value="$(eval &quot;'$(var motion_velocity_planner_launch_modules)' + 'autoware::motion_velocity_planner::OutOfLaneModule, '&quot;)"
if="$(var launch_motion_out_of_lane_module)"
/>
<let
name="motion_velocity_planner_launch_modules"
value="$(eval &quot;'$(var motion_velocity_planner_launch_modules)' + 'motion_velocity_planner::DynamicObstacleStopModule, '&quot;)"
if="$(var launch_dynamic_obstacle_stop_module)"
/>
<let name="motion_velocity_planner_launch_modules" value="$(eval &quot;'$(var motion_velocity_planner_launch_modules)' + '$(var launch_module_list_end)'&quot;)"/>

<!-- path planning for avoiding obstacle with dynamic object info -->
<group>
Expand Down Expand Up @@ -39,4 +55,36 @@
<arg name="output_trajectory" value="/planning/scenario_planning/lane_driving/trajectory"/>
</include>
</group>
<!-- plan slowdown or stops on the final trajectory -->
<group>
<load_composable_node target="/planning/scenario_planning/lane_driving/motion_planning/motion_planning_container">
<composable_node pkg="autoware_motion_velocity_planner_node" plugin="autoware::motion_velocity_planner::MotionVelocityPlannerNode" name="motion_velocity_planner" namespace="">
<!-- topic remap -->
<remap from="~/input/trajectory" to="obstacle_avoidance_planner/trajectory"/>
<remap from="~/input/vector_map" to="/map/vector_map"/>
<remap from="~/input/vehicle_odometry" to="/localization/kinematic_state"/>
<remap from="~/input/accel" to="/localization/acceleration"/>
<remap from="~/input/dynamic_objects" to="/perception/object_recognition/objects"/>
<remap from="~/input/no_ground_pointcloud" to="/perception/obstacle_segmentation/pointcloud"/>
<remap from="~/input/traffic_signals" to="/perception/traffic_light_recognition/traffic_signals"/>
<remap from="~/input/virtual_traffic_light_states" to="/perception/virtual_traffic_light_states"/>
<remap from="~/input/occupancy_grid" to="/perception/occupancy_grid_map/map"/>
<remap from="~/output/trajectory" to="motion_velocity_planner/trajectory"/>
<remap from="~/output/stop_reasons" to="/planning/scenario_planning/status/stop_reasons"/>
<remap from="~/output/velocity_factors" to="/planning/velocity_factors/motion_velocity_planner"/>
<!-- params -->
<param name="launch_modules" value="$(var motion_velocity_planner_launch_modules)"/>
<param from="$(var common_param_path)"/>
<param from="$(var vehicle_param_file)"/>
<param from="$(var nearest_search_param_path)"/>
<param from="$(var motion_velocity_smoother_param_path)"/>
<param from="$(var motion_velocity_smoother_type_param_path)"/>
<param from="$(var motion_velocity_planner_param_path)"/>
<param from="$(var motion_velocity_planner_out_of_lane_module_param_path)"/>
<!-- <param from="$(var motion_velocity_planner_template_param_path)"/> -->
<!-- composable node config -->
<extra_arg name="use_intra_process_comms" value="false"/>
</composable_node>
</load_composable_node>
</group>
</launch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.14)
project(autoware_motion_velocity_out_of_lane_module)

find_package(autoware_cmake REQUIRED)
autoware_package()
pluginlib_export_plugin_description_file(autoware_motion_velocity_planner_node plugins.xml)

ament_auto_add_library(${PROJECT_NAME} SHARED
DIRECTORY src
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(INSTALL_TO_SHARE config)
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
## Out of Lane

### Role

`out_of_lane` is the module that decelerates and stops to prevent the ego vehicle from entering another lane with incoming dynamic objects.

### Activation Timing

This module is activated if `launch_out_of_lane` is set to true.

### Inner-workings / Algorithms

The algorithm is made of the following steps.

1. Calculate the ego path footprints (red).
2. Calculate the other lanes (magenta).
3. Calculate the overlapping ranges between the ego path footprints and the other lanes (green).
4. For each overlapping range, decide if a stop or slow down action must be taken.
5. For each action, insert the corresponding stop or slow down point in the path.

![overview](./docs/out_of_lane-footprints_other_lanes_overlaps_ranges.png)

#### 1. Ego Path Footprints

In this first step, the ego footprint is projected at each path point and are eventually inflated based on the `extra_..._offset` parameters.

#### 2. Other lanes

In the second step, the set of lanes to consider for overlaps is generated.
This set is built by selecting all lanelets within some distance from the ego vehicle, and then removing non-relevant lanelets.
The selection distance is chosen as the maximum between the `slowdown.distance_threshold` and the `stop.distance_threshold`.

A lanelet is deemed non-relevant if it meets one of the following conditions.

- It is part of the lanelets followed by the ego path.
- It contains the rear point of the ego footprint.
- It follows one of the ego path lanelets.

#### 3. Overlapping ranges

In the third step, overlaps between the ego path footprints and the other lanes are calculated.
For each pair of other lane $l$ and ego path footprint $f$, we calculate the overlapping polygons using `boost::geometry::intersection`.
For each overlapping polygon found, if the distance inside the other lane $l$ is above the `overlap.minimum_distance` threshold, then the overlap is ignored.
Otherwise, the arc length range (relative to the ego path) and corresponding points of the overlapping polygons are stored.
Ultimately, for each other lane $l$, overlapping ranges of successive overlaps are built with the following information:

- overlapped other lane $l$.
- start and end ego path indexes.
- start and end ego path arc lengths.
- start and end overlap points.

#### 4. Decisions

In the fourth step, a decision to either slow down or stop before each overlapping range is taken based on the dynamic objects.
The conditions for the decision depend on the value of the `mode` parameter.

Whether it is decided to slow down or stop is determined by the distance between the ego vehicle and the start of the overlapping range (in arc length along the ego path).
If this distance is bellow the `actions.slowdown.threshold`, a velocity of `actions.slowdown.velocity` will be used.
If the distance is bellow the `actions.stop.threshold`, a velocity of `0`m/s will be used.

<table width="100%">
<tr>
<td>
<img src="./docs/out_of_lane_slow.png" width="550px"/>
</td>
<td>
<img src="./docs/out_of_lane_stop.png" width="550px"/>
</td>
</tr>
</table>

##### Threshold

With the `mode` set to `"threshold"`,
a decision to stop or slow down before a range is made if
an incoming dynamic object is estimated to reach the overlap within `threshold.time_threshold`.

##### TTC (time to collision)

With the `mode` set to `"ttc"`,
estimates for the times when ego and the dynamic objects reach the start and end of the overlapping range are calculated.
This is then used to calculate the time to collision over the period where ego crosses the overlap.
If the time to collision is predicted to go bellow the `ttc.threshold`, the decision to stop or slow down is made.

##### Intervals

With the `mode` set to `"intervals"`,
the estimated times when ego and the dynamic objects reach the start and end points of
the overlapping range are used to create time intervals.
These intervals can be made shorter or longer using the
`intervals.ego_time_buffer` and `intervals.objects_time_buffer` parameters.
If the time interval of ego overlaps with the time interval of an object, the decision to stop or slow down is made.

##### Time estimates

###### Ego

To estimate the times when ego will reach an overlap, it is assumed that ego travels along its path
at its current velocity or at half the velocity of the path points, whichever is higher.

###### Dynamic objects

Two methods are used to estimate the time when a dynamic objects with reach some point.
If `objects.use_predicted_paths` is set to `true`, the predicted paths of the dynamic object are used if their confidence value is higher than the value set by the `objects.predicted_path_min_confidence` parameter.
Otherwise, the lanelet map is used to estimate the distance between the object and the point and the time is calculated assuming the object keeps its current velocity.

#### 5. Path update

Finally, for each decision to stop or slow down before an overlapping range,
a point is inserted in the path.
For a decision taken for an overlapping range with a lane $l$ starting at ego path point index $i$,
a point is inserted in the path between index $i$ and $i-1$ such that the ego footprint projected at the inserted point does not overlap $l$.
Such point with no overlap must exist since, by definition of the overlapping range,
we know that there is no overlap at $i-1$.

If the point would cause a higher deceleration than allowed by the `max_accel` parameter (node parameter),
it is skipped.

Moreover, parameter `action.distance_buffer` adds an extra distance between the ego footprint and the overlap when possible.

### Module Parameters

| Parameter | Type | Description |
| ----------------------------- | ------ | --------------------------------------------------------------------------------- |
| `mode` | string | [-] mode used to consider a dynamic object. Candidates: threshold, intervals, ttc |
| `skip_if_already_overlapping` | bool | [-] if true, do not run this module when ego already overlaps another lane |

| Parameter /threshold | Type | Description |
| -------------------- | ------ | ---------------------------------------------------------------- |
| `time_threshold` | double | [s] consider objects that will reach an overlap within this time |

| Parameter /intervals | Type | Description |
| --------------------- | ------ | ------------------------------------------------------- |
| `ego_time_buffer` | double | [s] extend the ego time interval by this buffer |
| `objects_time_buffer` | double | [s] extend the time intervals of objects by this buffer |

| Parameter /ttc | Type | Description |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| `threshold` | double | [s] consider objects with an estimated time to collision bellow this value while ego is on the overlap |

| Parameter /objects | Type | Description |
| ------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `minimum_velocity` | double | [m/s] ignore objects with a velocity lower than this value |
| `predicted_path_min_confidence` | double | [-] minimum confidence required for a predicted path to be considered |
| `use_predicted_paths` | bool | [-] if true, use the predicted paths to estimate future positions; if false, assume the object moves at constant velocity along _all_ lanelets it currently is located in |

| Parameter /overlap | Type | Description |
| ------------------ | ------ | ---------------------------------------------------------------------------------------------------- |
| `minimum_distance` | double | [m] minimum distance inside a lanelet for an overlap to be considered |
| `extra_length` | double | [m] extra arc length to add to the front and back of an overlap (used to calculate enter/exit times) |

| Parameter /action | Type | Description |
| ----------------------------- | ------ | ---------------------------------------------------------------------------------------------- |
| `skip_if_over_max_decel` | bool | [-] if true, do not take an action that would cause more deceleration than the maximum allowed |
| `distance_buffer` | double | [m] buffer distance to try to keep between the ego footprint and lane |
| `slowdown.distance_threshold` | double | [m] insert a slow down when closer than this distance from an overlap |
| `slowdown.velocity` | double | [m] slow down velocity |
| `stop.distance_threshold` | double | [m] insert a stop when closer than this distance from an overlap |

| Parameter /ego | Type | Description |
| -------------------- | ------ | ---------------------------------------------------- |
| `extra_front_offset` | double | [m] extra front distance to add to the ego footprint |
| `extra_rear_offset` | double | [m] extra rear distance to add to the ego footprint |
| `extra_left_offset` | double | [m] extra left distance to add to the ego footprint |
| `extra_right_offset` | double | [m] extra right distance to add to the ego footprint |
Loading
Loading