Skip to content

Commit 3088346

Browse files
committed
fix(behavior_velocity): visualization and interpolation (#351)
* fix(behavior_velocity): fix duplicated polygon Signed-off-by: tanaka3 <ttatcoder@outlook.jp> * feat(behavior_velocity): Add paths used by the occluded spot module to the debug visualization of BehaviorVelocityPlanner Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp> Signed-off-by: tanaka3 <ttatcoder@outlook.jp> * fix(behavior_velocity): add visualize marker and fix angle of last point Signed-off-by: tanaka3 <ttatcoder@outlook.jp> * fix(behavior_velocity): fix occlusion spot last angle after interpolation Signed-off-by: tanaka3 <ttatcoder@outlook.jp> * feat(behavior_velocity): better readability Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
1 parent 210622e commit 3088346

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

planning/behavior_velocity_planner/include/scene_module/occlusion_spot/scene_occlusion_spot_in_private_road.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class OcclusionSpotInPrivateModule : public SceneModuleInterface
4848
std::string road_type = "private";
4949
std::vector<lanelet::BasicPolygon2d> sidewalks;
5050
std::vector<occlusion_spot_utils::PossibleCollisionInfo> possible_collisions;
51+
PathWithLaneId path_raw;
52+
PathWithLaneId interp_path;
5153
};
5254

5355
OcclusionSpotInPrivateModule(

planning/behavior_velocity_planner/src/scene_module/intersection/util.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ bool splineInterpolate(
129129
output->points.at(i).point.pose.orientation = planning_utils::getQuaternionFromYaw(yaw);
130130
}
131131
if (output->points.size() > 1) {
132-
size_t l = resampled_s.size();
132+
size_t l = output->points.size();
133133
output->points.front().point.pose.orientation = output->points.at(1).point.pose.orientation;
134-
output->points.back().point.pose.orientation = output->points.at(l - 1).point.pose.orientation;
134+
output->points.back().point.pose.orientation = output->points.at(l - 2).point.pose.orientation;
135135
}
136136
return true;
137137
}

planning/behavior_velocity_planner/src/scene_module/no_stopping_area/scene_no_stopping_area.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ bool splineInterpolate(
102102
output->points.at(i).point.pose.orientation = planning_utils::getQuaternionFromYaw(yaw);
103103
}
104104
if (output->points.size() > 1) {
105-
size_t l = resampled_s.size();
105+
size_t l = output->points.size();
106106
output->points.front().point.pose.orientation = output->points.at(1).point.pose.orientation;
107-
output->points.back().point.pose.orientation = output->points.at(l - 1).point.pose.orientation;
107+
output->points.back().point.pose.orientation = output->points.at(l - 2).point.pose.orientation;
108108
}
109109
return true;
110110
}

planning/behavior_velocity_planner/src/scene_module/occlusion_spot/debug.cpp

+38-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ visualization_msgs::msg::MarkerArray makePolygonMarker(
149149
debug_marker.action = visualization_msgs::msg::Marker::ADD;
150150
debug_marker.pose.position = tier4_autoware_utils::createMarkerPosition(0.0, 0.0, z);
151151
debug_marker.pose.orientation = tier4_autoware_utils::createMarkerOrientation(0, 0, 0, 1.0);
152-
debug_marker.scale = tier4_autoware_utils::createMarkerScale(0.05, 0.05, 0.05);
152+
debug_marker.scale = tier4_autoware_utils::createMarkerScale(0.1, 0.1, 0.1);
153153
debug_marker.color = tier4_autoware_utils::createMarkerColor(1.0, 0.0, 1.0, 0.3);
154154
debug_marker.lifetime = rclcpp::Duration::from_seconds(0.1);
155155
debug_marker.ns = "sidewalk";
@@ -160,10 +160,41 @@ visualization_msgs::msg::MarkerArray makePolygonMarker(
160160
debug_marker.points.push_back(point);
161161
}
162162
debug_markers.markers.push_back(debug_marker);
163+
debug_marker.id++;
164+
debug_marker.points.clear();
163165
}
164166
return debug_markers;
165167
}
166168

169+
visualization_msgs::msg::MarkerArray createPathMarkerArray(
170+
const PathWithLaneId & path, const std::string & ns, const int64_t lane_id, const double r,
171+
const double g, const double b)
172+
{
173+
visualization_msgs::msg::MarkerArray msg;
174+
int32_t uid = planning_utils::bitShift(lane_id);
175+
int32_t i = 0;
176+
for (const auto & p : path.points) {
177+
visualization_msgs::msg::Marker marker{};
178+
marker.header.frame_id = "map";
179+
marker.ns = ns;
180+
marker.id = uid + i++;
181+
marker.lifetime = rclcpp::Duration::from_seconds(0.3);
182+
marker.type = visualization_msgs::msg::Marker::ARROW;
183+
marker.action = visualization_msgs::msg::Marker::ADD;
184+
marker.pose = p.point.pose;
185+
marker.scale = createMarkerScale(0.6, 0.3, 0.3);
186+
if (std::find(p.lane_ids.begin(), p.lane_ids.end(), lane_id) != p.lane_ids.end()) {
187+
// if p.lane_ids has lane_id
188+
marker.color = createMarkerColor(r, g, b, 0.999);
189+
} else {
190+
marker.color = createMarkerColor(0.5, 0.5, 0.5, 0.999);
191+
}
192+
msg.markers.push_back(marker);
193+
}
194+
195+
return msg;
196+
}
197+
167198
template <class T>
168199
visualization_msgs::msg::MarkerArray createMarkers(
169200
T & debug_data, [[maybe_unused]] const int64_t module_id_)
@@ -222,6 +253,12 @@ visualization_msgs::msg::MarkerArray OcclusionSpotInPrivateModule::createDebugMa
222253
appendMarkerArray(createMarkers(debug_data_, module_id_), current_time, &debug_marker_array);
223254
appendMarkerArray(
224255
makePolygonMarker(debug_data_.sidewalks, debug_data_.z), current_time, &debug_marker_array);
256+
appendMarkerArray(
257+
createPathMarkerArray(debug_data_.path_raw, "path_raw", 0, 0.0, 1.0, 1.0), current_time,
258+
&debug_marker_array);
259+
appendMarkerArray(
260+
createPathMarkerArray(debug_data_.interp_path, "path_interp", 0, 0.0, 1.0, 1.0), current_time,
261+
&debug_marker_array);
225262
return debug_marker_array;
226263
}
227264
} // namespace behavior_velocity_planner

planning/behavior_velocity_planner/src/scene_module/occlusion_spot/occlusion_spot_utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ bool splineInterpolate(
123123
output->points.at(i).point.pose.orientation = planning_utils::getQuaternionFromYaw(yaw);
124124
}
125125
if (output->points.size() > 1) {
126-
size_t l = resampled_s.size();
126+
size_t l = output->points.size();
127127
output->points.front().point.pose.orientation = output->points.at(1).point.pose.orientation;
128-
output->points.back().point.pose.orientation = output->points.at(l - 1).point.pose.orientation;
128+
output->points.back().point.pose.orientation = output->points.at(l - 2).point.pose.orientation;
129129
}
130130
return true;
131131
}

planning/behavior_velocity_planner/src/scene_module/occlusion_spot/scene_occlusion_spot_in_private_road.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ bool OcclusionSpotInPrivateModule::modifyPathVelocity(
6868
utils::clipPathByLength(*path, clipped_path, max_range);
6969
PathWithLaneId interp_path;
7070
utils::splineInterpolate(clipped_path, 1.0, &interp_path, logger_);
71+
debug_data_.interp_path = interp_path;
7172
int closest_idx = -1;
7273
if (!planning_utils::calcClosestIndex<PathWithLaneId>(
7374
interp_path, ego_pose, closest_idx, param_.dist_thr, param_.angle_thr)) {
@@ -103,6 +104,7 @@ bool OcclusionSpotInPrivateModule::modifyPathVelocity(
103104
utils::applySafeVelocityConsideringPossibleCollision(path, possible_collisions, param_);
104105
debug_data_.z = path->points.front().point.pose.position.z;
105106
debug_data_.possible_collisions = possible_collisions;
107+
debug_data_.path_raw = *path;
106108
return true;
107109
}
108110

0 commit comments

Comments
 (0)