Skip to content

Commit

Permalink
refactor(planning_test_utils): add subscriber existance checker and t…
Browse files Browse the repository at this point in the history
…opic name validation (#3462)

* add subscriber existance checker and topic name validation

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* change function structure

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* refactor

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* style(pre-commit): autofix

* refactor

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* delete ASSERT_NO_THROW

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* modify test files in motion_velocity_smoother and planning_validator

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* modify test files in obstacle_velocity_limiter, obstacle_stop_planner and obstacle_velocity_limiter

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* modify test files in scenario_selector

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* modify test files in freespace_planner

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* modify test files in behavior_path_planner

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* Remove ament_cmake_gtest dependency from the planning_test_utils package

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* fix typo

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

---------

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
kyoichi-sugahara and pre-commit-ci[bot] authored Apr 27, 2023
1 parent 0f8d3c4 commit 855188a
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 318 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -100,7 +100,7 @@ TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionRoute)
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test with empty route
test_manager->testWithAbnormalRoute(test_target_node);
ASSERT_NO_THROW(test_manager->testWithAbnormalRoute(test_target_node));
rclcpp::shutdown();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,18 +28,14 @@ TEST(PlanningModuleInterfaceTest, testPlanningInterfaceWithVariousTrajectoryInpu
auto test_manager = std::make_shared<planning_test_utils::PlanningInterfaceTestManager>();

auto node_options = rclcpp::NodeOptions{};

const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");

const auto freespace_planner_dir =
ament_index_cpp::get_package_share_directory("freespace_planner");

node_options.arguments(
{"--ros-args", "--params-file",
planning_test_utils_dir + "/config/test_vehicle_info.param.yaml", "--params-file",
freespace_planner_dir + "/config/freespace_planner.param.yaml"});

auto test_target_node = std::make_shared<freespace_planner::FreespacePlannerNode>(node_options);

// publish necessary topics from test_manager
Expand All @@ -59,5 +55,5 @@ TEST(PlanningModuleInterfaceTest, testPlanningInterfaceWithVariousTrajectoryInpu
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test with empty route
test_manager->testWithAbnormalRoute(test_target_node);
ASSERT_NO_THROW(test_manager->testWithAbnormalRoute(test_target_node));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,16 +28,12 @@ TEST(PlanningModuleInterfaceTest, testPlanningInterfaceWithVariousTrajectoryInpu
auto test_manager = std::make_shared<planning_test_utils::PlanningInterfaceTestManager>();

auto node_options = rclcpp::NodeOptions{};

node_options.append_parameter_override("algorithm_type", "JerkFiltered");
node_options.append_parameter_override("publish_debug_trajs", false);

const auto motion_velocity_smoother_dir =
ament_index_cpp::get_package_share_directory("motion_velocity_smoother");

const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");

const auto motion_velocity_smoother_dir =
ament_index_cpp::get_package_share_directory("motion_velocity_smoother");
node_options.arguments(
{"--ros-args", "--params-file", planning_test_utils_dir + "/config/test_common.param.yaml",
"--params-file", planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
Expand Down Expand Up @@ -66,5 +62,5 @@ TEST(PlanningModuleInterfaceTest, testPlanningInterfaceWithVariousTrajectoryInpu
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test for trajectory with empty/one point/overlapping point
test_manager->testWithAbnormalTrajectory(test_target_node);
ASSERT_NO_THROW(test_manager->testWithAbnormalTrajectory(test_target_node));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,20 +28,16 @@ TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionTrajectory)
auto test_manager = std::make_shared<planning_test_utils::PlanningInterfaceTestManager>();

auto node_options = rclcpp::NodeOptions{};

const auto obstacle_cruise_planner_dir =
ament_index_cpp::get_package_share_directory("obstacle_cruise_planner");

const auto planning_test_utils_dir =
ament_index_cpp::get_package_share_directory("planning_test_utils");

node_options.arguments(
{"--ros-args", "--params-file", planning_test_utils_dir + "/config/test_common.param.yaml",
"--params-file", planning_test_utils_dir + "/config/test_nearest_search.param.yaml",
"--params-file", planning_test_utils_dir + "/config/test_vehicle_info.param.yaml",
"--params-file", obstacle_cruise_planner_dir + "/config/default_common.param.yaml",
"--params-file", obstacle_cruise_planner_dir + "/config/obstacle_cruise_planner.param.yaml"});

auto test_target_node =
std::make_shared<motion_planning::ObstacleCruisePlannerNode>(node_options);

Expand All @@ -58,9 +54,8 @@ TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionTrajectory)

// test for normal trajectory
ASSERT_NO_THROW(test_manager->testWithNominalTrajectory(test_target_node));

EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test for trajectory with empty/one point/overlapping point
test_manager->testWithAbnormalTrajectory(test_target_node);
ASSERT_NO_THROW(test_manager->testWithAbnormalTrajectory(test_target_node));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,8 @@ TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionTrajectory)

// publish necessary topics from test_manager
test_manager->publishOdometry(test_target_node, "obstacle_velocity_limiter/input/odometry");
test_manager->publishPointCloud(test_target_node, "obstacle_velocity_limiter/input/pointcloud");
test_manager->publishPointCloud(
test_target_node, "obstacle_velocity_limiter/input/obstacle_pointcloud");
test_manager->publishOccupancyGrid(
test_target_node, "obstacle_velocity_limiter/input/occupancy_grid");
test_manager->publishPredictedObjects(
Expand All @@ -64,5 +65,5 @@ TEST(PlanningModuleInterfaceTest, NodeTestWithExceptionTrajectory)
EXPECT_GE(test_manager->getReceivedTopicNum(), 1);

// test for trajectory with empty/one point/overlapping point
test_manager->testWithAbnormalTrajectory(test_target_node);
ASSERT_NO_THROW(test_manager->testWithAbnormalTrajectory(test_target_node));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Tier IV, Inc.
// Copyright 2023 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,11 +90,10 @@ class PlanningInterfaceTestManager
public:
PlanningInterfaceTestManager();

void publishOdometry(rclcpp::Node::SharedPtr target_node);
void publishOdometry(rclcpp::Node::SharedPtr target_node, std::string topic_name);

void publishInitialPose(rclcpp::Node::SharedPtr target_node);
void publishInitialPose(rclcpp::Node::SharedPtr target_node, std::string topic_name);
void publishInitialPose(
rclcpp::Node::SharedPtr target_node, std::string topic_name, const double shift = 0.0);

void publishMaxVelocity(rclcpp::Node::SharedPtr target_node, std::string topic_name);
void publishPointCloud(rclcpp::Node::SharedPtr target_node, std::string topic_name);
Expand All @@ -119,8 +118,6 @@ class PlanningInterfaceTestManager
void publishExternalCrosswalkStates(rclcpp::Node::SharedPtr target_node, std::string topic_name);
void publishExternalIntersectionStates(
rclcpp::Node::SharedPtr target_node, std::string topic_name);
void publishInitialPoseData(
rclcpp::Node::SharedPtr target_node, std::string topic_name, double shift = 0.0);

void setTrajectoryInputTopicName(std::string topic_name);
void setParkingTrajectoryInputTopicName(std::string topic_name);
Expand Down
Loading

0 comments on commit 855188a

Please sign in to comment.