Skip to content

Commit

Permalink
refactor(dynamic_avoidance): separate dynamic avoidance module (autow…
Browse files Browse the repository at this point in the history
…arefoundation#6019)

* refactor(dynamic_avoidance): separate dynamic avoidance module

Signed-off-by: Takayuki Murooka <[email protected]>

* move figures

Signed-off-by: Takayuki Murooka <[email protected]>

* update .pages

Signed-off-by: Takayuki Murooka <[email protected]>

---------

Signed-off-by: Takayuki Murooka <[email protected]>
  • Loading branch information
takayuki5168 authored and karishma1911 committed May 26, 2024
1 parent 9026df7 commit c6c8e53
Show file tree
Hide file tree
Showing 17 changed files with 211 additions and 31 deletions.
2 changes: 1 addition & 1 deletion planning/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nav:
- 'Scene Module':
- 'Avoidance': planning/behavior_path_avoidance_module
- 'Avoidance by Lane Change': planning/behavior_path_avoidance_by_lane_change_module
- 'Dynamic Avoidance': planning/behavior_path_planner/docs/behavior_path_planner_dynamic_avoidance_design
- 'Dynamic Avoidance': planning/behavior_path_dynamic_avoidance_module
- 'Goal Planner': planning/behavior_path_goal_planner_module
- 'Lane Change': planning/behavior_path_lane_change_module
- 'Side Shift': planning/behavior_path_side_shift_module
Expand Down
25 changes: 25 additions & 0 deletions planning/behavior_path_dynamic_avoidance_module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.14)
project(behavior_path_dynamic_avoidance_module)

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

ament_auto_add_library(${PROJECT_NAME} SHARED
src/scene.cpp
src/manager.cpp
)

if(BUILD_TESTING)
ament_add_ros_isolated_gmock(test_${PROJECT_NAME}
test/test_behavior_path_planner_node_interface.cpp
)

target_link_libraries(test_${PROJECT_NAME}
${PROJECT_NAME}
)

target_include_directories(test_${PROJECT_NAME} PRIVATE src)
endif()

ament_auto_package(INSTALL_TO_SHARE config)
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ First, a maximum lateral offset to avoid is calculated as follows.
The polygon's width to extract from the drivable area is the obstacle width and double `drivable_area_generation.lat_offset_from_obstacle`.
We can limit the lateral shift offset by `drivable_area_generation.max_lat_offset_to_avoid`.

![drivable_area_extraction_width](../image/dynamic_avoidance/drivable_area_extraction_width.drawio.svg)
![drivable_area_extraction_width](./image/drivable_area_extraction_width.drawio.svg)

Then, extracting the same directional and opposite directional obstacles from the drivable area will work as follows considering TTC (time to collision).
Regarding the same directional obstacles, obstacles whose TTC is negative will be ignored (e.g. The obstacle is in front of the ego, and the obstacle's velocity is larger than the ego's velocity.).

Same directional obstacles
![same_directional_object](../image/dynamic_avoidance/same_directional_object.svg)
![same_directional_object](./image/same_directional_object.svg)

Opposite directional obstacles
![opposite_directional_object](../image/dynamic_avoidance/opposite_directional_object.svg)
![opposite_directional_object](./image/opposite_directional_object.svg)

## Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__MANAGER_HPP_
#define BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__MANAGER_HPP_
#ifndef BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__MANAGER_HPP_
#define BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__MANAGER_HPP_

#include "behavior_path_planner/scene_module/dynamic_avoidance/dynamic_avoidance_module.hpp"
#include "behavior_path_dynamic_avoidance_module/scene.hpp"
#include "behavior_path_planner_common/interface/scene_module_manager_interface.hpp"

#include <rclcpp/rclcpp.hpp>
Expand Down Expand Up @@ -52,4 +52,4 @@ class DynamicAvoidanceModuleManager : public SceneModuleManagerInterface

} // namespace behavior_path_planner

#endif // BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__MANAGER_HPP_
#endif // BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__MANAGER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__DYNAMIC_AVOIDANCE_MODULE_HPP_
#define BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__DYNAMIC_AVOIDANCE_MODULE_HPP_
#ifndef BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__SCENE_HPP_
#define BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__SCENE_HPP_

#include "behavior_path_planner_common/interface/scene_module_interface.hpp"

Expand All @@ -23,9 +23,6 @@
#include <autoware_auto_perception_msgs/msg/predicted_object.hpp>
#include <autoware_auto_perception_msgs/msg/predicted_path.hpp>
#include <autoware_auto_planning_msgs/msg/path_with_lane_id.hpp>
#include <autoware_auto_vehicle_msgs/msg/turn_indicators_command.hpp>
#include <tier4_planning_msgs/msg/avoidance_debug_msg.hpp>
#include <tier4_planning_msgs/msg/avoidance_debug_msg_array.hpp>

#include <algorithm>
#include <memory>
Expand Down Expand Up @@ -413,4 +410,4 @@ class DynamicAvoidanceModule : public SceneModuleInterface
};
} // namespace behavior_path_planner

#endif // BEHAVIOR_PATH_PLANNER__SCENE_MODULE__DYNAMIC_AVOIDANCE__DYNAMIC_AVOIDANCE_MODULE_HPP_
#endif // BEHAVIOR_PATH_DYNAMIC_AVOIDANCE_MODULE__SCENE_HPP_
42 changes: 42 additions & 0 deletions planning/behavior_path_dynamic_avoidance_module/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>behavior_path_dynamic_avoidance_module</name>
<version>0.1.0</version>
<description>The behavior_path_dynamic_avoidance_module package</description>

<maintainer email="[email protected]">Takayuki Murooka</maintainer>
<maintainer email="[email protected]">Yuki Takagi</maintainer>
<maintainer email="[email protected]">Satoshi Ota</maintainer>
<maintainer email="[email protected]">Kosuke Takeuchi</maintainer>

<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>
<buildtool_depend>eigen3_cmake_module</buildtool_depend>

<depend>autoware_auto_perception_msgs</depend>
<depend>autoware_auto_planning_msgs</depend>
<depend>autoware_auto_vehicle_msgs</depend>
<depend>behavior_path_planner</depend>
<depend>behavior_path_planner_common</depend>
<depend>geometry_msgs</depend>
<depend>lanelet2_core</depend>
<depend>lanelet2_extension</depend>
<depend>motion_utils</depend>
<depend>object_recognition_utils</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>signal_processing</depend>
<depend>tier4_autoware_utils</depend>
<depend>visualization_msgs</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<library path="behavior_path_planner_lib">
<library path="behavior_path_dynamic_avoidance_module">
<class type="behavior_path_planner::DynamicAvoidanceModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>
</library>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "behavior_path_planner/scene_module/dynamic_avoidance/manager.hpp"
#include "behavior_path_dynamic_avoidance_module/manager.hpp"

#include "tier4_autoware_utils/ros/update_param.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "behavior_path_planner/scene_module/dynamic_avoidance/dynamic_avoidance_module.hpp"
#include "behavior_path_dynamic_avoidance_module/scene.hpp"

#include "behavior_path_planner_common/utils/drivable_area_expansion/static_drivable_area.hpp"
#include "behavior_path_planner_common/utils/utils.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright 2023 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.

#include "behavior_path_planner/behavior_path_planner_node.hpp"

#include <ament_index_cpp/get_package_share_directory.hpp>
#include <planning_test_utils/planning_interface_test_manager.hpp>
#include <planning_test_utils/planning_interface_test_manager_utils.hpp>

#include <vector>

using behavior_path_planner::BehaviorPathPlannerNode;
using planning_test_utils::PlanningInterfaceTestManager;

std::shared_ptr<PlanningInterfaceTestManager> generateTestManager()
{
auto test_manager = std::make_shared<PlanningInterfaceTestManager>();

// set subscriber with topic name: behavior_path_planner → test_node_
test_manager->setPathWithLaneIdSubscriber("behavior_path_planner/output/path");

// set behavior_path_planner's input topic name(this topic is changed to test node)
test_manager->setRouteInputTopicName("behavior_path_planner/input/route");

test_manager->setInitialPoseTopicName("behavior_path_planner/input/odometry");

return test_manager;
}

std::shared_ptr<BehaviorPathPlannerNode> generateNode()
{
auto node_options = rclcpp::NodeOptions{};
const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");
const auto behavior_path_planner_dir =
ament_index_cpp::get_package_share_directory("behavior_path_planner");

std::vector<std::string> module_names;
module_names.emplace_back("behavior_path_planner::DynamicAvoidanceModuleManager");

std::vector<rclcpp::Parameter> params;
params.emplace_back("launch_modules", module_names);
node_options.parameter_overrides(params);

test_utils::updateNodeOptions(
node_options,
{planning_test_utils_dir + "/config/test_common.param.yaml",
planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
planning_test_utils_dir + "/config/test_vehicle_info.param.yaml",
behavior_path_planner_dir + "/config/behavior_path_planner.param.yaml",
behavior_path_planner_dir + "/config/drivable_area_expansion.param.yaml",
behavior_path_planner_dir + "/config/scene_module_manager.param.yaml",
ament_index_cpp::get_package_share_directory("behavior_path_dynamic_avoidance_module") +
"/config/dynamic_avoidance.param.yaml"});

return std::make_shared<BehaviorPathPlannerNode>(node_options);
}

void publishMandatoryTopics(
std::shared_ptr<PlanningInterfaceTestManager> test_manager,
std::shared_ptr<BehaviorPathPlannerNode> test_target_node)
{
// publish necessary topics from test_manager
test_manager->publishInitialPose(test_target_node, "behavior_path_planner/input/odometry");
test_manager->publishAcceleration(test_target_node, "behavior_path_planner/input/accel");
test_manager->publishPredictedObjects(test_target_node, "behavior_path_planner/input/perception");
test_manager->publishOccupancyGrid(
test_target_node, "behavior_path_planner/input/occupancy_grid_map");
test_manager->publishLaneDrivingScenario(
test_target_node, "behavior_path_planner/input/scenario");
test_manager->publishMap(test_target_node, "behavior_path_planner/input/vector_map");
test_manager->publishCostMap(test_target_node, "behavior_path_planner/input/costmap");
test_manager->publishOperationModeState(test_target_node, "system/operation_mode/state");
test_manager->publishLateralOffset(
test_target_node, "behavior_path_planner/input/lateral_offset");
}

TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionRoute)
{
rclcpp::init(0, nullptr);
auto test_manager = generateTestManager();
auto test_target_node = generateNode();

publishMandatoryTopics(test_manager, test_target_node);

// test for normal trajectory
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithBehaviorNominalRoute(test_target_node));
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test with empty route
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalRoute(test_target_node));
rclcpp::shutdown();
}

TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
{
rclcpp::init(0, nullptr);

auto test_manager = generateTestManager();
auto test_target_node = generateNode();
publishMandatoryTopics(test_manager, test_target_node);

// test for normal trajectory
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithBehaviorNominalRoute(test_target_node));

// make sure behavior_path_planner is running
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testRouteWithInvalidEgoPose(test_target_node));

rclcpp::shutdown();
}
4 changes: 0 additions & 4 deletions planning/behavior_path_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ autoware_package()
find_package(OpenCV REQUIRED)
find_package(magic_enum CONFIG REQUIRED)

pluginlib_export_plugin_description_file(${PROJECT_NAME} plugins.xml)

ament_auto_add_library(${PROJECT_NAME}_lib SHARED
src/planner_manager.cpp
src/behavior_path_planner_node.cpp
src/scene_module/dynamic_avoidance/dynamic_avoidance_module.cpp
src/scene_module/dynamic_avoidance/manager.cpp
)

target_include_directories(${PROJECT_NAME}_lib SYSTEM PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion planning/behavior_path_planner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Behavior Path Planner has following scene modules
| :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------- |
| Lane Following | this module generates reference path from lanelet centerline. | LINK |
| Avoidance | this module generates avoidance path when there is objects that should be avoid. | [LINK](../behavior_path_avoidance_module/README.md) |
| Dynamic Avoidance | WIP | LINK |
| Dynamic Avoidance | WIP | [LINK](../behavior_path_dynamic_avoidance_module/README.md) |
| Avoidance By Lane Change | this module generates lane change path when there is objects that should be avoid. | [LINK](../behavior_path_avoidance_by_lane_change_module/README.md) |
| Lane Change | this module is performed when it is necessary and a collision check with other vehicles is cleared. | [LINK](../behavior_path_lane_change_module/README.md) |
| External Lane Change | WIP | LINK |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,18 @@ std::shared_ptr<BehaviorPathPlannerNode> generateNode()
ament_index_cpp::get_package_share_directory("behavior_path_planner");

std::vector<std::string> module_names;
module_names.emplace_back("behavior_path_planner::DynamicAvoidanceModuleManager");

std::vector<rclcpp::Parameter> params;
params.emplace_back("launch_modules", module_names);
node_options.parameter_overrides(params);

test_utils::updateNodeOptions(
node_options,
{planning_test_utils_dir + "/config/test_common.param.yaml",
planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
planning_test_utils_dir + "/config/test_vehicle_info.param.yaml",
behavior_path_planner_dir + "/config/behavior_path_planner.param.yaml",
behavior_path_planner_dir + "/config/drivable_area_expansion.param.yaml",
behavior_path_planner_dir + "/config/scene_module_manager.param.yaml",
behavior_path_planner_dir + "/config/dynamic_avoidance/dynamic_avoidance.param.yaml"});
node_options, {planning_test_utils_dir + "/config/test_common.param.yaml",
planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
planning_test_utils_dir + "/config/test_vehicle_info.param.yaml",
behavior_path_planner_dir + "/config/behavior_path_planner.param.yaml",
behavior_path_planner_dir + "/config/drivable_area_expansion.param.yaml",
behavior_path_planner_dir + "/config/scene_module_manager.param.yaml"});

return std::make_shared<BehaviorPathPlannerNode>(node_options);
}
Expand Down

0 comments on commit c6c8e53

Please sign in to comment.