Skip to content

Commit 52a94ff

Browse files
authored
Merge branch 'main' into chore/ndt_scan_matcher/rename_config_path
2 parents b8e779d + b396413 commit 52a94ff

File tree

28 files changed

+2000
-10
lines changed

28 files changed

+2000
-10
lines changed

launch/tier4_planning_launch/launch/scenario_planning/lane_driving/behavior_planning/behavior_planning.launch.xml

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<arg name="launch_external_request_lane_change_left_module" default="true"/>
1616
<arg name="launch_goal_planner_module" default="true"/>
1717
<arg name="launch_start_planner_module" default="true"/>
18+
<arg name="launch_sampling_planner_module" default="true"/>
1819
<arg name="launch_side_shift_module" default="true"/>
1920

2021
<arg name="launch_crosswalk_module" default="true"/>
@@ -58,6 +59,11 @@
5859
value="$(eval &quot;'$(var behavior_path_planner_launch_modules)' + 'behavior_path_planner::StartPlannerModuleManager, '&quot;)"
5960
if="$(var launch_start_planner_module)"
6061
/>
62+
<let
63+
name="behavior_path_planner_launch_modules"
64+
value="$(eval &quot;'$(var behavior_path_planner_launch_modules)' + 'behavior_path_planner::SamplingPlannerModuleManager, '&quot;)"
65+
if="$(var launch_sampling_planner_module)"
66+
/>
6167
<let
6268
name="behavior_path_planner_launch_modules"
6369
value="$(eval &quot;'$(var behavior_path_planner_launch_modules)' + 'behavior_path_planner::GoalPlannerModuleManager, '&quot;)"
@@ -204,6 +210,7 @@
204210
<param from="$(var behavior_path_planner_lane_change_module_param_path)"/>
205211
<param from="$(var behavior_path_planner_goal_planner_module_param_path)"/>
206212
<param from="$(var behavior_path_planner_start_planner_module_param_path)"/>
213+
<param from="$(var behavior_path_planner_sampling_planner_module_param_path)"/>
207214
<param from="$(var behavior_path_planner_drivable_area_expansion_param_path)"/>
208215
<param from="$(var behavior_path_planner_scene_module_manager_param_path)"/>
209216
<param from="$(var behavior_path_planner_common_param_path)"/>

map/map_height_fitter/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ ament_auto_add_executable(node
1414
src/node.cpp
1515
)
1616

17-
ament_auto_package(INSTALL_TO_SHARE launch)
17+
ament_auto_package(
18+
INSTALL_TO_SHARE
19+
launch
20+
config)

map/map_height_fitter/README.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ This library fits the given point with the ground of the point cloud map.
44
The map loading operation is switched by the parameter `enable_partial_load` of the node specified by `map_loader_name`.
55
The node using this library must use multi thread executor.
66

7-
| Interface | Local Name | Description |
8-
| ------------ | ------------------ | ---------------------------------------- |
9-
| Parameter | map_loader_name | The point cloud map loader name. |
10-
| Subscription | ~/pointcloud_map | The topic name to load the whole map |
11-
| Client | ~/partial_map_load | The service name to load the partial map |
7+
## Parameters
8+
9+
{{ json_to_markdown("map/map_height_fitter/schema/map_height_fitter.schema.json") }}
10+
11+
## Topic subscription
12+
13+
| Topic Name | Description |
14+
| ---------------- | -------------------------------------------------------------------------------------------- |
15+
| ~/pointcloud_map | The topic containing the whole pointcloud map (only used when `enable_partial_load = false`) |
16+
17+
## Service client
18+
19+
| Service Name | Description |
20+
| ------------------ | ----------------------------------- |
21+
| ~/partial_map_load | The service to load the partial map |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**:
2+
ros__parameters:
3+
map_loader_name: "/map/pointcloud_map_loader"

map/map_height_fitter/launch/map_height_fitter.launch.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<launch>
2+
<arg name="param_path" default="$(find-pkg-share map_height_fitter)/config/map_height_fitter.param.yaml"/>
3+
24
<group>
35
<push-ros-namespace namespace="map"/>
46
<node pkg="map_height_fitter" exec="node" name="map_height_fitter">
5-
<param name="map_loader_name" value="/map/pointcloud_map_loader"/>
7+
<param from="$(var param_path)"/>
68
<remap from="~/pointcloud_map" to="/map/pointcloud_map"/>
79
<remap from="~/partial_map_load" to="/map/get_partial_pointcloud_map"/>
810
</node>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Parameters for map_height_fitter",
4+
"type": "object",
5+
"definitions": {
6+
"map_height_fitter": {
7+
"type": "object",
8+
"properties": {
9+
"map_loader_name": {
10+
"type": "string",
11+
"description": "Node name of the map loader from which this map_height_fitter will retrieve its parameters",
12+
"default": "/map/pointcloud_map_loader"
13+
}
14+
},
15+
"required": ["map_loader_name"],
16+
"additionalProperties": false
17+
}
18+
},
19+
"properties": {
20+
"/**": {
21+
"type": "object",
22+
"properties": {
23+
"ros__parameters": {
24+
"$ref": "#/definitions/map_height_fitter"
25+
}
26+
},
27+
"required": ["ros__parameters"],
28+
"additionalProperties": false
29+
}
30+
},
31+
"required": ["/**"],
32+
"additionalProperties": false
33+
}

planning/behavior_path_goal_planner_module/include/behavior_path_goal_planner_module/goal_planner_module.hpp

+44
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <autoware_auto_planning_msgs/msg/path_with_lane_id.hpp>
3838
#include <autoware_auto_vehicle_msgs/msg/hazard_lights_command.hpp>
3939

40+
#include <atomic>
4041
#include <deque>
4142
#include <limits>
4243
#include <memory>
@@ -290,6 +291,35 @@ class GoalPlannerModule : public SceneModuleInterface
290291
std::unordered_map<std::string, std::shared_ptr<ObjectsOfInterestMarkerInterface>> &
291292
objects_of_interest_marker_interface_ptr_map);
292293

294+
~GoalPlannerModule()
295+
{
296+
if (lane_parking_timer_) {
297+
lane_parking_timer_->cancel();
298+
}
299+
if (freespace_parking_timer_) {
300+
freespace_parking_timer_->cancel();
301+
}
302+
303+
while (is_lane_parking_cb_running_.load() || is_freespace_parking_cb_running_.load()) {
304+
const std::string running_callbacks = std::invoke([&]() {
305+
if (is_lane_parking_cb_running_ && is_freespace_parking_cb_running_) {
306+
return "lane parking and freespace parking";
307+
}
308+
if (is_lane_parking_cb_running_) {
309+
return "lane parking";
310+
}
311+
return "freespace parking";
312+
});
313+
RCLCPP_INFO_THROTTLE(
314+
getLogger(), *clock_, 1000, "Waiting for %s callback to finish...",
315+
running_callbacks.c_str());
316+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
317+
}
318+
319+
RCLCPP_INFO_THROTTLE(
320+
getLogger(), *clock_, 1000, "lane parking and freespace parking callbacks finished");
321+
}
322+
293323
void updateModuleParams(const std::any & parameters) override
294324
{
295325
parameters_ = std::any_cast<std::shared_ptr<GoalPlannerParameters>>(parameters);
@@ -330,6 +360,18 @@ class GoalPlannerModule : public SceneModuleInterface
330360
CandidateOutput planCandidate() const override { return CandidateOutput{}; }
331361

332362
private:
363+
// Flag class for managing whether a certain callback is running in multi-threading
364+
class ScopedFlag
365+
{
366+
public:
367+
explicit ScopedFlag(std::atomic<bool> & flag) : flag_(flag) { flag_.store(true); }
368+
369+
~ScopedFlag() { flag_.store(false); }
370+
371+
private:
372+
std::atomic<bool> & flag_;
373+
};
374+
333375
/*
334376
* state transitions and plan function used in each state
335377
*
@@ -403,10 +445,12 @@ class GoalPlannerModule : public SceneModuleInterface
403445
// pre-generate lane parking paths in a separate thread
404446
rclcpp::TimerBase::SharedPtr lane_parking_timer_;
405447
rclcpp::CallbackGroup::SharedPtr lane_parking_timer_cb_group_;
448+
std::atomic<bool> is_lane_parking_cb_running_;
406449

407450
// generate freespace parking paths in a separate thread
408451
rclcpp::TimerBase::SharedPtr freespace_parking_timer_;
409452
rclcpp::CallbackGroup::SharedPtr freespace_parking_timer_cb_group_;
453+
std::atomic<bool> is_freespace_parking_cb_running_;
410454

411455
// debug
412456
mutable GoalPlannerDebugData debug_data_;

planning/behavior_path_goal_planner_module/src/goal_planner_module.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ GoalPlannerModule::GoalPlannerModule(
6262
parameters_{parameters},
6363
vehicle_info_{vehicle_info_util::VehicleInfoUtil(node).getVehicleInfo()},
6464
thread_safe_data_{mutex_, clock_},
65+
is_lane_parking_cb_running_{false},
66+
is_freespace_parking_cb_running_{false},
6567
debug_stop_pose_with_info_{&stop_pose_}
6668
{
6769
LaneDepartureChecker lane_departure_checker{};
@@ -171,6 +173,8 @@ bool GoalPlannerModule::hasDeviatedFromCurrentPreviousModulePath() const
171173
// generate pull over candidate paths
172174
void GoalPlannerModule::onTimer()
173175
{
176+
const ScopedFlag flag(is_lane_parking_cb_running_);
177+
174178
if (getCurrentStatus() == ModuleStatus::IDLE) {
175179
return;
176180
}
@@ -287,6 +291,8 @@ void GoalPlannerModule::onTimer()
287291

288292
void GoalPlannerModule::onFreespaceParkingTimer()
289293
{
294+
const ScopedFlag flag(is_freespace_parking_cb_running_);
295+
290296
if (getCurrentStatus() == ModuleStatus::IDLE) {
291297
return;
292298
}

planning/behavior_path_planner/config/scene_module_manager.param.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,12 @@
8282
keep_last: false
8383
priority: 7
8484
max_module_size: 1
85+
86+
sampling_planner:
87+
enable_module: true
88+
enable_rtc: false
89+
enable_simultaneous_execution_as_approved_module: false
90+
enable_simultaneous_execution_as_candidate_module: false
91+
keep_last: true
92+
priority: 16
93+
max_module_size: 1

planning/behavior_path_planner/launch/behavior_path_planner.launch.xml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<arg name="behavior_path_planner_lane_change_module_param_path"/>
2020
<arg name="behavior_path_planner_goal_planner_module_param_path"/>
2121
<arg name="behavior_path_planner_start_planner_module_param_path"/>
22+
<arg name="behavior_path_planner_sampling_planner_module_param_path"/>
2223
<arg name="behavior_path_planner_drivable_area_expansion_param_path"/>
2324

2425
<node pkg="behavior_path_planner" exec="behavior_path_planner" name="behavior_path_planner" output="screen">
@@ -49,6 +50,7 @@
4950
<param from="$(var behavior_path_planner_avoidance_module_param_path)"/>
5051
<param from="$(var behavior_path_planner_avoidance_by_lc_module_param_path)"/>
5152
<param from="$(var behavior_path_planner_dynamic_avoidance_module_param_path)"/>
53+
<param from="$(var behavior_path_planner_sampling_planner_module_param_path)"/>
5254
<param from="$(var behavior_path_planner_lane_change_module_param_path)"/>
5355
<param from="$(var behavior_path_planner_goal_planner_module_param_path)"/>
5456
<param from="$(var behavior_path_planner_start_planner_module_param_path)"/>

planning/behavior_path_planner/package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<depend>autoware_perception_msgs</depend>
4444
<depend>behavior_path_planner_common</depend>
4545
<depend>freespace_planning_algorithms</depend>
46+
<depend>frenet_planner</depend>
4647
<depend>geometry_msgs</depend>
4748
<depend>interpolation</depend>
4849
<depend>lane_departure_checker</depend>
@@ -52,6 +53,7 @@
5253
<depend>magic_enum</depend>
5354
<depend>motion_utils</depend>
5455
<depend>object_recognition_utils</depend>
56+
<depend>path_sampler</depend>
5557
<depend>planning_test_utils</depend>
5658
<depend>pluginlib</depend>
5759
<depend>rclcpp</depend>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(behavior_path_sampling_planner_module)
3+
4+
find_package(autoware_cmake REQUIRED)
5+
autoware_package()
6+
pluginlib_export_plugin_description_file(behavior_path_planner plugins.xml)
7+
8+
ament_auto_add_library(${PROJECT_NAME} SHARED
9+
src/sampling_planner_module.cpp
10+
src/manager.cpp
11+
)
12+
13+
ament_auto_package(INSTALL_TO_SHARE config)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Behavior Path Sampling Based Planner
2+
3+
WARNING: This module is experimental and has not been properly tested on a real vehicle, use only on simulations.
4+
5+
## Purpose
6+
7+
This package implements a node that uses sampling based planning to generate a drivable trajectory for the behavior path planner. It is heavily based off the [sampling_based_planner module](https://github.com/autowarefoundation/autoware.universe/tree/main/planning/sampling_based_planner).
8+
9+
## Features
10+
11+
This package is able to:
12+
13+
- create a smooth trajectory to avoid static obstacles.
14+
- guarantees the generated trajectory (if any) complies with customizable hard constraints.
15+
- transitions to a success state after the ego vehicle merges to its goal lane.
16+
- re-use previously generated outputs to re-sample new alternative paths
17+
18+
Note that the velocity is just taken over from the input path.
19+
20+
## Algorithm
21+
22+
Sampling based planning is decomposed into 3 successive steps:
23+
24+
1. Sampling: candidate trajectories are generated.
25+
2. Pruning: invalid candidates are discarded.
26+
3. Selection: the best remaining valid candidate is selected.
27+
28+
### Sampling
29+
30+
Candidate trajectories are generated based on the current ego state and some target state.
31+
1 sampling algorithms is currently implemented: polynomials in the frenet frame.
32+
33+
### Pruning
34+
35+
The validity of each candidate trajectory is checked using a set of hard constraints.
36+
37+
- collision: ensure no collision with static obstacles;
38+
- curvature: ensure smooth curvature;
39+
- drivable area: ensure the trajectory stays within the drivable area.
40+
41+
### Selection
42+
43+
Among the valid candidate trajectories, the _best_ one is determined using a set of soft constraints (i.e., objective functions).
44+
45+
- curvature: prefer smoother trajectories;
46+
- length: prefer trajectories with longer remaining path length;
47+
- lateral deviation: prefer trajectories close to the goal.
48+
49+
Each soft constraint is associated with a weight to allow tuning of the preferences.
50+
51+
## Limitations
52+
53+
The quality of the candidates generated with polynomials in frenet frame greatly depend on the reference path.
54+
If the reference path is not smooth, the resulting candidates will probably be un-drivable.
55+
56+
Failure to find a valid trajectory current results in a suddenly stopping trajectory.
57+
58+
The module has troubles generating paths that converge rapidly to the goal lanelet. Basically, after overcoming all obstacles, the module should prioritize paths that rapidly make the ego vehicle converge back to its goal lane (ie. paths with low average and final lateral deviation). However, this does not function properly at the moment.
59+
60+
Detection of proper merging can be rough: Sometimes, the module when detects that the ego has converged on the goal lanelet and that there are no more obstacles, the planner transitions to the goal planner, but the transition is not very smooth and could cause discomfort for the user.
61+
62+
## Future works
63+
64+
Some possible improvements for this module include:
65+
66+
-Implementing a dynamic weight tuning algorithm: Dynamically change weights depending on the scenario (ie. to prioritize more the paths with low curvature and low avg. lat. deviation after all obstacles have been avoided).
67+
68+
-Implementing multi-objective optimization to improve computing time and possibly make a more dynamic soft constraints weight tuning. [Related publication](https://ieeexplore.ieee.org/abstract/document/10180226).
69+
70+
-Implement bezier curves as another method to obtain samples, see the [sampling_based_planner module](https://github.com/autowarefoundation/autoware.universe/tree/main/planning/sampling_based_planner).
71+
72+
-Explore the possibility to replace several or other behavior path modules with the sampling based behavior path module.
73+
74+
-Perform real-life tests of this module once it has matured and some of its limitations have been solved.
75+
76+
## Other possibilities
77+
78+
The module is currently aimed at creating paths for static obstacle avoidance. However, the nature of sampling planner allows this module to be expanded or repurposed to other tasks such as lane changes, dynamic avoidance and general reaching of a goal. It is possible, with a good dynamic/scenario dependant weight tuning to use the sampling planning approach as a replacement for the other behavior path modules, assuming good candidate pruning and good soft constraints weight tuning.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**:
2+
ros__parameters:
3+
start_planner:
4+
max_curvature: 0.1
5+
min_curvature: -0.1
6+
lateral_deviation_weight: 1.0
7+
length_weight: 1.0
8+
curvature_weight: 1.0
9+
enable_frenet: true
10+
enable_bezier: false
11+
resolution: 0.5
12+
previous_path_reuse_points_nb: 2
13+
nb_target_lateral_positions: {10.0, 20.0}
14+
target_lengths: {-2.0, -1.0, 0.0, 1.0, 2.0}
15+
target_lateral_positions: 2
16+
target_lateral_velocities: {-0.1, 0.0, 0.1}
17+
target_lateral_accelerations: {0.0}
18+
force_zero_deviation: true
19+
force_zero_heading: true
20+
smooth_reference: false

0 commit comments

Comments
 (0)