Skip to content

Commit 320eaa3

Browse files
committed
refactor(blind_spot): organize based on decision policy
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 003ee0c commit 320eaa3

File tree

4 files changed

+209
-231
lines changed

4 files changed

+209
-231
lines changed

planning/behavior_velocity_blind_spot_module/src/debug.cpp

+2-52
Original file line numberDiff line numberDiff line change
@@ -71,55 +71,16 @@ visualization_msgs::msg::MarkerArray createLaneletPolygonsMarkerArray(
7171
return msg;
7272
}
7373

74-
visualization_msgs::msg::MarkerArray createPoseMarkerArray(
75-
const geometry_msgs::msg::Pose & pose, const StateMachine::State & state, const std::string & ns,
76-
const int64_t id, const double r, const double g, const double b)
77-
{
78-
visualization_msgs::msg::MarkerArray msg;
79-
80-
if (state == StateMachine::State::STOP) {
81-
visualization_msgs::msg::Marker marker_line{};
82-
marker_line.header.frame_id = "map";
83-
marker_line.ns = ns + "_line";
84-
marker_line.id = id;
85-
marker_line.lifetime = rclcpp::Duration::from_seconds(0.3);
86-
marker_line.type = visualization_msgs::msg::Marker::LINE_STRIP;
87-
marker_line.action = visualization_msgs::msg::Marker::ADD;
88-
marker_line.pose.orientation = createMarkerOrientation(0, 0, 0, 1.0);
89-
marker_line.scale = createMarkerScale(0.1, 0.0, 0.0);
90-
marker_line.color = createMarkerColor(r, g, b, 0.999);
91-
92-
const double yaw = tf2::getYaw(pose.orientation);
93-
94-
const double a = 3.0;
95-
geometry_msgs::msg::Point p0;
96-
p0.x = pose.position.x - a * std::sin(yaw);
97-
p0.y = pose.position.y + a * std::cos(yaw);
98-
p0.z = pose.position.z;
99-
marker_line.points.push_back(p0);
100-
101-
geometry_msgs::msg::Point p1;
102-
p1.x = pose.position.x + a * std::sin(yaw);
103-
p1.y = pose.position.y - a * std::cos(yaw);
104-
p1.z = pose.position.z;
105-
marker_line.points.push_back(p1);
106-
107-
msg.markers.push_back(marker_line);
108-
}
109-
110-
return msg;
111-
}
112-
11374
} // namespace
11475

11576
motion_utils::VirtualWalls BlindSpotModule::createVirtualWalls()
11677
{
11778
motion_utils::VirtualWalls virtual_walls;
11879

119-
if (!isActivated() && !is_over_pass_judge_line_) {
80+
if (debug_data_.virtual_wall_pose) {
12081
motion_utils::VirtualWall wall;
12182
wall.text = "blind_spot";
122-
wall.pose = debug_data_.virtual_wall_pose;
83+
wall.pose = debug_data_.virtual_wall_pose.value();
12384
wall.ns = std::to_string(module_id_) + "_";
12485
virtual_walls.push_back(wall);
12586
}
@@ -130,19 +91,8 @@ visualization_msgs::msg::MarkerArray BlindSpotModule::createDebugMarkerArray()
13091
{
13192
visualization_msgs::msg::MarkerArray debug_marker_array;
13293

133-
const auto state = state_machine_.getState();
13494
const auto now = this->clock_->now();
13595

136-
appendMarkerArray(
137-
createPoseMarkerArray(
138-
debug_data_.stop_point_pose, state, "stop_point_pose", module_id_, 1.0, 0.0, 0.0),
139-
&debug_marker_array, now);
140-
141-
appendMarkerArray(
142-
createPoseMarkerArray(
143-
debug_data_.judge_point_pose, state, "judge_point_pose", module_id_, 1.0, 1.0, 0.5),
144-
&debug_marker_array, now);
145-
14696
appendMarkerArray(
14797
createLaneletPolygonsMarkerArray(
14898
debug_data_.conflict_areas, "conflict_area", module_id_, 0.0, 0.5, 0.5),

planning/behavior_velocity_blind_spot_module/src/manager.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,16 @@ void BlindSpotModuleManager::launchNewModules(
6363
}
6464

6565
// Is turning lane?
66-
const std::string turn_direction = ll.attributeOr("turn_direction", "else");
67-
if (turn_direction != "left" && turn_direction != "right") {
66+
const std::string turn_direction_str = ll.attributeOr("turn_direction", "else");
67+
if (turn_direction_str != "left" && turn_direction_str != "right") {
6868
continue;
6969
}
70+
const auto turn_direction = turn_direction_str == "left"
71+
? BlindSpotModule::TurnDirection::LEFT
72+
: BlindSpotModule::TurnDirection::RIGHT;
7073

7174
registerModule(std::make_shared<BlindSpotModule>(
72-
module_id, lane_id, planner_data_, planner_param_, logger_.get_child("blind_spot_module"),
75+
module_id, lane_id, turn_direction, planner_param_, logger_.get_child("blind_spot_module"),
7376
clock_));
7477
generateUUID(module_id);
7578
updateRTCStatus(

0 commit comments

Comments
 (0)