Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autonomous_emergency_braking): add virtual stop wall to aeb #7894

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ common/time_utils/** christopherj.ho@gmail.com shumpei.wakabayashi@tier4.jp tomo
common/traffic_light_recognition_marker_publisher/** shumpei.wakabayashi@tier4.jp takeshi.miura@tier4.jp tomoya.kimura@tier4.jp
common/traffic_light_utils/** kotaro.uetake@tier4.jp satoshi.ota@tier4.jp shunsuke.miura@tier4.jp
common/tvm_utility/** ambroise.vincent@arm.com xinyu.wang@tier4.jp
control/autoware_autonomous_emergency_braking/** daniel.sanchez@tier4.jp mamoru.sobue@tier4.jp takamasa.horibe@tier4.jp tomoya.kimura@tier4.jp
control/autoware_autonomous_emergency_braking/** daniel.sanchez@tier4.jp mamoru.sobue@tier4.jp takamasa.horibe@tier4.jp tomoya.kimura@tier4.jp kyoichi.sugahara@tier4.jp
control/autoware_control_validator/** kyoichi.sugahara@tier4.jp makoto.kurihara@tier4.jp mamoru.sobue@tier4.jp takamasa.horibe@tier4.jp takayuki.murooka@tier4.jp
control/autoware_external_cmd_selector/** fumiya.watanabe@tier4.jp satoshi.ota@tier4.jp shumpei.wakabayashi@tier4.jp taiki.tanaka@tier4.jp takamasa.horibe@tier4.jp takayuki.murooka@tier4.jp tomoya.kimura@tier4.jp
control/autoware_joy_controller/** fumiya.watanabe@tier4.jp satoshi.ota@tier4.jp shumpei.wakabayashi@tier4.jp taiki.tanaka@tier4.jp takamasa.horibe@tier4.jp takayuki.murooka@tier4.jp tomoya.kimura@tier4.jp
Expand Down
1 change: 1 addition & 0 deletions control/autoware_autonomous_emergency_braking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ When vehicle odometry information is faulty, it is possible that the MPC fails t

| Name | Unit | Type | Description | Default value |
| :-------------------------------- | :----- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ |
| publish_debug_markers | [-] | bool | flag to publish debug markers | true |
| publish_debug_pointcloud | [-] | bool | flag to publish the point cloud used for debugging | false |
| use_predicted_trajectory | [-] | bool | flag to use the predicted path from the control module | true |
| use_imu_path | [-] | bool | flag to use the predicted path generated by sensor data | true |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Debug
publish_debug_pointcloud: false
publish_debug_markers: true

# Point cloud partitioning
detection_range_min_height: 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ class AEB : public rclcpp::Node

// member variables
bool publish_debug_pointcloud_;
bool publish_debug_markers_;
bool use_predicted_trajectory_;
bool use_imu_path_;
bool use_pointcloud_data_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
#endif

#include <vector>

namespace autoware::motion::control::autonomous_emergency_braking::utils
{
using autoware::universe_utils::Polygon2d;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<maintainer email="tomoya.kimura@tier4.jp">Tomoya Kimura</maintainer>
<maintainer email="mamoru.sobue@tier4.jp">Mamoru Sobue</maintainer>
<maintainer email="daniel.sanchez@tier4.jp">Daniel Sanchez</maintainer>
<maintainer email="kyoichi.sugahara@tier4.jp">Kyoichi Sugahara</maintainer>

<license>Apache License 2.0</license>

Expand Down
38 changes: 36 additions & 2 deletions control/autoware_autonomous_emergency_braking/src/node.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TIER IV, Inc.

Check notice on line 1 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.50 to 5.72, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,7 @@

#include <autoware/autonomous_emergency_braking/node.hpp>
#include <autoware/autonomous_emergency_braking/utils.hpp>
#include <autoware/motion_utils/marker/marker_helper.hpp>
#include <autoware/universe_utils/geometry/boost_geometry.hpp>
#include <autoware/universe_utils/geometry/boost_polygon_utils.hpp>
#include <autoware/universe_utils/geometry/geometry.hpp>
Expand Down Expand Up @@ -41,7 +42,9 @@
#include <tf2/utils.h>

#include <cmath>
#include <functional>
#include <limits>
#include <optional>
#ifdef ROS_DISTRO_GALACTIC
#include <tf2_eigen/tf2_eigen.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
Expand Down Expand Up @@ -131,6 +134,7 @@
}
// parameter
publish_debug_pointcloud_ = declare_parameter<bool>("publish_debug_pointcloud");
publish_debug_markers_ = declare_parameter<bool>("publish_debug_markers");

Check warning on line 137 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L137

Added line #L137 was not covered by tests
use_predicted_trajectory_ = declare_parameter<bool>("use_predicted_trajectory");
use_imu_path_ = declare_parameter<bool>("use_imu_path");
use_pointcloud_data_ = declare_parameter<bool>("use_pointcloud_data");
Expand Down Expand Up @@ -182,6 +186,7 @@
{
using autoware::universe_utils::updateParam;
updateParam<bool>(parameters, "publish_debug_pointcloud", publish_debug_pointcloud_);
updateParam<bool>(parameters, "publish_debug_markers", publish_debug_markers_);

Check warning on line 189 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L189

Added line #L189 was not covered by tests
updateParam<bool>(parameters, "use_predicted_trajectory", use_predicted_trajectory_);
updateParam<bool>(parameters, "use_imu_path", use_imu_path_);
updateParam<bool>(parameters, "use_pointcloud_data", use_pointcloud_data_);
Expand Down Expand Up @@ -378,7 +383,9 @@
stat.addf("RSS", "%.2f", data.rss);
stat.addf("Distance", "%.2f", data.distance_to_object);
stat.addf("Object Speed", "%.2f", data.velocity);
addCollisionMarker(data, debug_markers);
if (publish_debug_markers_) {
addCollisionMarker(data, debug_markers);

Check warning on line 387 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L387

Added line #L387 was not covered by tests
}
} else {
const std::string error_msg = "[AEB]: No Collision";
const auto diag_level = DiagnosticStatus::OK;
Expand Down Expand Up @@ -455,7 +462,7 @@
});

// Add debug markers
{
if (publish_debug_markers_) {

Check notice on line 465 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

AEB::checkCollision increases in cyclomatic complexity from 17 to 18, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
const auto [color_r, color_g, color_b, color_a] = debug_colors;
addMarker(
this->get_clock()->now(), path, ego_polys, objects, closest_object_point, color_r, color_g,
Expand Down Expand Up @@ -896,6 +903,33 @@
autoware::universe_utils::createMarkerColor(1.0, 0.0, 0.0, 0.3));
point_marker.pose.position = data.position;
debug_markers.markers.push_back(point_marker);

const auto ego_map_pose = std::invoke([this]() -> std::optional<geometry_msgs::msg::Pose> {
geometry_msgs::msg::TransformStamped tf_current_pose;

Check warning on line 908 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L907-L908

Added lines #L907 - L908 were not covered by tests
geometry_msgs::msg::Pose p;
try {
tf_current_pose = tf_buffer_.lookupTransform(
"map", "base_link", rclcpp::Time(0), rclcpp::Duration::from_seconds(1.0));
} catch (tf2::TransformException & ex) {
RCLCPP_ERROR(get_logger(), "%s", ex.what());

Check warning on line 914 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L911-L914

Added lines #L911 - L914 were not covered by tests
return std::nullopt;
}

p.orientation = tf_current_pose.transform.rotation;
p.position.x = tf_current_pose.transform.translation.x;
p.position.y = tf_current_pose.transform.translation.y;
p.position.z = tf_current_pose.transform.translation.z;

Check warning on line 921 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L918-L921

Added lines #L918 - L921 were not covered by tests
return std::make_optional(p);
});

Check warning on line 923 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L923

Added line #L923 was not covered by tests

if (ego_map_pose.has_value()) {
const double base_to_front_offset = vehicle_info_.max_longitudinal_offset_m;
const auto ego_front_pose = autoware::universe_utils::calcOffsetPose(

Check warning on line 927 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L926-L927

Added lines #L926 - L927 were not covered by tests
ego_map_pose.value(), base_to_front_offset, 0.0, 0.0, 0.0);
const auto virtual_stop_wall = autoware::motion_utils::createStopVirtualWallMarker(
ego_front_pose, "autonomous_emergency_braking", this->now(), 0);
autoware::universe_utils::appendMarkerArray(virtual_stop_wall, &debug_markers);

Check warning on line 931 in control/autoware_autonomous_emergency_braking/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

control/autoware_autonomous_emergency_braking/src/node.cpp#L930-L931

Added lines #L930 - L931 were not covered by tests
}
}

} // namespace autoware::motion::control::autonomous_emergency_braking
Expand Down
Loading