Skip to content

Commit f2f4105

Browse files
committed
fix
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 1d6da07 commit f2f4105

File tree

2 files changed

+13
-18
lines changed
  • control/autonomous_emergency_braking

2 files changed

+13
-18
lines changed

control/autonomous_emergency_braking/include/autonomous_emergency_braking/node.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ class AEB : public rclcpp::Node
141141
bool hasCollision(
142142
const double current_v, const Path & ego_path, const std::vector<ObjectData> & objects);
143143

144-
std::optional<Path> generateEgoPath(
145-
const double curr_v, const double curr_w, std::vector<Polygon2d> & polygons);
144+
Path generateEgoPath(const double curr_v, const double curr_w, std::vector<Polygon2d> & polygons);
146145
std::optional<Path> generateEgoPath(
147146
const Trajectory & predicted_traj, std::vector<Polygon2d> & polygons);
148147
void createObjectData(

control/autonomous_emergency_braking/src/node.cpp

+12-16
Original file line numberDiff line numberDiff line change
@@ -309,26 +309,22 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
309309
// step3. create ego path based on sensor data
310310
bool has_collision_ego = false;
311311
if (use_imu_path_) {
312-
Path ego_path;
313312
std::vector<Polygon2d> ego_polys;
314313
const double current_w = angular_velocity_ptr_->z;
315314
constexpr double color_r = 0.0 / 256.0;
316315
constexpr double color_g = 148.0 / 256.0;
317316
constexpr double color_b = 205.0 / 256.0;
318317
constexpr double color_a = 0.999;
319318
const auto current_time = get_clock()->now();
320-
const auto ego_path_opt = generateEgoPath(current_v, current_w, ego_polys);
321-
if (ego_path_opt) {
322-
const auto & ego_path = ego_path_opt.value();
323-
std::vector<ObjectData> objects;
324-
createObjectData(ego_path, ego_polys, current_time, objects);
325-
has_collision_ego = hasCollision(current_v, ego_path, objects);
326-
327-
std::string ns = "ego";
328-
addMarker(
329-
current_time, ego_path, ego_polys, objects, color_r, color_g, color_b, color_a, ns,
330-
debug_markers);
331-
}
319+
const auto ego_path = generateEgoPath(current_v, current_w, ego_polys);
320+
std::vector<ObjectData> objects;
321+
createObjectData(ego_path, ego_polys, current_time, objects);
322+
has_collision_ego = hasCollision(current_v, ego_path, objects);
323+
324+
std::string ns = "ego";
325+
addMarker(
326+
current_time, ego_path, ego_polys, objects, color_r, color_g, color_b, color_a, ns,
327+
debug_markers);
332328
}
333329

334330
// step4. transform predicted trajectory from control module
@@ -388,7 +384,7 @@ bool AEB::hasCollision(
388384
return false;
389385
}
390386

391-
std::optional<Path> AEB::generateEgoPath(
387+
Path AEB::generateEgoPath(
392388
const double curr_v, const double curr_w, std::vector<Polygon2d> & polygons)
393389
{
394390
Path path;
@@ -402,7 +398,7 @@ std::optional<Path> AEB::generateEgoPath(
402398

403399
if (curr_v < 0.1) {
404400
// if current velocity is too small, assume it stops at the same point
405-
return std::nullopt;
401+
return path;
406402
}
407403

408404
constexpr double epsilon = 1e-6;
@@ -450,7 +446,6 @@ std::optional<Path> AEB::generateEgoPath(
450446
return std::nullopt;
451447
}
452448

453-
Path path;
454449
geometry_msgs::msg::TransformStamped transform_stamped{};
455450
try {
456451
transform_stamped = tf_buffer_.lookupTransform(
@@ -462,6 +457,7 @@ std::optional<Path> AEB::generateEgoPath(
462457
}
463458

464459
// create path
460+
Path path;
465461
path.resize(predicted_traj.points.size());
466462
for (size_t i = 0; i < predicted_traj.points.size(); ++i) {
467463
geometry_msgs::msg::Pose map_pose;

0 commit comments

Comments
 (0)