|
| 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