Skip to content

Commit 44364a9

Browse files
committed
feat(behavior_velocity_crosswalk): add node test
Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
1 parent eed6aec commit 44364a9

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ if(BUILD_TESTING)
1414
find_package(ament_lint_auto REQUIRED)
1515
ament_lint_auto_find_test_dependencies()
1616
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
17-
test/test_crosswalk.cpp
17+
# 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_grid_map_utils</depend>
2627
<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+
"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

0 commit comments

Comments
 (0)