Skip to content

Commit e652241

Browse files
committed
test(blind_spot): add unit tests
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent d50bb0b commit e652241

File tree

13 files changed

+4526
-582
lines changed

13 files changed

+4526
-582
lines changed

common/autoware_test_utils/test_map/intersection/lanelet2_map.osm

+292-547
Large diffs are not rendered by default.

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/CMakeLists.txt

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(autoware_behavior_velocity_blind_spot_module)
33

4+
option(EXPORT_TEST_PLOT_FIGURE "Export plot figures in test" OFF)
5+
46
find_package(autoware_cmake REQUIRED)
57
autoware_package()
68
pluginlib_export_plugin_description_file(autoware_behavior_velocity_planner plugins.xml)
@@ -11,6 +13,20 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
1113
src/scene.cpp
1214
src/decisions.cpp
1315
src/util.cpp
16+
src/parameter.cpp
1417
)
1518

16-
ament_auto_package(INSTALL_TO_SHARE config)
19+
if(BUILD_TESTING)
20+
if(EXPORT_TEST_PLOT_FIGURE)
21+
add_definitions(-DEXPORT_TEST_PLOT_FIGURE "-Wno-attributes")
22+
endif()
23+
find_package(ament_lint_auto REQUIRED)
24+
ament_lint_auto_find_test_dependencies()
25+
# NOTE(soblin): pybind11::scoped_interpreter needs to be initialized globaly, not in the FixtureClass instantiated for each test suite
26+
ament_add_gtest(test_${PROJECT_NAME}_util
27+
test/test_util.cpp
28+
)
29+
target_link_libraries(test_${PROJECT_NAME}_util ${PROJECT_NAME})
30+
endif()
31+
32+
ament_auto_package(INSTALL_TO_SHARE config test_data)

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/include/autoware/behavior_velocity_blind_spot_module/manager.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__MANAGER_HPP_
1616
#define AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__MANAGER_HPP_
1717

18+
#include "autoware/behavior_velocity_blind_spot_module/parameter.hpp"
1819
#include "autoware/behavior_velocity_blind_spot_module/scene.hpp"
1920

2021
#include <autoware/behavior_velocity_planner_common/plugin_interface.hpp>
@@ -38,7 +39,7 @@ class BlindSpotModuleManager : public SceneModuleManagerInterfaceWithRTC
3839
const char * getModuleName() override { return "blind_spot"; }
3940

4041
private:
41-
BlindSpotModule::PlannerParam planner_param_;
42+
PlannerParam planner_param_;
4243

4344
void launchNewModules(const tier4_planning_msgs::msg::PathWithLaneId & path) override;
4445

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
#ifndef AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__PARAMETER_HPP_
16+
#define AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__PARAMETER_HPP_
17+
18+
#include <rclcpp/node.hpp>
19+
20+
#include <string>
21+
22+
namespace autoware::behavior_velocity_planner
23+
{
24+
struct PlannerParam
25+
{
26+
static PlannerParam init(rclcpp::Node & node, const std::string & ns);
27+
bool use_pass_judge_line{};
28+
double stop_line_margin{};
29+
double backward_detection_length{};
30+
double ignore_width_from_center_line{};
31+
double adjacent_extend_width{};
32+
double opposite_adjacent_extend_width{};
33+
double max_future_movement_time{};
34+
double ttc_min{};
35+
double ttc_max{};
36+
double ttc_ego_minimal_velocity{};
37+
};
38+
} // namespace autoware::behavior_velocity_planner
39+
40+
#endif // AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__PARAMETER_HPP_

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/include/autoware/behavior_velocity_blind_spot_module/scene.hpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__SCENE_HPP_
1616
#define AUTOWARE__BEHAVIOR_VELOCITY_BLIND_SPOT_MODULE__SCENE_HPP_
1717

18+
#include <autoware/behavior_velocity_blind_spot_module/parameter.hpp>
1819
#include <autoware/behavior_velocity_blind_spot_module/util.hpp>
1920
#include <autoware/behavior_velocity_planner_common/scene_module_interface.hpp>
2021
#include <autoware/behavior_velocity_planner_common/utilization/state_machine.hpp>
@@ -70,20 +71,6 @@ class BlindSpotModule : public SceneModuleInterface
7071
};
7172

7273
public:
73-
struct PlannerParam
74-
{
75-
bool use_pass_judge_line;
76-
double stop_line_margin;
77-
double backward_detection_length;
78-
double ignore_width_from_center_line;
79-
double adjacent_extend_width;
80-
double opposite_adjacent_extend_width;
81-
double max_future_movement_time;
82-
double ttc_min;
83-
double ttc_max;
84-
double ttc_ego_minimal_velocity;
85-
};
86-
8774
BlindSpotModule(
8875
const int64_t module_id, const int64_t lane_id, const TurnDirection turn_direction,
8976
const std::shared_ptr<const PlannerData> planner_data, const PlannerParam & planner_param,

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<depend>autoware_perception_msgs</depend>
2424
<depend>autoware_planning_msgs</depend>
2525
<depend>autoware_route_handler</depend>
26+
<depend>autoware_test_utils</depend>
2627
<depend>autoware_universe_utils</depend>
2728
<depend>geometry_msgs</depend>
2829
<depend>pluginlib</depend>
@@ -31,6 +32,7 @@
3132
<depend>tier4_planning_msgs</depend>
3233
<depend>visualization_msgs</depend>
3334

35+
<test_depend>ament_cmake_ros</test_depend>
3436
<test_depend>ament_lint_auto</test_depend>
3537
<test_depend>autoware_lint_common</test_depend>
3638

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/src/manager.cpp

+1-17
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,7 @@ BlindSpotModuleManager::BlindSpotModuleManager(rclcpp::Node & node)
3434
node, getModuleName(), getEnableRTC(node, std::string(getModuleName()) + ".enable_rtc"))
3535
{
3636
const std::string ns(BlindSpotModuleManager::getModuleName());
37-
planner_param_.use_pass_judge_line =
38-
getOrDeclareParameter<bool>(node, ns + ".use_pass_judge_line");
39-
planner_param_.stop_line_margin = getOrDeclareParameter<double>(node, ns + ".stop_line_margin");
40-
planner_param_.backward_detection_length =
41-
getOrDeclareParameter<double>(node, ns + ".backward_detection_length");
42-
planner_param_.ignore_width_from_center_line =
43-
getOrDeclareParameter<double>(node, ns + ".ignore_width_from_center_line");
44-
planner_param_.adjacent_extend_width =
45-
getOrDeclareParameter<double>(node, ns + ".adjacent_extend_width");
46-
planner_param_.opposite_adjacent_extend_width =
47-
getOrDeclareParameter<double>(node, ns + ".opposite_adjacent_extend_width");
48-
planner_param_.max_future_movement_time =
49-
getOrDeclareParameter<double>(node, ns + ".max_future_movement_time");
50-
planner_param_.ttc_min = getOrDeclareParameter<double>(node, ns + ".ttc_min");
51-
planner_param_.ttc_max = getOrDeclareParameter<double>(node, ns + ".ttc_max");
52-
planner_param_.ttc_ego_minimal_velocity =
53-
getOrDeclareParameter<double>(node, ns + ".ttc_ego_minimal_velocity");
37+
planner_param_ = PlannerParam::init(node, ns);
5438
}
5539

5640
void BlindSpotModuleManager::launchNewModules(const tier4_planning_msgs::msg::PathWithLaneId & path)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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_blind_spot_module/parameter.hpp"
16+
17+
#include <autoware/universe_utils/ros/parameter.hpp>
18+
19+
#include <string>
20+
21+
namespace autoware::behavior_velocity_planner
22+
{
23+
24+
PlannerParam PlannerParam::init(rclcpp::Node & node, const std::string & ns)
25+
{
26+
using autoware::universe_utils::getOrDeclareParameter;
27+
PlannerParam param;
28+
param.use_pass_judge_line = getOrDeclareParameter<bool>(node, ns + ".use_pass_judge_line");
29+
param.stop_line_margin = getOrDeclareParameter<double>(node, ns + ".stop_line_margin");
30+
param.backward_detection_length =
31+
getOrDeclareParameter<double>(node, ns + ".backward_detection_length");
32+
param.ignore_width_from_center_line =
33+
getOrDeclareParameter<double>(node, ns + ".ignore_width_from_center_line");
34+
param.adjacent_extend_width = getOrDeclareParameter<double>(node, ns + ".adjacent_extend_width");
35+
param.opposite_adjacent_extend_width =
36+
getOrDeclareParameter<double>(node, ns + ".opposite_adjacent_extend_width");
37+
param.max_future_movement_time =
38+
getOrDeclareParameter<double>(node, ns + ".max_future_movement_time");
39+
param.ttc_min = getOrDeclareParameter<double>(node, ns + ".ttc_min");
40+
param.ttc_max = getOrDeclareParameter<double>(node, ns + ".ttc_max");
41+
param.ttc_ego_minimal_velocity =
42+
getOrDeclareParameter<double>(node, ns + ".ttc_ego_minimal_velocity");
43+
return param;
44+
}
45+
} // namespace autoware::behavior_velocity_planner

planning/behavior_velocity_planner/autoware_behavior_velocity_blind_spot_module/src/util.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ lanelet::ConstLanelets generateBlindSpotLanelets(
220220
break;
221221
}
222222
// make lane_ids unique
223-
if (std::find(lane_ids.begin(), lane_ids.end(), lane_id) == lane_ids.end()) {
224-
lane_ids.push_back(lane_id);
223+
if (std::find(lane_ids.begin(), lane_ids.end(), id) == lane_ids.end()) {
224+
lane_ids.push_back(id);
225225
}
226226
}
227227
if (found_intersection_lane) break;
@@ -301,6 +301,7 @@ lanelet::ConstLanelets generateBlindSpotLanelets(
301301
blind_spot_lanelets.push_back(ego_half_lanelet);
302302
}
303303
}
304+
304305
return blind_spot_lanelets;
305306
}
306307

0 commit comments

Comments
 (0)