Skip to content

Commit 2ac3ba6

Browse files
takayuki5168kyoichi-sugahara
authored andcommitted
feat(behavior_velocity_modules): add node test (autowarefoundation#9790)
* feat(behavior_velocity_crosswalk): add node test Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * feat(behavior_velocity_xxx_module): add node test Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * fix Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> * change directory tests -> test Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com> --------- Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent 3df609e commit 2ac3ba6

File tree

38 files changed

+699
-50
lines changed

38 files changed

+699
-50
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

+2
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_behavior_velocity_rtc_interface</depend>
2223
<depend>autoware_lanelet2_extension</depend>
@@ -32,6 +33,7 @@
3233
<depend>tier4_planning_msgs</depend>
3334
<depend>visualization_msgs</depend>
3435

36+
<test_depend>ament_cmake_ros</test_depend>
3537
<test_depend>ament_lint_auto</test_depend>
3638
<test_depend>autoware_lint_common</test_depend>
3739

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_crosswalk_module/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if(BUILD_TESTING)
1515
ament_lint_auto_find_test_dependencies()
1616
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
1717
test/test_crosswalk.cpp
18+
test/test_node_interface.cpp
1819
)
1920
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME})
2021
endif()

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<buildtool_depend>autoware_cmake</buildtool_depend>
2222
<buildtool_depend>eigen3_cmake_module</buildtool_depend>
2323

24+
<depend>autoware_behavior_velocity_planner</depend>
2425
<depend>autoware_behavior_velocity_planner_common</depend>
2526
<depend>autoware_behavior_velocity_rtc_interface</depend>
2627
<depend>autoware_grid_map_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+
"crosswalk", "autoware::behavior_velocity_planner::CrosswalkModulePlugin"}};
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_behavior_velocity_rtc_interface</depend>
2425
<depend>autoware_internal_debug_msgs</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_behavior_velocity_rtc_interface</depend>
2223
<depend>autoware_interpolation</depend>

0 commit comments

Comments
 (0)