Skip to content

Commit 45a3c48

Browse files
authored
refactor(autoware_behavior_velocity_stop_line_module): refactor and test (#9424)
* refactor(autoware_behavior_velocity_stop_line_module): refactor and test Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * modify Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * small changes Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * update Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * fix test error Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * update Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> --------- Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
1 parent fdc7a55 commit 45a3c48

File tree

9 files changed

+351
-228
lines changed

9 files changed

+351
-228
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,15 @@ ament_auto_add_library(${PROJECT_NAME} SHARED
1111
src/scene.cpp
1212
)
1313

14+
if(BUILD_TESTING)
15+
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
16+
test/test_scene.cpp
17+
)
18+
target_link_libraries(test_${PROJECT_NAME}
19+
gtest_main
20+
${PROJECT_NAME}
21+
)
22+
target_include_directories(test_${PROJECT_NAME} PRIVATE src)
23+
endif()
24+
1425
ament_auto_package(INSTALL_TO_SHARE config)

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/config/stop_line.param.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@
33
stop_line:
44
stop_margin: 0.0
55
stop_duration_sec: 1.0
6-
use_initialization_stop_line_state: true
76
hold_stop_margin_distance: 2.0
8-
9-
debug:
10-
show_stop_line_collision_check: false # [-] whether to show stopline collision

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<depend>tf2_geometry_msgs</depend>
3434
<depend>visualization_msgs</depend>
3535

36+
<test_depend>ament_cmake_ros</test_depend>
3637
<test_depend>ament_lint_auto</test_depend>
3738
<test_depend>autoware_lint_common</test_depend>
3839

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/src/debug.cpp

-77
Original file line numberDiff line numberDiff line change
@@ -12,89 +12,12 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "autoware/behavior_velocity_planner_common/utilization/util.hpp"
1615
#include "autoware/motion_utils/marker/virtual_wall_marker_creator.hpp"
1716
#include "autoware/universe_utils/geometry/geometry.hpp"
18-
#include "autoware/universe_utils/ros/marker_helper.hpp"
1917
#include "scene.hpp"
2018

21-
#ifdef ROS_DISTRO_GALACTIC
22-
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
23-
#else
24-
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
25-
#endif
26-
2719
namespace autoware::behavior_velocity_planner
2820
{
29-
using autoware::universe_utils::appendMarkerArray;
30-
using autoware::universe_utils::createMarkerColor;
31-
using autoware::universe_utils::createMarkerScale;
32-
33-
namespace
34-
{
35-
using DebugData = StopLineModule::DebugData;
36-
37-
visualization_msgs::msg::MarkerArray createStopLineCollisionCheck(
38-
const DebugData & debug_data, const int64_t module_id)
39-
{
40-
visualization_msgs::msg::MarkerArray msg;
41-
42-
// Search Segments
43-
{
44-
visualization_msgs::msg::Marker marker;
45-
marker.header.frame_id = "map";
46-
marker.ns = "search_segments";
47-
marker.id = module_id;
48-
marker.lifetime = rclcpp::Duration::from_seconds(0.5);
49-
marker.type = visualization_msgs::msg::Marker::SPHERE_LIST;
50-
marker.action = visualization_msgs::msg::Marker::ADD;
51-
for (const auto & e : debug_data.search_segments) {
52-
marker.points.push_back(
53-
geometry_msgs::build<geometry_msgs::msg::Point>().x(e.at(0).x()).y(e.at(0).y()).z(0.0));
54-
marker.points.push_back(
55-
geometry_msgs::build<geometry_msgs::msg::Point>().x(e.at(1).x()).y(e.at(1).y()).z(0.0));
56-
}
57-
marker.scale = createMarkerScale(0.1, 0.1, 0.1);
58-
marker.color = createMarkerColor(0.0, 0.0, 1.0, 0.999);
59-
msg.markers.push_back(marker);
60-
}
61-
62-
// Search stopline
63-
{
64-
visualization_msgs::msg::Marker marker;
65-
marker.header.frame_id = "map";
66-
marker.ns = "search_stopline";
67-
marker.id = module_id;
68-
marker.lifetime = rclcpp::Duration::from_seconds(0.5);
69-
marker.type = visualization_msgs::msg::Marker::LINE_STRIP;
70-
marker.action = visualization_msgs::msg::Marker::ADD;
71-
const auto p0 = debug_data.search_stopline.at(0);
72-
marker.points.push_back(
73-
geometry_msgs::build<geometry_msgs::msg::Point>().x(p0.x()).y(p0.y()).z(0.0));
74-
const auto p1 = debug_data.search_stopline.at(1);
75-
marker.points.push_back(
76-
geometry_msgs::build<geometry_msgs::msg::Point>().x(p1.x()).y(p1.y()).z(0.0));
77-
78-
marker.scale = createMarkerScale(0.1, 0.1, 0.1);
79-
marker.color = createMarkerColor(1.0, 0.0, 0.0, 0.999);
80-
msg.markers.push_back(marker);
81-
}
82-
83-
return msg;
84-
}
85-
86-
} // namespace
87-
88-
visualization_msgs::msg::MarkerArray StopLineModule::createDebugMarkerArray()
89-
{
90-
visualization_msgs::msg::MarkerArray debug_marker_array;
91-
if (planner_param_.show_stop_line_collision_check) {
92-
appendMarkerArray(
93-
createStopLineCollisionCheck(debug_data_, module_id_), &debug_marker_array,
94-
this->clock_->now());
95-
}
96-
return debug_marker_array;
97-
}
9821

9922
autoware::motion_utils::VirtualWalls StopLineModule::createVirtualWalls()
10023
{

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/src/manager.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include "manager.hpp"
1616

1717
#include "autoware/universe_utils/ros/parameter.hpp"
18-
#include "autoware_lanelet2_extension/utility/query.hpp"
18+
19+
#include <lanelet2_core/primitives/BasicRegulatoryElements.h>
1920

2021
#include <memory>
2122
#include <set>
@@ -28,19 +29,14 @@ using autoware::universe_utils::getOrDeclareParameter;
2829
using lanelet::TrafficSign;
2930

3031
StopLineModuleManager::StopLineModuleManager(rclcpp::Node & node)
31-
: SceneModuleManagerInterface(node, getModuleName())
32+
: SceneModuleManagerInterface(node, getModuleName()), planner_param_()
3233
{
3334
const std::string ns(StopLineModuleManager::getModuleName());
3435
auto & p = planner_param_;
3536
p.stop_margin = getOrDeclareParameter<double>(node, ns + ".stop_margin");
3637
p.hold_stop_margin_distance =
3738
getOrDeclareParameter<double>(node, ns + ".hold_stop_margin_distance");
3839
p.stop_duration_sec = getOrDeclareParameter<double>(node, ns + ".stop_duration_sec");
39-
p.use_initialization_stop_line_state =
40-
getOrDeclareParameter<bool>(node, ns + ".use_initialization_stop_line_state");
41-
// debug
42-
p.show_stop_line_collision_check =
43-
getOrDeclareParameter<bool>(node, ns + ".debug.show_stop_line_collision_check");
4440
}
4541

4642
std::vector<StopLineWithLaneId> StopLineModuleManager::getStopLinesWithLaneIdOnPath(
@@ -82,10 +78,9 @@ void StopLineModuleManager::launchNewModules(const tier4_planning_msgs::msg::Pat
8278
for (const auto & stop_line_with_lane_id :
8379
getStopLinesWithLaneIdOnPath(path, planner_data_->route_handler_->getLaneletMapPtr())) {
8480
const auto module_id = stop_line_with_lane_id.first.id();
85-
const auto lane_id = stop_line_with_lane_id.second;
8681
if (!isModuleRegistered(module_id)) {
8782
registerModule(std::make_shared<StopLineModule>(
88-
module_id, lane_id, stop_line_with_lane_id.first, planner_param_,
83+
module_id, stop_line_with_lane_id.first, planner_param_,
8984
logger_.get_child("stop_line_module"), clock_));
9085
}
9186
}

planning/behavior_velocity_planner/autoware_behavior_velocity_stop_line_module/src/manager.hpp

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

18-
#include "autoware/behavior_velocity_planner_common/plugin_interface.hpp"
1918
#include "autoware/behavior_velocity_planner_common/plugin_wrapper.hpp"
2019
#include "autoware/behavior_velocity_planner_common/scene_module_interface.hpp"
2120
#include "scene.hpp"

0 commit comments

Comments
 (0)