Skip to content

Commit ec82355

Browse files
committed
feat(behavior_velocity_xxx_module): add node test
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 33dc075 commit ec82355

File tree

22 files changed

+608
-0
lines changed

22 files changed

+608
-0
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
1313
src/util.cpp
1414
)
1515

16+
if(BUILD_TESTING)
17+
find_package(ament_lint_auto REQUIRED)
18+
ament_lint_auto_find_test_dependencies()
19+
file(GLOB_RECURSE TEST_SOURCES test/*.cpp)
20+
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
21+
${TEST_SOURCES}
22+
)
23+
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME})
24+
endif()
25+
1626
ament_auto_package(INSTALL_TO_SHARE config)

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<buildtool_depend>ament_cmake_auto</buildtool_depend>
1818
<buildtool_depend>autoware_cmake</buildtool_depend>
1919

20+
<depend>autoware_behavior_velocity_planner</depend>
2021
<depend>autoware_behavior_velocity_planner_common</depend>
2122
<depend>autoware_lanelet2_extension</depend>
2223
<depend>autoware_motion_utils</depend>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2024 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 <autoware/behavior_velocity_planner/test_utils.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
#include <cmath>
20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
24+
namespace autoware::behavior_velocity_planner
25+
{
26+
TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionPathWithLaneID)
27+
{
28+
rclcpp::init(0, nullptr);
29+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
30+
auto test_target_node = autoware::behavior_velocity_planner::generateNode({});
31+
32+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
33+
34+
// test with nominal path_with_lane_id
35+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
36+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
37+
38+
// test with empty path_with_lane_id
39+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalPathWithLaneId(test_target_node));
40+
rclcpp::shutdown();
41+
}
42+
43+
TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
44+
{
45+
rclcpp::init(0, nullptr);
46+
47+
const auto plugin_info_vec = {autoware::behavior_velocity_planner::PluginInfo{
48+
"blind_spot", "autoware::behavior_velocity_planner::BlindSpotModulePlugin"}};
49+
50+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
51+
auto test_target_node = autoware::behavior_velocity_planner::generateNode(plugin_info_vec);
52+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
53+
54+
// test for normal trajectory
55+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
56+
57+
// make sure behavior_path_planner is running
58+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
59+
60+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testOffTrackFromPathWithLaneId(test_target_node));
61+
62+
rclcpp::shutdown();
63+
}
64+
} // namespace autoware::behavior_velocity_planner

planning/behavior_velocity_planner/autoware_behavior_velocity_detection_area_module/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if(BUILD_TESTING)
1414
ament_lint_auto_find_test_dependencies()
1515
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
1616
test/test_utils.cpp
17+
test/test_node_interface.cpp
1718
)
1819
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME})
1920
endif()

planning/behavior_velocity_planner/autoware_behavior_velocity_detection_area_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<buildtool_depend>autoware_cmake</buildtool_depend>
1818
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
1919

20+
<depend>autoware_behavior_velocity_planner</depend>
2021
<depend>autoware_behavior_velocity_planner_common</depend>
2122
<depend>autoware_lanelet2_extension</depend>
2223
<depend>autoware_motion_utils</depend>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2024 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 <autoware/behavior_velocity_planner/test_utils.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
#include <cmath>
20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
24+
namespace autoware::behavior_velocity_planner
25+
{
26+
TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionPathWithLaneID)
27+
{
28+
rclcpp::init(0, nullptr);
29+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
30+
auto test_target_node = autoware::behavior_velocity_planner::generateNode({});
31+
32+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
33+
34+
// test with nominal path_with_lane_id
35+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
36+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
37+
38+
// test with empty path_with_lane_id
39+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalPathWithLaneId(test_target_node));
40+
rclcpp::shutdown();
41+
}
42+
43+
TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
44+
{
45+
rclcpp::init(0, nullptr);
46+
47+
const auto plugin_info_vec = {autoware::behavior_velocity_planner::PluginInfo{
48+
"detection_area", "autoware::behavior_velocity_planner::DetectionAreaModulePlugin"}};
49+
50+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
51+
auto test_target_node = autoware::behavior_velocity_planner::generateNode(plugin_info_vec);
52+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
53+
54+
// test for normal trajectory
55+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
56+
57+
// make sure behavior_path_planner is running
58+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
59+
60+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testOffTrackFromPathWithLaneId(test_target_node));
61+
62+
rclcpp::shutdown();
63+
}
64+
} // namespace autoware::behavior_velocity_planner

planning/behavior_velocity_planner/autoware_behavior_velocity_intersection_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<buildtool_depend>ament_cmake_auto</buildtool_depend>
2020
<buildtool_depend>autoware_cmake</buildtool_depend>
2121

22+
<depend>autoware_behavior_velocity_planner</depend>
2223
<depend>autoware_behavior_velocity_planner_common</depend>
2324
<depend>autoware_internal_debug_msgs</depend>
2425
<depend>autoware_interpolation</depend>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2024 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 <autoware/behavior_velocity_planner/test_utils.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
#include <cmath>
20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
24+
namespace autoware::behavior_velocity_planner
25+
{
26+
TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionPathWithLaneID)
27+
{
28+
rclcpp::init(0, nullptr);
29+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
30+
auto test_target_node = autoware::behavior_velocity_planner::generateNode({});
31+
32+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
33+
34+
// test with nominal path_with_lane_id
35+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
36+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
37+
38+
// test with empty path_with_lane_id
39+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalPathWithLaneId(test_target_node));
40+
rclcpp::shutdown();
41+
}
42+
43+
TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
44+
{
45+
rclcpp::init(0, nullptr);
46+
47+
const auto plugin_info_vec = {autoware::behavior_velocity_planner::PluginInfo{
48+
"intersection", "autoware::behavior_velocity_planner::IntersectionModulePlugin"}};
49+
50+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
51+
auto test_target_node = autoware::behavior_velocity_planner::generateNode(plugin_info_vec);
52+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
53+
54+
// test for normal trajectory
55+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
56+
57+
// make sure behavior_path_planner is running
58+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
59+
60+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testOffTrackFromPathWithLaneId(test_target_node));
61+
62+
rclcpp::shutdown();
63+
}
64+
} // namespace autoware::behavior_velocity_planner

planning/behavior_velocity_planner/autoware_behavior_velocity_no_stopping_area_module/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if(BUILD_TESTING)
1414
ament_lint_auto_find_test_dependencies()
1515
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
1616
test/test_utils.cpp
17+
test/test_node_interface.cpp
1718
)
1819
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME})
1920
endif()

planning/behavior_velocity_planner/autoware_behavior_velocity_no_stopping_area_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<buildtool_depend>ament_cmake_auto</buildtool_depend>
1818
<buildtool_depend>autoware_cmake</buildtool_depend>
1919

20+
<depend>autoware_behavior_velocity_planner</depend>
2021
<depend>autoware_behavior_velocity_planner_common</depend>
2122
<depend>autoware_interpolation</depend>
2223
<depend>autoware_lanelet2_extension</depend>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2024 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 <autoware/behavior_velocity_planner/test_utils.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
#include <cmath>
20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
24+
namespace autoware::behavior_velocity_planner
25+
{
26+
TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionPathWithLaneID)
27+
{
28+
rclcpp::init(0, nullptr);
29+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
30+
auto test_target_node = autoware::behavior_velocity_planner::generateNode({});
31+
32+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
33+
34+
// test with nominal path_with_lane_id
35+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
36+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
37+
38+
// test with empty path_with_lane_id
39+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithAbnormalPathWithLaneId(test_target_node));
40+
rclcpp::shutdown();
41+
}
42+
43+
TEST(PlanningModuleInterfaceTest, NodeTestWithOffTrackEgoPose)
44+
{
45+
rclcpp::init(0, nullptr);
46+
47+
const auto plugin_info_vec = {autoware::behavior_velocity_planner::PluginInfo{
48+
"no_stopping_area", "autoware::behavior_velocity_planner::NoStoppingAreaModulePlugin"}};
49+
50+
auto test_manager = autoware::behavior_velocity_planner::generateTestManager();
51+
auto test_target_node = autoware::behavior_velocity_planner::generateNode(plugin_info_vec);
52+
autoware::behavior_velocity_planner::publishMandatoryTopics(test_manager, test_target_node);
53+
54+
// test for normal trajectory
55+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testWithNominalPathWithLaneId(test_target_node));
56+
57+
// make sure behavior_path_planner is running
58+
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);
59+
60+
ASSERT_NO_THROW_WITH_ERROR_MSG(test_manager->testOffTrackFromPathWithLaneId(test_target_node));
61+
62+
rclcpp::shutdown();
63+
}
64+
} // namespace autoware::behavior_velocity_planner

planning/behavior_velocity_planner/autoware_behavior_velocity_run_out_module/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if(BUILD_TESTING)
2121
tests/test_path_utils.cpp
2222
tests/test_utils.cpp
2323
tests/test_state_machine.cpp
24+
tests/test_node_interface.cpp
2425
)
2526
target_link_libraries(test_${PROJECT_NAME}
2627
autoware_behavior_velocity_run_out_module

planning/behavior_velocity_planner/autoware_behavior_velocity_run_out_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
2121

2222
<depend>autoware_behavior_velocity_crosswalk_module</depend>
23+
<depend>autoware_behavior_velocity_planner</depend>
2324
<depend>autoware_behavior_velocity_planner_common</depend>
2425
<depend>autoware_internal_debug_msgs</depend>
2526
<depend>autoware_motion_utils</depend>

0 commit comments

Comments
 (0)