Skip to content

Commit 41e5903

Browse files
authored
refactor(side_shift): separate side shift module (autowarefoundation#5820)
* refactor(side_shift): separate side shift module Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * refactor(bpp): remove side shift module Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 64d12e6 commit 41e5903

15 files changed

+214
-29
lines changed

planning/behavior_path_planner/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ ament_auto_add_library(${PROJECT_NAME}_lib SHARED
1414
src/behavior_path_planner_node.cpp
1515
src/scene_module/dynamic_avoidance/dynamic_avoidance_module.cpp
1616
src/scene_module/dynamic_avoidance/manager.cpp
17-
src/scene_module/side_shift/side_shift_module.cpp
18-
src/scene_module/side_shift/manager.cpp
1917
src/scene_module/lane_change/interface.cpp
2018
src/scene_module/lane_change/normal.cpp
2119
src/scene_module/lane_change/external_request.cpp
2220
src/scene_module/lane_change/manager.cpp
2321
src/utils/lane_change/utils.cpp
24-
src/utils/side_shift/util.cpp
2522
src/utils/occupancy_grid_based_collision_detector/occupancy_grid_based_collision_detector.cpp
2623
src/marker_utils/lane_change/debug.cpp
2724
)

planning/behavior_path_planner/plugins.xml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<library path="behavior_path_planner_lib">
2-
<class type="behavior_path_planner::SideShiftModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>
32
<class type="behavior_path_planner::DynamicAvoidanceModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>
43
<class type="behavior_path_planner::LaneChangeRightModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>
54
<class type="behavior_path_planner::LaneChangeLeftModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>

planning/behavior_path_planner/test/test_behavior_path_planner_node_interface.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ std::shared_ptr<BehaviorPathPlannerNode> generateNode()
5050

5151
std::vector<std::string> module_names;
5252
module_names.emplace_back("behavior_path_planner::DynamicAvoidanceModuleManager");
53-
module_names.emplace_back("behavior_path_planner::SideShiftModuleManager");
5453
module_names.emplace_back("behavior_path_planner::LaneChangeRightModuleManager");
5554
module_names.emplace_back("behavior_path_planner::LaneChangeLeftModuleManager");
5655
module_names.emplace_back("behavior_path_planner::ExternalRequestLaneChangeRightModuleManager");
@@ -69,8 +68,7 @@ std::shared_ptr<BehaviorPathPlannerNode> generateNode()
6968
behavior_path_planner_dir + "/config/drivable_area_expansion.param.yaml",
7069
behavior_path_planner_dir + "/config/scene_module_manager.param.yaml",
7170
behavior_path_planner_dir + "/config/dynamic_avoidance/dynamic_avoidance.param.yaml",
72-
behavior_path_planner_dir + "/config/lane_change/lane_change.param.yaml",
73-
behavior_path_planner_dir + "/config/side_shift/side_shift.param.yaml"});
71+
behavior_path_planner_dir + "/config/lane_change/lane_change.param.yaml"});
7472

7573
return std::make_shared<BehaviorPathPlannerNode>(node_options);
7674
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(behavior_path_side_shift_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/scene.cpp
10+
src/utils.cpp
11+
src/manager.cpp
12+
)
13+
14+
if(BUILD_TESTING)
15+
ament_add_ros_isolated_gmock(test_${PROJECT_NAME}
16+
test/test_behavior_path_planner_node_interface.cpp
17+
)
18+
19+
target_link_libraries(test_${PROJECT_NAME}
20+
${PROJECT_NAME}
21+
)
22+
23+
target_include_directories(test_${PROJECT_NAME} PRIVATE src)
24+
endif()
25+
26+
ament_auto_package(INSTALL_TO_SHARE config)

planning/behavior_path_planner/include/behavior_path_planner/utils/side_shift/side_shift_parameters.hpp planning/behavior_path_side_shift_module/include/behavior_path_side_shift_module/data_structs.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__SIDE_SHIFT_PARAMETERS_HPP_
16-
#define BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__SIDE_SHIFT_PARAMETERS_HPP_
15+
#ifndef BEHAVIOR_PATH_SIDE_SHIFT_MODULE__DATA_STRUCTS_HPP_
16+
#define BEHAVIOR_PATH_SIDE_SHIFT_MODULE__DATA_STRUCTS_HPP_
1717

1818
#include "behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
1919

@@ -51,4 +51,4 @@ struct SideShiftDebugData
5151
};
5252

5353
} // namespace behavior_path_planner
54-
#endif // BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__SIDE_SHIFT_PARAMETERS_HPP_
54+
#endif // BEHAVIOR_PATH_SIDE_SHIFT_MODULE__DATA_STRUCTS_HPP_

planning/behavior_path_planner/include/behavior_path_planner/scene_module/side_shift/manager.hpp planning/behavior_path_side_shift_module/include/behavior_path_side_shift_module/manager.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__MANAGER_HPP_
16-
#define BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__MANAGER_HPP_
15+
#ifndef BEHAVIOR_PATH_SIDE_SHIFT_MODULE__MANAGER_HPP_
16+
#define BEHAVIOR_PATH_SIDE_SHIFT_MODULE__MANAGER_HPP_
1717

18-
#include "behavior_path_planner/scene_module/side_shift/side_shift_module.hpp"
1918
#include "behavior_path_planner_common/interface/scene_module_manager_interface.hpp"
19+
#include "behavior_path_side_shift_module/scene.hpp"
2020

2121
#include <rclcpp/rclcpp.hpp>
2222

@@ -50,4 +50,4 @@ class SideShiftModuleManager : public SceneModuleManagerInterface
5050

5151
} // namespace behavior_path_planner
5252

53-
#endif // BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__MANAGER_HPP_
53+
#endif // BEHAVIOR_PATH_SIDE_SHIFT_MODULE__MANAGER_HPP_
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Tier IV, Inc.
1+
// Copyright 2021 TIER IV, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,12 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__SIDE_SHIFT_MODULE_HPP_
16-
#define BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__SIDE_SHIFT_MODULE_HPP_
15+
#ifndef BEHAVIOR_PATH_SIDE_SHIFT_MODULE__SCENE_HPP_
16+
#define BEHAVIOR_PATH_SIDE_SHIFT_MODULE__SCENE_HPP_
1717

18-
#include "behavior_path_planner/utils/side_shift/side_shift_parameters.hpp"
1918
#include "behavior_path_planner_common/interface/scene_module_interface.hpp"
2019
#include "behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
20+
#include "behavior_path_side_shift_module/data_structs.hpp"
2121

2222
#include <rclcpp/rclcpp.hpp>
2323

@@ -134,4 +134,4 @@ class SideShiftModule : public SceneModuleInterface
134134

135135
} // namespace behavior_path_planner
136136

137-
#endif // BEHAVIOR_PATH_PLANNER__SCENE_MODULE__SIDE_SHIFT__SIDE_SHIFT_MODULE_HPP_
137+
#endif // BEHAVIOR_PATH_SIDE_SHIFT_MODULE__SCENE_HPP_

planning/behavior_path_planner/include/behavior_path_planner/utils/side_shift/util.hpp planning/behavior_path_side_shift_module/include/behavior_path_side_shift_module/utils.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Tier IV, Inc.
1+
// Copyright 2021 TIER IV, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__UTIL_HPP_
16-
#define BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__UTIL_HPP_
15+
#ifndef BEHAVIOR_PATH_SIDE_SHIFT_MODULE__UTILS_HPP_
16+
#define BEHAVIOR_PATH_SIDE_SHIFT_MODULE__UTILS_HPP_
1717

1818
#include <autoware_auto_planning_msgs/msg/path_with_lane_id.hpp>
1919
#include <geometry_msgs/msg/point.hpp>
@@ -41,4 +41,4 @@ Point transformToGrid(
4141

4242
} // namespace behavior_path_planner
4343

44-
#endif // BEHAVIOR_PATH_PLANNER__UTILS__SIDE_SHIFT__UTIL_HPP_
44+
#endif // BEHAVIOR_PATH_SIDE_SHIFT_MODULE__UTILS_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>behavior_path_side_shift_module</name>
5+
<version>0.1.0</version>
6+
<description>The behavior_path_side_shift_module package</description>
7+
8+
<maintainer email="satoshi.ota@tier4.jp">Satoshi Ota</maintainer>
9+
<maintainer email="fumiya.watanabe@tier4.jp">Fumiya Watanabe</maintainer>
10+
<maintainer email="kyoichi.sugahara@tier4.jp">Kyoichi Sugahara</maintainer>
11+
<maintainer email="tomoya.kimura@tier4.jp">Tomoya Kimura</maintainer>
12+
<maintainer email="shumpei.wakabayashi@tier4.jp">Shumpei Wakabayashi</maintainer>
13+
<maintainer email="tomohito.ando@tier4.jp">Tomohito Ando</maintainer>
14+
15+
<license>Apache License 2.0</license>
16+
17+
<buildtool_depend>ament_cmake_auto</buildtool_depend>
18+
<buildtool_depend>autoware_cmake</buildtool_depend>
19+
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
20+
21+
<depend>autoware_auto_planning_msgs</depend>
22+
<depend>behavior_path_planner</depend>
23+
<depend>behavior_path_planner_common</depend>
24+
<depend>geometry_msgs</depend>
25+
<depend>motion_utils</depend>
26+
<depend>pluginlib</depend>
27+
<depend>rclcpp</depend>
28+
<depend>tier4_autoware_utils</depend>
29+
<depend>tier4_planning_msgs</depend>
30+
31+
<test_depend>ament_cmake_ros</test_depend>
32+
<test_depend>ament_lint_auto</test_depend>
33+
<test_depend>autoware_lint_common</test_depend>
34+
35+
<export>
36+
<build_type>ament_cmake</build_type>
37+
</export>
38+
</package>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<library path="behavior_path_side_shift_module">
2+
<class type="behavior_path_planner::SideShiftModuleManager" base_class_type="behavior_path_planner::SceneModuleManagerInterface"/>
3+
</library>

planning/behavior_path_planner/src/scene_module/side_shift/manager.cpp planning/behavior_path_side_shift_module/src/manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "behavior_path_planner/scene_module/side_shift/manager.hpp"
15+
#include "behavior_path_side_shift_module/manager.hpp"
1616

1717
#include "tier4_autoware_utils/ros/update_param.hpp"
1818

planning/behavior_path_planner/src/scene_module/side_shift/side_shift_module.cpp planning/behavior_path_side_shift_module/src/scene.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Tier IV, Inc.
1+
// Copyright 2021 TIER IV, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,13 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "behavior_path_planner/scene_module/side_shift/side_shift_module.hpp"
15+
#include "behavior_path_side_shift_module/scene.hpp"
1616

17-
#include "behavior_path_planner/utils/side_shift/util.hpp"
1817
#include "behavior_path_planner_common/marker_utils/utils.hpp"
1918
#include "behavior_path_planner_common/utils/drivable_area_expansion/static_drivable_area.hpp"
2019
#include "behavior_path_planner_common/utils/path_utils.hpp"
2120
#include "behavior_path_planner_common/utils/utils.hpp"
21+
#include "behavior_path_side_shift_module/utils.hpp"
2222

2323
#include <lanelet2_extension/utility/utilities.hpp>
2424

planning/behavior_path_planner/src/utils/side_shift/util.cpp planning/behavior_path_side_shift_module/src/utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Tier IV, Inc.
1+
// Copyright 2021 TIER IV, Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "behavior_path_planner/utils/side_shift/util.hpp"
15+
#include "behavior_path_side_shift_module/utils.hpp"
1616

1717
#include "behavior_path_planner_common/utils/utils.hpp"
1818

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// Copyright 2023 TIER IV, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "ament_index_cpp/get_package_share_directory.hpp"
16+
#include "behavior_path_planner/behavior_path_planner_node.hpp"
17+
#include "planning_interface_test_manager/planning_interface_test_manager.hpp"
18+
#include "planning_interface_test_manager/planning_interface_test_manager_utils.hpp"
19+
20+
#include <gtest/gtest.h>
21+
22+
#include <cmath>
23+
#include <vector>
24+
25+
using behavior_path_planner::BehaviorPathPlannerNode;
26+
using planning_test_utils::PlanningInterfaceTestManager;
27+
28+
std::shared_ptr<PlanningInterfaceTestManager> generateTestManager()
29+
{
30+
auto test_manager = std::make_shared<PlanningInterfaceTestManager>();
31+
32+
// set subscriber with topic name: behavior_path_planner → test_node_
33+
test_manager->setPathWithLaneIdSubscriber("behavior_path_planner/output/path");
34+
35+
// set behavior_path_planner's input topic name(this topic is changed to test node)
36+
test_manager->setRouteInputTopicName("behavior_path_planner/input/route");
37+
38+
test_manager->setInitialPoseTopicName("behavior_path_planner/input/odometry");
39+
40+
return test_manager;
41+
}
42+
43+
std::shared_ptr<BehaviorPathPlannerNode> generateNode()
44+
{
45+
auto node_options = rclcpp::NodeOptions{};
46+
const auto planning_test_utils_dir =
47+
ament_index_cpp::get_package_share_directory("planning_test_utils");
48+
const auto behavior_path_planner_dir =
49+
ament_index_cpp::get_package_share_directory("behavior_path_planner");
50+
51+
std::vector<std::string> module_names;
52+
module_names.emplace_back("behavior_path_planner::SideShiftModuleManager");
53+
54+
std::vector<rclcpp::Parameter> params;
55+
params.emplace_back("launch_modules", module_names);
56+
node_options.parameter_overrides(params);
57+
58+
test_utils::updateNodeOptions(
59+
node_options, {planning_test_utils_dir + "/config/test_common.param.yaml",
60+
planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
61+
planning_test_utils_dir + "/config/test_vehicle_info.param.yaml",
62+
behavior_path_planner_dir + "/config/behavior_path_planner.param.yaml",
63+
behavior_path_planner_dir + "/config/drivable_area_expansion.param.yaml",
64+
behavior_path_planner_dir + "/config/scene_module_manager.param.yaml",
65+
ament_index_cpp::get_package_share_directory("behavior_path_side_shift_module") +
66+
"/config/side_shift.param.yaml"});
67+
68+
return std::make_shared<BehaviorPathPlannerNode>(node_options);
69+
}
70+
71+
void publishMandatoryTopics(
72+
std::shared_ptr<PlanningInterfaceTestManager> test_manager,
73+
std::shared_ptr<BehaviorPathPlannerNode> test_target_node)
74+
{
75+
// publish necessary topics from test_manager
76+
test_manager->publishInitialPose(test_target_node, "behavior_path_planner/input/odometry");
77+
test_manager->publishAcceleration(test_target_node, "behavior_path_planner/input/accel");
78+
test_manager->publishPredictedObjects(test_target_node, "behavior_path_planner/input/perception");
79+
test_manager->publishOccupancyGrid(
80+
test_target_node, "behavior_path_planner/input/occupancy_grid_map");
81+
test_manager->publishLaneDrivingScenario(
82+
test_target_node, "behavior_path_planner/input/scenario");
83+
test_manager->publishMap(test_target_node, "behavior_path_planner/input/vector_map");
84+
test_manager->publishCostMap(test_target_node, "behavior_path_planner/input/costmap");
85+
test_manager->publishOperationModeState(test_target_node, "system/operation_mode/state");
86+
test_manager->publishLateralOffset(
87+
test_target_node, "behavior_path_planner/input/lateral_offset");
88+
}
89+
90+
TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionRoute)
91+
{
92+
rclcpp::init(0, nullptr);
93+
auto test_manager = generateTestManager();
94+
auto test_target_node = generateNode();
95+
96+
publishMandatoryTopics(test_manager, test_target_node);
97+
98+
// test for normal trajectory
99+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithBehaviorNominalRoute(test_target_node));
100+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
101+
102+
// test with empty route
103+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalRoute(test_target_node));
104+
rclcpp::shutdown();
105+
}
106+
107+
TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
108+
{
109+
rclcpp::init(0, nullptr);
110+
111+
auto test_manager = generateTestManager();
112+
auto test_target_node = generateNode();
113+
publishMandatoryTopics(test_manager, test_target_node);
114+
115+
// test for normal trajectory
116+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithBehaviorNominalRoute(test_target_node));
117+
118+
// make sure behavior_path_planner is running
119+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
120+
121+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testRouteWithInvalidEgoPose(test_target_node));
122+
123+
rclcpp::shutdown();
124+
}

0 commit comments

Comments
 (0)